Skip to content

Use jemalloc for Clippy #142286

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

Merged
merged 2 commits into from
Jun 20, 2025
Merged

Use jemalloc for Clippy #142286

merged 2 commits into from
Jun 20, 2025

Conversation

Kobzol
Copy link
Contributor

@Kobzol Kobzol commented Jun 10, 2025

The tool macros are annoying, we should IMO just get rid of them, create separate steps for each tool and (re)use some builders in them to share the build code.

r? @ghost

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 10, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 10, 2025

Some changes occurred in src/tools/opt-dist

cc @Kobzol

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rustbot rustbot added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Jun 10, 2025
@Kobzol
Copy link
Contributor Author

Kobzol commented Jun 10, 2025

@bors2 try

(Creating artifacts for local benchmarks)

@rust-bors
Copy link

rust-bors bot commented Jun 10, 2025

⌛ Trying commit 0c6bbfb with merge df45868

To cancel the try build, run the command @bors2 try cancel.

rust-bors bot added a commit that referenced this pull request Jun 10, 2025
[experiment] Use jemalloc for Clippy

The tool macros are annoying, we should IMO just get rid of them, create separate steps for each tool and (re)use some builders in them to share the build code.

r? `@ghost`
@rust-bors
Copy link

rust-bors bot commented Jun 10, 2025

☀️ Try build successful (CI)
Build commit: df45868 (df45868f04767f218ec5cc3d611eab803eaf32ec)

@Kobzol
Copy link
Contributor Author

Kobzol commented Jun 10, 2025

Confirmed that previously, Clippy used glibc malloc, but with this PR, it uses jemalloc, using rustc-perf:

cargo run --bin collector profile_local cachegrind `rustup +df45868f04767f218ec5cc3d611eab803eaf32ec which rustc` --profiles Clippy --scenarios Full --exact-match helloworld

In terms of performance, it looks pretty good!
image

@Kobzol Kobzol changed the title [experiment] Use jemalloc for Clippy Use jemalloc for Clippy Jun 12, 2025
@Kobzol Kobzol force-pushed the clippy-jemalloc branch from 0c6bbfb to 723dae8 Compare June 12, 2025 05:00
@Kobzol
Copy link
Contributor Author

Kobzol commented Jun 12, 2025

r? @flip1995

Copy link
Member

@flip1995 flip1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I want r? @blyxyas to take another look. r=me if it looks good to you too 👍

@rustbot rustbot assigned blyxyas and unassigned flip1995 Jun 12, 2025
@blyxyas
Copy link
Member

blyxyas commented Jun 17, 2025

I'm finding some differences in my results (although I'm checking them directly with the cachegrind annotations, not through the UI). I'll perform some more benchmarks but I have some questions. In my outputs cargo is 8.6% better, but for example syn is considerably worse (12.16b -> 13.01b), and serde is too (24b -> 28b).

Did you use RUSTFLAGS="-Wclippy:all"? With the command you provided it seems that the benchmarks fail because of some deny-level lints? Also, did you use multithreading with -Zthreads=XX?

I'll make sure that this is not a result from some background noise today, just sharing my current results. Let's hope that I can figure it out and make sure that these results are just background noise.

NOTE: Seems that although the benchmark fails, cgann- files are still created. So it doesn't really matter if the benchmark fails in this case (?)

@Kobzol
Copy link
Contributor Author

Kobzol commented Jun 17, 2025

I just used the default --profiles=Clippy in rustc-perf, which was recently fixed to actually use Clippy instead of doing a debug build 😆 No multi-threading was used, and I only ran the benchmarks presented above. I haven't actually tried Clippy on the whole benchmark suite, if it fails on some benchmarks, then we should definitely pass RUSTFLAGS="-Wclippy:all"! Would you like to send a PR to rustc-perf that adds this flag?

@blyxyas
Copy link
Member

blyxyas commented Jun 18, 2025

