Skip to content
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

[Minor perf] Avoid unnecessary allocations #14509

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

blyxyas
Copy link
Member

@blyxyas blyxyas commented Mar 31, 2025

Commits:

  1. Reserve store.late_passes with 320 and store.early_passes with 64, this leaves us some leeway for adding new passes. Note that there are not as many passes are there lints.
  2. Add [env] with some MALLOC_CONF for mainly for faster testing, but to also optimize in profiling.

This PR makes it so we avoid unnecessary reallocations, oh and we now use MALLOC_CONF for some heap-allocation optimization (I tested manually every config flag and came to this conclusion, see jemalloc/TUNING.md). I'm not sure if this would impact on rustup-distributed binaries, but I'm also taking some measures to make sure that rustup-distributed Clippy binaries (and the Rust compiler overall)) use all of Jemalloc

The performance gains vary depending on factors outside of the users control, but in wasmi (my favourite crate to benchmark due to the 66K LOC) it varies between 100ms to 400ms. Overall a solid optimization.

How to test:

There are two ways to benchmark, either with cargo lintcheck --perf in the checkout and in master, then perf diff perf.data perf.data.0, or with RUSTFLAGS="-Zself-profile" cargo dev lint <my_crate>, and measureme. Choose whichever one is most comfortable.

changelog: Minor allocation performance improvements.

1. Reserve `store.late_passes` with 320 and `store.early_passes` with 64, this leaves us some leeway for adding new passes.
2. Add [env] with some MALLOC_CONF for mainly for faster testing, but to also optimize in profiling.
@rustbot
Copy link
Collaborator

rustbot commented Mar 31, 2025

r? @Jarcho

rustbot has assigned @Jarcho.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Mar 31, 2025
@blyxyas blyxyas added the performance-project For issues and PRs related to the Clippy Performance Project label Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance-project For issues and PRs related to the Clippy Performance Project S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants