Rust compiler performance in November 2026: spans, trait solver, and overall results
The author's first month of Rust compiler performance work for Hexcat focused mostly on spans[1], the data structures recording source locations that every AST, HIR, and MIR[2] node carries. A span has four 32-bit fields — source location, optional hygiene and provenance data, and an optional parent position — for 16 bytes that most of the time compress into one of three 8-byte inline formats, with the remaining cases interned[3] into a global table. A new compression scheme (#163857) cuts interning to around 1% of spans in incremental builds, down from 20-40% with the old scheme, and typically under 0.1% in non-incremental builds, reducing instruction counts across many benchmarks by more than 3% in the best cases, with even larger cycle count improvements. Follow-up PRs included Josh Triplett's micro-optimizations of span operations (over 2% in the best case) and a single-entry cache in front of a hash table repeatedly consulted during metadata encoding/decoding and stable hashing (over 4% in the best case, mostly benefiting incremental compilation); an attempt to make Option<Span> the same size as Span worked but was abandoned because it did not improve performance.
About a dozen micro-optimizations across three PRs (#163981, #164234, #165160) — early returns on hot paths, avoided allocations and recomputations, optimized special cases — cut the instruction count overhead of the new trait solver on a Check Full build of Diesel from 1.49x to 1.16x, and typenum and nalgebra also improved. Avoiding the creation of one type variable per element in literals requiring type inference, such as vec![1, 2, 3, 4], cut cycle counts by 8-12% on a stress test with a vec literal of more than 100,000 elements but helped no other benchmark; it was merged anyway because it was simple and improved one error message. A draft PR extends the trivial_consts mechanism, which skips entire passes including borrow checking for trivial consts like const N: usize = 0, to also avoid building MIR, cutting instruction counts by up to 6% in the best case (libc). Takayuki Maeda's sparse encoding mechanism for metadata slightly increased instruction counts, left cycle counts and wall-times neutral, and reduced metadata sizes by up to 37% and max RSS[4] (peak memory) by up to 7%.
Wall-time measurements from 2026-09-28 to 2026-11-02 that meet the relevance threshold show improvements on 236 tests across 45 benchmarks, some of them double-digit percentages, and regressions on just four tests across three benchmarks; the mean wall-time reduction is 2.85% and the mean max-RSS reduction is 4.46%. Of 561 instruction count measurements since the start of the year, 560 are improvements and a single one is a regression, and the second-worst improvement is 3.10%; Matyáš Racek made this observation, noting that a few weeks earlier every single result was green.
Read the original nnethercote.github.ioDiscussion
Sources
-
nnethercote.github.io
How to speed up the Rust compiler in November 2026