Finally got to benchmark it on a separate server, and in this server with -Wclippy::all (I'll open a PR to change this in rustc-perf) I've found improvements between 3.6% to 4.3% in manual revision. (Notably, single-threaded, but I don't think that multithreading will affect this significantly)

RUSTFLAGS="-Wclippy::all" cargo run -r --bin collector profile_local cachegrind `rustup +clippy-jemalloc which rustc` --profiles Clippy --scenarios Full --id clippy_jemalloc

Copy link
Member

@blyxyas blyxyas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! ❤️

@Kobzol
Copy link
Contributor Author

Kobzol commented Jun 18, 2025

Thank you for the benchmark!

@bors r=flip1995,blyxyas rollup=never

@bors
Copy link
Collaborator

bors commented Jun 18, 2025

📌 Commit 723dae8 has been approved by flip1995,blyxyas

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 18, 2025
@blyxyas
Copy link
Member

blyxyas commented Jun 18, 2025

So nostalgic using bors again

@bors
Copy link
Collaborator

bors commented Jun 20, 2025

⌛ Testing commit 723dae8 with merge c4c766b...

bors added a commit that referenced this pull request Jun 20, 2025
Use jemalloc for Clippy

The tool macros are annoying, we should IMO just get rid of them, create separate steps for each tool and (re)use some builders in them to share the build code.

r? `@ghost`
@rust-log-analyzer
Copy link
Collaborator

The job dist-x86_64-msvc failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[2025-06-20T01:21:42Z DEBUG collector::compile::benchmark] Benchmark iteration 1/1
[2025-06-20T01:21:42Z INFO  collector::compile::execute] run_rustc with incremental=false, profile=Opt, scenario=Some(Full), patch=None, backend=Llvm, target=X86_64UnknownLinuxGnu, phase=benchmark
[2025-06-20T01:21:42Z DEBUG collector::compile::execute] "\\\\?\\C:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\stage0\\bin\\cargo.exe" "rustc" "--manifest-path" "Cargo.toml" "-p" "path+file:///C:/Users/RUNNER~1/AppData/Local/Temp/.tmpkOmtjQ#[email protected]" "--release" "--" "--wrap-rustc-with" "Eprintln"
[2025-06-20T01:21:43Z INFO  collector::compile::execute] run_rustc with incremental=true, profile=Opt, scenario=Some(IncrFull), patch=None, backend=Llvm, target=X86_64UnknownLinuxGnu, phase=benchmark
[2025-06-20T01:21:43Z DEBUG collector::compile::execute] "\\\\?\\C:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\stage0\\bin\\cargo.exe" "rustc" "--manifest-path" "Cargo.toml" "-p" "path+file:///C:/Users/RUNNER~1/AppData/Local/Temp/.tmpkOmtjQ#[email protected]" "--release" "--" "--wrap-rustc-with" "Eprintln" "-C" "incremental=C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\.tmpkOmtjQ\\incremental-state"
[2025-06-20T01:21:45Z INFO  collector::compile::execute] run_rustc with incremental=true, profile=Opt, scenario=Some(IncrUnchanged), patch=None, backend=Llvm, target=X86_64UnknownLinuxGnu, phase=benchmark
[2025-06-20T01:21:45Z DEBUG collector::compile::execute] "\\\\?\\C:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\stage0\\bin\\cargo.exe" "rustc" "--manifest-path" "Cargo.toml" "-p" "path+file:///C:/Users/RUNNER~1/AppData/Local/Temp/.tmpkOmtjQ#[email protected]" "--release" "--" "--wrap-rustc-with" "Eprintln" "-C" "incremental=C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\.tmpkOmtjQ\\incremental-state"
Finished benchmark match-stress (6/9)
Executing benchmark serde-1.0.219-new-solver (7/9)
Preparing serde-1.0.219-new-solver
[2025-06-20T01:21:46Z INFO  collector::compile::execute] run_rustc with incremental=false, profile=Check, scenario=None, patch=None, backend=Llvm, target=X86_64UnknownLinuxGnu, phase=dependencies
[2025-06-20T01:21:46Z INFO  collector::compile::execute] run_rustc with incremental=false, profile=Debug, scenario=None, patch=None, backend=Llvm, target=X86_64UnknownLinuxGnu, phase=dependencies

@bors
Copy link
Collaborator

bors commented Jun 20, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 20, 2025
@Kobzol
Copy link
Contributor Author

Kobzol commented Jun 20, 2025

Looks like some spurious Windows file path error..

@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 20, 2025
@bors
Copy link
Collaborator

bors commented Jun 20, 2025

⌛ Testing commit 723dae8 with merge 18491d5...

@bors
Copy link
Collaborator

bors commented Jun 20, 2025

☀️ Test successful - checks-actions
Approved by: flip1995,blyxyas
Pushing 18491d5 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 20, 2025
@bors bors merged commit 18491d5 into rust-lang:master Jun 20, 2025
11 checks passed
@rustbot rustbot added this to the 1.89.0 milestone Jun 20, 2025
Copy link
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 5b74275 (parent) -> 18491d5 (this PR)

Test differences

No test diffs found

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 18491d5be00eb3ed2f1ccee2ac5b792694f2a7a0 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. i686-msvc-2: 7297.0s -> 11171.8s (53.1%)
  2. dist-i686-msvc: 6854.1s -> 10368.1s (51.3%)
  3. dist-x86_64-apple: 7868.7s -> 11661.7s (48.2%)
  4. x86_64-apple-1: 6732.2s -> 8569.5s (27.3%)
  5. x86_64-apple-2: 4546.3s -> 5596.5s (23.1%)
  6. dist-aarch64-apple: 6379.9s -> 5483.3s (-14.1%)
  7. aarch64-apple: 4932.8s -> 4363.8s (-11.5%)
  8. x86_64-rust-for-linux: 2819.3s -> 2543.9s (-9.8%)
  9. dist-apple-various: 6970.2s -> 6401.2s (-8.2%)
  10. dist-riscv64-linux: 4962.6s -> 4605.6s (-7.2%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (18491d5): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (primary 1.6%, secondary 2.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.6% [1.1%, 2.6%] 4
Regressions ❌
(secondary)
2.7% [1.2%, 7.1%] 17
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-5.3% [-5.3%, -5.3%] 1
All ❌✅ (primary) 1.6% [1.1%, 2.6%] 4

Cycles

Results (secondary -3.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.8% [3.8%, 3.8%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.6% [-9.0%, -2.3%] 5
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 692.705s -> 691.482s (-0.18%)
Artifact size: 372.00 MiB -> 371.94 MiB (-0.01%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants