Skip to content

Commit a4498f1

Browse files
committed
Avoid compacting a fresh database since we don't have any usage info yet
1 parent a2a19e0 commit a4498f1

File tree

1 file changed

+19
-14
lines changed
  • turbopack/crates/turbo-tasks-backend/src/database/turbo

1 file changed

+19
-14
lines changed

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

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pub struct TurboKeyValueDatabase {
4040
compact_join_handle: Mutex<Option<JoinHandle<Result<()>>>>,
4141
is_ci: bool,
4242
is_short_session: bool,
43+
is_fresh: bool,
4344
}
4445

4546
impl TurboKeyValueDatabase {
@@ -50,6 +51,7 @@ impl TurboKeyValueDatabase {
5051
compact_join_handle: Mutex::new(None),
5152
is_ci,
5253
is_short_session,
54+
is_fresh: db.is_empty(),
5355
})
5456
}
5557
}
@@ -111,20 +113,23 @@ impl KeyValueDatabase for TurboKeyValueDatabase {
111113
join_handle.join()?;
112114
}
113115
// Compact the database on shutdown
114-
if self.is_ci {
115-
// Fully compact in CI to reduce cache size
116-
do_compact(
117-
&self.db,
118-
"Finished filesystem cache database compaction",
119-
usize::MAX,
120-
)?;
121-
} else {
122-
// Compact with a reasonable limit in non-CI environments
123-
do_compact(
124-
&self.db,
125-
"Finished filesystem cache database compaction",
126-
available_parallelism().map_or(4, |c| max(4, c.get())),
127-
)?;
116+
// (Avoid compacting a fresh database since we don't have any usage info yet)
117+
if !self.is_fresh {
118+
if self.is_ci {
119+
// Fully compact in CI to reduce cache size
120+
do_compact(
121+
&self.db,
122+
"Finished filesystem cache database compaction",
123+
usize::MAX,
124+
)?;
125+
} else {
126+
// Compact with a reasonable limit in non-CI environments
127+
do_compact(
128+
&self.db,
129+
"Finished filesystem cache database compaction",
130+
available_parallelism().map_or(4, |c| max(4, c.get())),
131+
)?;
132+
}
128133
}
129134
// Shutdown the database
130135
self.db.shutdown()

0 commit comments

Comments
 (0)