-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[Minor perf] Avoid unnecessary allocations #14509
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
base: master
Are you sure you want to change the base?
Conversation
r? @flip1995 I don't know how the malloc config interacts with builds in the rustc repo. |
I have no idea who to ask about the effects of using |
So Clippy doesn't use jemalloc at the moment, so for the MALLOC_CONF, we should first actually switch to it 😆 The preallocation makes sense, I suppose, and could be landed separately. |
@blyxyas Should we remove the |
Oh, actually I didn't realize that the |
Yeah, the |
Ah, I see. I misunderstood this then. Let me try on the next sync, if this affects building Clippy in the Rust repo in any way, and if it doesn't, merge this as-is. |
[env] | ||
MALLOC_CONF = "percpu_arena:phycpu,metadata_thp:always,dirty_decay_ms:300,muzzy_decay_ms:300" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally add a comment here explaining that this is for building Clippy a bit faster
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. ;Add comment
Commits:
store.late_passes
with 320 andstore.early_passes
with 64, this leaves us some leeway for adding new passes. Note that there are not as many passes are there lints.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 JemallocThe 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 inmaster
, thenperf diff perf.data perf.data.0
, or withRUSTFLAGS="-Zself-profile" cargo dev lint <my_crate>
, and measureme. Choose whichever one is most comfortable.changelog: Minor allocation performance improvements.