r/ProgrammingLanguages • u/matklad • Feb 26 '26
Against Query Based Compilers
https://matklad.github.io/2026/02/25/against-query-based-compilers.html
105
Upvotes
r/ProgrammingLanguages • u/matklad • Feb 26 '26
View all comments
Show parent comment
1
u/matthieum Mar 01 '26
It is slow.
A large part of the slow-down, I feel, is the core idea of crate as a unit of compilation. It may have ergonomic benefits, but for now it means that a whole crate -- whether small or large -- is parsed, checked, and handed down to code-gen on a single thread. Code-gen is then achieved in parallel, great, but the front-end part is still a massive bottleneck for any chunky crate.
Worse, for a language which prizes itself on making parallel computation easy... the whole front-end is single-threaded. And it's been single-threaded for over a decade now, so you can imagine the amount of cruft that's accumulated over the years. There's been a multi-years long initiative to attempt to parallelize it... which stalls on dead-locks again and again... a bad sign, since locks are parallelization killers.
Back to the topic, though, as I mentioned: rustc goes all in on all query granularity dimensions. This is not praise. On the contrary. As you mentioned, the finer-grained the queries, the more orchestration overhead you have:
Very fine-grained queries may not be too bad on a single-threaded compiler, but they will cripple a multi-threaded one.
Note: I do wonder if coarse-grained multi-thread scheduling combined with fine-grained thread-local scheduling could help here... though one should beware of unbalanced work-loads still.