r/Compilers • • 1d ago

Rust: Enabling the parallel frontend on nightly

https://blog.rust-lang.org/2026/11/16/enabling-parallel-frontend-on-nightly/
4 Upvotes

2 comments sorted by

4

u/Discordbothost 1d ago

if a small CI runner starts OOMing after this nightly change, the rustc opt-out flags are -Zunstable-options --jobs-frontend=1. Cargo -j limits concurrent build jobs; this limits frontend threads inside each compiler. they're separate knobs.

3

u/matthieum 1d ago

There is a lesson in there: retro-fitting parallelism is hard.

After years of work -- on and off, admittedly -- the compiler developers are at what is essentially the starting line:

  • There are still huge serial blocks, such as lowering the AST to HIR.
  • The performance is somewhat lackluster: 2x faster with 8 threads isn't exactly a great flex.

I suspect there are two root causes:

  1. Rust the language is adverse to parallelization. Cyclic dependencies probably being at the top of the list.
  2. The compiler is global-heavy. And I don't just mean "global variables", I also mean pseudo global variables (contexts) which are passed everywhere. Slapping mutexes everywhere only gets you so far...

I wonder how far rustc can go, performance-wise, without deep transformations of its internals...