Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
1 change: 1 addition & 0 deletions turbopack/crates/turbopack-cli/benches/small_apps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 15 additions & 3 deletions turbopack/crates/turbopack-cli/src/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)]
Expand Down
14 changes: 12 additions & 2 deletions turbopack/crates/turbopack-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,25 @@ 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);

#[cfg(not(codspeed))]
rt.disable_lifo_slot();

let args = Arguments::parse();
rt.build().unwrap().block_on(main_inner(args)).unwrap();
}

Expand Down
Loading