about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-03-18 12:04:21 +0100
committerGitHub <noreply@github.com>2023-03-18 12:04:21 +0100
commit7ebf2cd2b8f1f8c11f9339ef337d336a91d6f7dc (patch)
tree599c1fff28765ed61a3acb84485935c9c2417d04 /src/bootstrap
parent9599f3cc5430039b615bc5171be41a6733083dc0 (diff)
parent675c4aa2c1c142415d4e95bf550ec0b1de2493d0 (diff)
downloadrust-7ebf2cd2b8f1f8c11f9339ef337d336a91d6f7dc.tar.gz
rust-7ebf2cd2b8f1f8c11f9339ef337d336a91d6f7dc.zip
Rollup merge of #108772 - jyn514:faster-tidy, r=the8472
Speed up tidy quite a lot

I highly recommend reviewing this commit-by-commit. Based on #106440 for convenience.

## Timings

These were collected by running `x test tidy -v` to copy paste the command, then using [`samply record`](https://github.com/mstange/samply).

before (8 threads)
![image](https://user-images.githubusercontent.com/23638587/222965319-352ad2c8-367c-4d74-960a-e4bb161a6aff.png)

after (8 threads) ![image](https://user-images.githubusercontent.com/23638587/222965323-fa846f4e-727a-4bf8-8e3b-1b7b40505cc3.png)

before (64 threads) ![image](https://user-images.githubusercontent.com/23638587/222965302-dc88020c-19e9-49d9-a87d-cad054d717f3.png)
after (64 threads) ![image](https://user-images.githubusercontent.com/23638587/222965335-e73d7622-59de-41d2-9cc4-1bd67042a349.png)

The last commit makes tidy use more threads, so comparing "before (8 threads)" to "after (64 threads)" is IMO the most realistic comparison. Locally, that brings the time for me to run tidy down from 4 to .9 seconds, i.e. the majority of the time for `x test tidy` is now spend running `fmt --check`.

r? `@the8472`
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/test.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs
index f5d680df113..baddc9da48d 100644
--- a/src/bootstrap/test.rs
+++ b/src/bootstrap/test.rs
@@ -1118,7 +1118,11 @@ impl Step for Tidy {
         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");
         }