mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-18 00:53:31 +00:00
lintcheck: don't run clippy in parallel by default
This commit is contained in:
parent
d931d1b5e6
commit
2d9932d720
1 changed files with 31 additions and 18 deletions
|
@ -588,28 +588,41 @@ pub fn run(clap_config: &ArgMatches) {
|
||||||
.flatten()
|
.flatten()
|
||||||
.collect()
|
.collect()
|
||||||
} else {
|
} else {
|
||||||
let counter = std::sync::atomic::AtomicUsize::new(0);
|
if config.max_jobs > 1 {
|
||||||
|
// run parallel with rayon
|
||||||
|
|
||||||
// Ask rayon for thread count. Assume that half of that is the number of physical cores
|
let counter = AtomicUsize::new(0);
|
||||||
// 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
|
// Ask rayon for thread count. Assume that half of that is the number of physical cores
|
||||||
// order to achive some kind of parallelism
|
// 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
|
||||||
|
|
||||||
// by default, use a single thread
|
// This helps when we check many small crates with dep-trees that don't have a lot of branches in
|
||||||
let num_cpus = config.max_jobs;
|
// order to achive some kind of parallelism
|
||||||
let num_crates = crates.len();
|
|
||||||
|
|
||||||
// check all crates (default)
|
// by default, use a single thread
|
||||||
crates
|
let num_cpus = config.max_jobs;
|
||||||
.into_par_iter()
|
let num_crates = crates.len();
|
||||||
.map(|krate| krate.download_and_extract())
|
|
||||||
.map(|krate| krate.run_clippy_lints(&cargo_clippy_path, &counter, num_cpus, num_crates))
|
// check all crates (default)
|
||||||
.flatten()
|
crates
|
||||||
.collect()
|
.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
|
// generate some stats
|
||||||
|
|
Loading…
Reference in a new issue