-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lintcheck: parallelize #6764
lintcheck: parallelize #6764
Conversation
Use rayon to figure out the threadcount and half that for core count. For each core, create a target dir that is used. Otherwise, when running multiple clippys with the same target-dir, cargo would lock the dir and prevent parallelism. This way we can run multiple clippys at the same time (on root crates) but we sacrifice cache-hits (when we already cargo-checked crate-deps).
r? @flip1995 (rust-highfive has picked a reviewer for you, use r? to override) |
Timings on 40c server
Size of target dirs: $ du -sh target
4.2G target
$ du -sh target/lintcheck
1.6G target/lintcheck
$ du -sh target/lintcheck/shared_target_dir
1.5G target/lintcheck/shared_target_dir
Size of target dirs: $ du -sh target
4.7G target
$ du -sh target/lintcheck
2.2G target/lintcheck
$ du -sh target/lintcheck/shared_target_dir
2.1G target/lintcheck/shared_target_dir Overall a speed up of 5.67x. So it is definitely worth it if you have a machine with many cores, but not that relevant on smaller machines. So I would add a flag |
Lol, so we we throw in 40x the performance for a ~5-6x speedup 😆 ... I wonder if we could get slightly better performance by checking crates with large deptrees first or if the difference is negligible. |
Well if you used 4c/8t before its more like 10x the power. I also looked at
I don't think that this will help much. Computing the dep trees and the figuring out what to compile where and in which order sounds definitely too complicated. |
Extremely hacky and ugly way to figure out the total number of deps in crate dep tree: format!("{:?}", cargo_metadata::MetadataCommand::new().manifest_path("./Cargo.toml").exec().unwrap().resolve.unwrap().nodes).matches("dependencies: ").count(); |
defaults to 1 -j 0 choses the number of threads automtically (= number of physical cores)
@bors r+ Thanks! Does this command compute only the direct deps or the complete tree? |
📌 Commit 8499a32 has been approved by |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
It counts the number of deps in the entire dep tree. |
By default we use a single thread and one target dir as before.
If
-j n
is passed, usen
target dirs and run one clippy in each of them.We need several target dirs because cargo would lock them for a single process otherwise which would prevent the parallelism.
-j 0
makes rayon use $thread_count/2 (which I assume is the number of physical cores of a machine) for the number of threads.Other change:
Show output of clippy being compiled when building it for lintcheck (makes it easier to spot compiler errors etc)
Show some progress indication in the "Linting... foo 1.2.3" message.
Sort crates before linting (previously crates would be split randomly between target dirs, with the sorting, we try to make sure that even crates land in target dir 0 and odd ones in target dir 1 etc..)
Please write a short comment explaining your change (or "none" for internal only changes)
changelog: parallelize lintcheck with rayon