mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
Turbopack: add manual worker count override (#84454)
This commit is contained in:
@@ -254,6 +254,10 @@ inherits = "release"
|
||||
debug-assertions = true
|
||||
overflow-checks = true
|
||||
|
||||
[profile.release-with-debug]
|
||||
inherits = "release"
|
||||
debug = true
|
||||
|
||||
[workspace.dependencies]
|
||||
# Workspace crates
|
||||
next-api = { path = "crates/next-api" }
|
||||
|
||||
@@ -74,6 +74,7 @@ fn bench_small_apps(c: &mut Criterion) {
|
||||
log_detail: false,
|
||||
full_stats: false,
|
||||
target: None,
|
||||
worker_threads: None,
|
||||
},
|
||||
no_sourcemap: false,
|
||||
no_minify: false,
|
||||
|
||||
@@ -25,6 +25,14 @@ impl Arguments {
|
||||
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(
|
||||
@@ -80,13 +88,17 @@ pub struct CommonArguments {
|
||||
#[clap(long)]
|
||||
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
|
||||
// MB.
|
||||
// #[clap(long)]
|
||||
// pub memory_limit: Option<usize>,
|
||||
/// Whether to build for the `browser` or `node``
|
||||
#[clap(long)]
|
||||
pub target: Option<Target>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Args)]
|
||||
|
||||
@@ -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.max_blocking_threads(usize::MAX - worker_threads);
|
||||
@@ -50,7 +61,6 @@ fn main() {
|
||||
#[cfg(not(codspeed))]
|
||||
rt.disable_lifo_slot();
|
||||
|
||||
let args = Arguments::parse();
|
||||
rt.build().unwrap().block_on(main_inner(args)).unwrap();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user