Unverified Commit 640d7bc5 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Turbopack: add manual worker count override (#84454)

parent 0f781a6a
...@@ -254,6 +254,10 @@ inherits = "release" ...@@ -254,6 +254,10 @@ inherits = "release"
debug-assertions = true debug-assertions = true
overflow-checks = true overflow-checks = true
[profile.release-with-debug]
inherits = "release"
debug = true
[workspace.dependencies] [workspace.dependencies]
# Workspace crates # Workspace crates
next-api = { path = "crates/next-api" } next-api = { path = "crates/next-api" }
......
...@@ -74,6 +74,7 @@ fn bench_small_apps(c: &mut Criterion) { ...@@ -74,6 +74,7 @@ fn bench_small_apps(c: &mut Criterion) {
log_detail: false, log_detail: false,
full_stats: false, full_stats: false,
target: None, target: None,
worker_threads: None,
}, },
no_sourcemap: false, no_sourcemap: false,
no_minify: false, no_minify: false,
......
...@@ -25,6 +25,14 @@ impl Arguments { ...@@ -25,6 +25,14 @@ impl Arguments {
Arguments::Dev(args) => args.common.dir.as_deref(), Arguments::Dev(args) => args.common.dir.as_deref(),
} }
} }
/// The number of worker threads to use. see [CommonArguments]::worker_threads
pub fn worker_threads(&self) -> Option<usize> {
match self {
Arguments::Build(args) => args.common.worker_threads,
Arguments::Dev(args) => args.common.worker_threads,
}
}
} }
#[derive( #[derive(
...@@ -80,13 +88,17 @@ pub struct CommonArguments { ...@@ -80,13 +88,17 @@ pub struct CommonArguments {
#[clap(long)] #[clap(long)]
pub full_stats: bool, pub full_stats: bool,
/// Whether to build for the `browser` or `node`
#[clap(long)]
pub target: Option<Target>,
/// Number of worker threads to use for parallel processing
#[clap(long)]
pub worker_threads: Option<usize>,
// Enable experimental garbage collection with the provided memory limit in // Enable experimental garbage collection with the provided memory limit in
// MB. // MB.
// #[clap(long)] // #[clap(long)]
// pub memory_limit: Option<usize>, // pub memory_limit: Option<usize>,
/// Whether to build for the `browser` or `node``
#[clap(long)]
pub target: Option<Target>,
} }
#[derive(Debug, Args)] #[derive(Debug, Args)]
......
...@@ -42,7 +42,18 @@ fn main() { ...@@ -42,7 +42,18 @@ fn main() {
}); });
}); });
let worker_threads = available_parallelism().map(|n| n.get()).unwrap_or(1); let args = Arguments::parse();
let worker_threads = args
.worker_threads()
.map(|v| {
if v == 0 {
panic!("--worker-threads=0 is invalid, you must use at least one thread.");
} else {
v
}
})
.unwrap_or_else(|| available_parallelism().map(|n| n.get()).unwrap_or(1));
rt.worker_threads(worker_threads); rt.worker_threads(worker_threads);
rt.max_blocking_threads(usize::MAX - worker_threads); rt.max_blocking_threads(usize::MAX - worker_threads);
...@@ -50,7 +61,6 @@ fn main() { ...@@ -50,7 +61,6 @@ fn main() {
#[cfg(not(codspeed))] #[cfg(not(codspeed))]
rt.disable_lifo_slot(); rt.disable_lifo_slot();
let args = Arguments::parse();
rt.build().unwrap().block_on(main_inner(args)).unwrap(); rt.build().unwrap().block_on(main_inner(args)).unwrap();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment