Skip to content

Commit 9d7952a

Browse files
committed
Turbopack: avoid compation on initial write
1 parent 931eee8 commit 9d7952a

File tree

1 file changed

+9
-4
lines changed
  • turbopack/crates/turbo-tasks-backend/src/database

1 file changed

+9
-4
lines changed

turbopack/crates/turbo-tasks-backend/src/database/turbo.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ impl KeyValueDatabase for TurboKeyValueDatabase {
8989
batch: self.db.write_batch()?,
9090
db: &self.db,
9191
compact_join_handle: &self.compact_join_handle,
92+
initial_write: self.db.is_empty(),
9293
}))
9394
}
9495

@@ -106,6 +107,7 @@ pub struct TurboWriteBatch<'a> {
106107
batch: turbo_persistence::WriteBatch<WriteBuffer<'static>, 5>,
107108
db: &'a Arc<TurboPersistence>,
108109
compact_join_handle: &'a Mutex<Option<JoinHandle<Result<()>>>>,
110+
initial_write: bool,
109111
}
110112

111113
impl<'a> BaseWriteBatch<'a> for TurboWriteBatch<'a> {
@@ -126,10 +128,13 @@ impl<'a> BaseWriteBatch<'a> for TurboWriteBatch<'a> {
126128
// Commit the write batch
127129
self.db.commit_write_batch(self.batch)?;
128130

129-
// Start a new compaction in the background
130-
let db = self.db.clone();
131-
let handle = spawn(move || db.compact(COMPACT_MAX_COVERAGE, COMPACT_MAX_MERGE_SEQUENCE));
132-
self.compact_join_handle.lock().replace(handle);
131+
if !self.initial_write {
132+
// Start a new compaction in the background
133+
let db = self.db.clone();
134+
let handle =
135+
spawn(move || db.compact(COMPACT_MAX_COVERAGE, COMPACT_MAX_MERGE_SEQUENCE));
136+
self.compact_join_handle.lock().replace(handle);
137+
}
133138

134139
Ok(())
135140
}

0 commit comments

Comments
 (0)