Skip to content

Commit 95a4efc

Browse files
committed
Turbopack: allow to customize the parallel execution of turbo-persistence
1 parent 8491337 commit 95a4efc

File tree

10 files changed

+853
-446
lines changed

10 files changed

+853
-446
lines changed

turbopack/crates/turbo-persistence-tools/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::path::PathBuf;
44

55
use anyhow::{Context, Result, bail};
6-
use turbo_persistence::{MetaFileEntryInfo, TurboPersistence};
6+
use turbo_persistence::{MetaFileEntryInfo, SerialScheduler, TurboPersistence};
77

88
fn main() -> Result<()> {
99
// Get CLI argument
@@ -16,7 +16,7 @@ fn main() -> Result<()> {
1616
bail!("The provided path does not exist: {}", path.display());
1717
}
1818

19-
let db = TurboPersistence::open_read_only(path)?;
19+
let db: TurboPersistence<SerialScheduler> = TurboPersistence::open_read_only(path)?;
2020
let meta_info = db
2121
.meta_info()
2222
.context("Failed to retrieve meta information")?;

turbopack/crates/turbo-persistence/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ memmap2 = "0.9.5"
2222
parking_lot = { workspace = true }
2323
qfilter = { version = "0.2.4", features = ["serde"] }
2424
quick_cache = { workspace = true }
25-
rayon = { workspace = true }
2625
rustc-hash = { workspace = true }
2726
smallvec = { workspace = true }
2827
thread_local = { workspace = true }
@@ -32,6 +31,7 @@ zstd = { version = "0.13.2", features = ["zdict_builder"] }
3231

3332
[dev-dependencies]
3433
rand = { workspace = true, features = ["small_rng"] }
34+
rayon = { workspace = true }
3535
tempfile = { workspace = true }
3636

3737
[lints]

turbopack/crates/turbo-persistence/src/collector.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::mem::take;
2+
13
use crate::{
24
ValueBuffer,
35
collector_entry::{CollectorEntry, CollectorEntryValue, EntryKey},
@@ -111,4 +113,11 @@ impl<K: StoreKey, const SIZE_SHIFT: usize> Collector<K, SIZE_SHIFT> {
111113
self.total_value_size = 0;
112114
self.entries.drain(..)
113115
}
116+
117+
/// Clears the collector and drops the capacity
118+
pub fn drop_contents(&mut self) {
119+
drop(take(&mut self.entries));
120+
self.total_key_size = 0;
121+
self.total_value_size = 0;
122+
}
114123
}

0 commit comments

Comments
 (0)