How to speed up the Rust compiler in May 2025
It has been two months since my last post on the Rust compiler’s performance. Time for a small update.
Benchmarks updated
This update comes hot on the heels of the previous one because Jakub Beránek and I updated most of the “primary” benchmarks in the rustc-perf benchmark suite. These benchmarks are verbatim copies of third-party crates, and we have a policy of updating them every three years to ensure we are measuring code that people are using. This does impact data continuity, though we do have a set of old “stable” benchmarks that never change, plus “secondary” benchmarks (e.g. microbenchmarks) that rarely change.
General Progress
For the period 2025-03-17 to 2025-05-20 you can see the results on the primary metrics here: wall-time, peak memory usage, and binary size. I won’t go in to detail because none of them changed that much. This is a good thing! Because of the benchmarks update we only had 25 benchmarks (mostly secondary benchmarks) measured across the period, instead of the usual 43. My next update will include all the new benchmarks.
One notable improvement
#140561: In this PR,
Michael Goulet made a fairly small change
to how local variables are gathered by the type checker, making the gathering
lazier. This gave an impressive 10%+ reduction in compile times for certain
check
builds of the cranelift-codegen-0.119.0
benchmark, because it made
obligation processing faster. I don’t really understand the effect, but it does
make me wonder if there is some kind of custom profiling/logging we could do to
identify sub-optimal obligation processing.