compaction: avoid no-op timeline dir fsync

Random find while looking at an idle 20k tenant pageserver where each tenant
has 9 tiny L0 layers and compaction produces no new L1s / image layers.

The aggregate CPU cost of running this every 20s for 20k tenants is
actually substantial, due to the use of spawn_blocking under the hood.
This commit is contained in:
Christian Schwarz
2024-01-10 10:41:09 +00:00
parent 69eafb56eb
commit 4dd33718e5

View File

@@ -3131,11 +3131,13 @@ impl Timeline {
.await
.context("fsync of newly created layer files")?;
par_fsync::par_fsync_async(&[self
.conf
.timeline_path(&self.tenant_shard_id, &self.timeline_id)])
.await
.context("fsync of timeline dir")?;
if !all_paths.is_empty() {
par_fsync::par_fsync_async(&[self
.conf
.timeline_path(&self.tenant_shard_id, &self.timeline_id)])
.await
.context("fsync of timeline dir")?;
}
let mut guard = self.layers.write().await;