about summary refs log tree commit diff
diff options
context:
space:
mode:
authorThe8472 <git@infinite-source.de>2021-02-20 22:52:44 +0100
committerThe8472 <git@infinite-source.de>2021-02-20 23:12:56 +0100
commit6dc948e7238780dbe3d8e19b03f720c7c1e53449 (patch)
treea4de10196065ac94bfa0ea917013ba528d61b4c4
parent211d49c73cccdcf10444c0db3b8ae1e91582c6cd (diff)
downloadrust-6dc948e7238780dbe3d8e19b03f720c7c1e53449.tar.gz
rust-6dc948e7238780dbe3d8e19b03f720c7c1e53449.zip
limit rustfmt parallelism by taking -j into account
-rw-r--r--src/bootstrap/format.rs6
1 files 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()();
             }