-
Notifications
You must be signed in to change notification settings - Fork 440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove_remote_layer: uninteresting refactorings #4936
Conversation
Drafting while we see "uninteresting refactorings" produce a new personal record of broken tests. Narrator: it never did have test failures, only compilation errors, messed up fixups. |
fd0148e
to
859a7ed
Compare
I'll fix the fixup mistake noted above, and split away the preparatory refactorings from these more unrelated fixes/refactorings. Done in latest force-push, split to #4937. |
trust vec to keep the count, avoid different kind of binding names for no reason.
if any cache helps, it should now be more likely to help.
it is captured when the error is created...
1264 tests run: 1212 passed, 0 failed, 52 skipped (full report)The comment gets automatically updated with the latest test results
2f37588 at 2023-08-09T10:33:11.268Z :recycle: |
859a7ed
to
3ee5d23
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! LGTM
Small diff to reduce number of LayerDesc clones a bit:
diff --git a/pageserver/src/tenant/layer_map.rs b/pageserver/src/tenant/layer_map.rs
index c4b894fcf..59813b19d 100644
--- a/pageserver/src/tenant/layer_map.rs
+++ b/pageserver/src/tenant/layer_map.rs
@@ -121,7 +121,7 @@ impl BatchedUpdates<'_> {
///
/// This should be called when the corresponding file on disk has been deleted.
///
- pub fn remove_historic(&mut self, layer_desc: PersistentLayerDesc) {
+ pub fn remove_historic(&mut self, layer_desc: &PersistentLayerDesc) {
self.layer_map.remove_historic_noflush(layer_desc)
}
@@ -253,11 +253,11 @@ impl LayerMap {
///
/// Helper function for BatchedUpdates::remove_historic
///
- pub fn remove_historic_noflush(&mut self, layer_desc: PersistentLayerDesc) {
+ pub fn remove_historic_noflush(&mut self, layer_desc: &PersistentLayerDesc) {
self.historic
- .remove(historic_layer_coverage::LayerKey::from(&layer_desc));
+ .remove(historic_layer_coverage::LayerKey::from(layer_desc));
let layer_key = layer_desc.key();
- if Self::is_l0(&layer_desc) {
+ if Self::is_l0(layer_desc) {
let len_before = self.l0_delta_layers.len();
let mut l0_delta_layers = std::mem::take(&mut self.l0_delta_layers);
l0_delta_layers.retain(|other| other.key() != layer_key);
@@ -766,8 +766,7 @@ mod tests {
expected_in_counts
);
- map.batch_update()
- .remove_historic(downloaded.layer_desc().clone());
+ map.batch_update().remove_historic(downloaded.layer_desc());
assert_eq!(count_layer_in(&map, downloaded.layer_desc()), (0, 0));
}
diff --git a/pageserver/src/tenant/timeline/layer_manager.rs b/pageserver/src/tenant/timeline/layer_manager.rs
index e2f1634ad..824d869be 100644
--- a/pageserver/src/tenant/timeline/layer_manager.rs
+++ b/pageserver/src/tenant/timeline/layer_manager.rs
@@ -277,7 +277,7 @@ impl LayerManager {
updates: &mut BatchedUpdates<'_>,
mapping: &mut LayerFileManager,
) {
- updates.remove_historic(layer.layer_desc().clone());
+ updates.remove_historic(layer.layer_desc());
mapping.remove(layer);
}
@@ -291,7 +291,7 @@ impl LayerManager {
metrics: &TimelineMetrics,
mapping: &mut LayerFileManager,
) -> anyhow::Result<()> {
- let desc = layer.layer_desc().to_owned();
+ let desc = layer.layer_desc();
if !layer.is_remote_layer() {
layer.delete_resident_layer_file()?;
metrics.resident_physical_size_gauge.sub(desc.file_size);
Above in 2f37588. |
|
@@ -304,17 +304,18 @@ pub async fn disk_usage_eviction_task_iteration_impl<U: Usage>( | |||
// Debug-log the list of candidates | |||
let now = SystemTime::now(); | |||
for (i, (partition, candidate)) in candidates.iter().enumerate() { | |||
let desc = candidate.layer.layer_desc(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sad this is that this is basically dead code... and it might be now more expensive than doing this in a debug!
because on prod debug is never enabled so the formatting would had never been done, but let's hope rustc/llvm decide to move this method call after the debug interest check :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. It's a virtual call, as the layer is a Arc<dyn PersistentLayer>
, which can have arbitrary side effects, so I think the optimizer will not move after the check for debug, However, it should be a cheap operation so fine to do.
…#4938) Implement a new `struct Layer` abstraction which manages downloadness internally, requiring no LayerMap locking or rewriting to download or evict providing a property "you have a layer, you can read it". The new `struct Layer` provides ability to keep the file resident via a RAII structure for new layers which still need to be uploaded. Previous solution solved this `RemoteTimelineClient::wait_completion` which lead to bugs like #5639. Evicting or the final local deletion after garbage collection is done using Arc'd value `Drop`. With a single `struct Layer` the closed open ended `trait Layer`, `trait PersistentLayer` and `struct RemoteLayer` are removed following noting that compaction could be simplified by simply not using any of the traits in between: #4839. The new `struct Layer` is a preliminary to remove `Timeline::layer_removal_cs` documented in #4745. Preliminaries: #4936, #4937, #5013, #5014, #5022, #5033, #5044, #5058, #5059, #5061, #5074, #5103, epic #5172, #5645, #5649. Related split off: #5057, #5134.
In the quest to solve #4745 by moving the download/evictedness to be internally mutable factor of a Layer and get rid of
trait PersistentLayer
at least for prod usage,layer_removal_cs
, we present some misc cleanups.