‹ BackHN Continuity

Thread

How to speed up the Rust compiler in September 2026

279 points · 171 comments · trickypr

  1. Surac · · focus · HN ↗
    Why is the compiler slow in the first place? I have no rust knowledge, how slow us slow, lets say in comparison to a c compiler?

    What is the performance killer?

    1. jerf · · focus · HN ↗
      Doing stuff isn't free. For instance, Go compiles relatively quickly for a modern language, but the biggest reason for that is that it does less stuff than most compilers... less optimization, less checking, and some stuff built into the language to avoid some of the problems with having to read lots of headers just to compile a file and other ways of doing less stuff, but mostly the key is it does less stuff, in both the good and bad senses of that.

      If you want something like Rust that offers guarantees and checks and cross-checks by the boatload, it adds up. Macros, monomorphization, implicit code generation with traits and all those other things add up too. And you can't always get O(n) or O(n log n) code to implement those checks. Maybe it can be sped up and maybe there's tricks here or there, but at the Pareto frontier, a language that has more checks will be slower to compile than one that has fewer.

      And that's not a bad thing or a deficit in Rust, it's just the nature of the beast.

      1. ModernMech · · focus · HN ↗
        And since you bring up Go and contrast the compile time with Rust, it&#x27;s been experienced at Google (and also Volvo and other places) that Rust and Go teams are as productive whereas C++ is less than half as productive: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?t=27012&amp;v=6mZRWFQRvmw&amp;feature=youtu.be" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?t=27012&amp;v=6mZRWFQRvmw&amp;feature=...

        So the focus on Rust compile time is misplaced. It&#x27;s not a big deal in terms of overall productivity.

        1. gpm · · focus · HN ↗
          I don&#x27;t think that follows - just that compile times aren&#x27;t the only thing that matters. Maybe rust could be twice as productive as go if compile times went to zero for instance (or maybe not - just disputing that the evidence proves the claim here).
          1. ModernMech · · focus · HN ↗
            But it can&#x27;t go to zero, that was the point -- at some level you have to pay for what you get. I&#x27;m not saying the compile times couldn&#x27;t be better, but Rust can&#x27;t be Go in terms of compile times if it wants to offer the guarantees and options it does. Meanwhile if Go wants to offer more options and stronger guarantees, it won&#x27;t be able to preserve the short compile times everyone points to.
            1. vlovich123 · · focus · HN ↗
              The Cranelift backend is extremely fast. Most of the slowness is all the crazy optimizations that LLVM does + other things (generating debug info etc).
              1. dicytea · · focus · HN ↗
                Cranelift&#x27;s biggest blocker for me is that it completely breaks debuggers:

                <a href="https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;rustc_codegen_cranelift&#x2F;issues&#x2F;166" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;rustc_codegen_cranelift&#x2F;issues&#x2F;...

                1. dabinat · · focus · HN ↗
                  I’m not sure if Cranelift support will ever become stable. It’s really complex, it has tradeoffs like you mentioned, and it requires its own backend to be maintained. TPDE looks like something that could more realistically be stabilized as it just slots into the existing LLVM support.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.