From 6dc948e7238780dbe3d8e19b03f720c7c1e53449 Mon Sep 17 00:00:00 2001 From: The8472 Date: Sat, 20 Feb 2021 22:52:44 +0100 Subject: [PATCH] limit rustfmt parallelism by taking -j into account --- src/bootstrap/format.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bootstrap/format.rs b/src/bootstrap/format.rs index 40043c6e31a..3c9b66e5a01 100644 --- a/src/bootstrap/format.rs +++ b/src/bootstrap/format.rs @@ -122,8 +122,8 @@ pub fn format(build: &Build, check: bool) { WalkBuilder::new(src.clone()).types(matcher).overrides(ignore_fmt).build_parallel(); // there is a lot of blocking involved in spawning a child process and reading files to format. - // spawn more processes than available cores to keep the CPU busy - let max_processes = num_cpus::get() * 2; + // spawn more processes than available concurrency to keep the CPU busy + let max_processes = build.jobs() as usize * 2; // spawn child processes on a separate thread so we can batch entries we have received from ignore let thread = std::thread::spawn(move || { @@ -135,7 +135,7 @@ pub fn format(build: &Build, check: bool) { let child = rustfmt(&src, &rustfmt_path, paths.as_slice(), check); children.push_back(child); - if children.len() > max_processes { + if children.len() >= max_processes { // await oldest child children.pop_front().unwrap()(); }