Let tidy use more threads

This has a significant speedup for me locally, from about 1.3 seconds to
.9 seconds.
This commit is contained in:
Joshua Nelson 2023-03-05 07:59:36 -06:00
parent 19b272a94b
commit 3a58b2b3b0

View File

@ -1118,7 +1118,11 @@ fn run(self, builder: &Builder<'_>) {
cmd.arg(&builder.src);
cmd.arg(&builder.initial_cargo);
cmd.arg(&builder.out);
cmd.arg(builder.jobs().to_string());
// Tidy is heavily IO constrained. Still respect `-j`, but use a higher limit if `jobs` hasn't been configured.
let jobs = builder.config.jobs.unwrap_or_else(|| {
8 * std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get) as u32
});
cmd.arg(jobs.to_string());
if builder.is_verbose() {
cmd.arg("--verbose");
}