about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--clippy_dev/src/lintcheck.rs57
1 files changed, 35 insertions, 22 deletions
diff --git a/clippy_dev/src/lintcheck.rs b/clippy_dev/src/lintcheck.rs
index 423daa0d190..00f406a085e 100644
--- a/clippy_dev/src/lintcheck.rs
+++ b/clippy_dev/src/lintcheck.rs
@@ -588,28 +588,41 @@ pub fn run(clap_config: &ArgMatches) {
             .flatten()
             .collect()
     } else {
-        let counter = std::sync::atomic::AtomicUsize::new(0);
-
-        // Ask rayon for thread count. Assume that half of that is the number of physical cores
-        // Use one target dir for each core so that we can run N clippys in parallel.
-        // We need to use different target dirs because cargo would lock them for a single build otherwise,
-        // killing the parallelism. However this also means that deps will only be reused half/a
-        // quarter of the time which might result in a longer wall clock runtime
-
-        // This helps when we check many small crates with dep-trees that don't have a lot of branches in
-        // order to achive some kind of parallelism
-
-        // by default, use a single thread
-        let num_cpus = config.max_jobs;
-        let num_crates = crates.len();
-
-        // check all crates (default)
-        crates
-            .into_par_iter()
-            .map(|krate| krate.download_and_extract())
-            .map(|krate| krate.run_clippy_lints(&cargo_clippy_path, &counter, num_cpus, num_crates))
-            .flatten()
-            .collect()
+        if config.max_jobs > 1 {
+            // run parallel with rayon
+
+            let counter = AtomicUsize::new(0);
+
+            // Ask rayon for thread count. Assume that half of that is the number of physical cores
+            // Use one target dir for each core so that we can run N clippys in parallel.
+            // We need to use different target dirs because cargo would lock them for a single build otherwise,
+            // killing the parallelism. However this also means that deps will only be reused half/a
+            // quarter of the time which might result in a longer wall clock runtime
+
+            // This helps when we check many small crates with dep-trees that don't have a lot of branches in
+            // order to achive some kind of parallelism
+
+            // by default, use a single thread
+            let num_cpus = config.max_jobs;
+            let num_crates = crates.len();
+
+            // check all crates (default)
+            crates
+                .into_par_iter()
+                .map(|krate| krate.download_and_extract())
+                .map(|krate| krate.run_clippy_lints(&cargo_clippy_path, &counter, num_cpus, num_crates))
+                .flatten()
+                .collect()
+        } else {
+            // run sequential
+            let num_crates = crates.len();
+            crates
+                .into_iter()
+                .map(|krate| krate.download_and_extract())
+                .map(|krate| krate.run_clippy_lints(&cargo_clippy_path, &AtomicUsize::new(0), 1, num_crates))
+                .flatten()
+                .collect()
+        }
     };
 
     // generate some stats