Skip to content

Commit 450b07e

Browse files
authored
Turbopack: allow to customize the parallel execution of turbo-persistence (#82668)
<!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # -->
1 parent e21ac64 commit 450b07e

File tree

10 files changed

+852
-446
lines changed

10 files changed

+852
-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)