Hacker News new | past | comments | ask | show | jobs | submit login
How to speed up the Rust compiler in October 2022 (nnethercote.github.io)
75 points by itamarst on Oct 27, 2022 | hide | past | favorite | 10 comments



I learned quite recently that one of the limiting factors in the Rust compiler’s performance is the LLVM IR it produces being of poor quality. This means that LLVM itself takes much longer to produce code. Are there any initiatives to address this?


Yes, I guess?: Cranelift, which is a LLVM-like library written in Rust. This could be used for faster debug builds in the future. There's a Rust backend using Cranelift [2].

If you mean addressing the poor quality of LLVM IR directly, then I don't know.

[1]: https://github.com/bytecodealliance/wasmtime/blob/main/crane... [2]: https://github.com/bjorn3/rustc_codegen_cranelift


It's unclear. There were discussions on the rustc Zulip that recently pointed to LLVM being actually quite performant at canonicalizing poor-quality IR; so any time saved in the backend by producing better IR is offset by the additional time spent in the front-end to produce that IR.

(I'm not a compiler developer, don't quote me on this)


I thought (maybe incorrectly) that most of the time is spent on linking in Rust codebase. Aside: out of curiosity, how did you find out about this fact/quirk about LLVM IR?


Amazingly, it's actually in the original rust-lang FAQ: https://prev.rust-lang.org/en-US/faq.html#why-is-rustc-slow


Thank you!


This is inspiring work - thank you for sharing. That timer bot is a game changer.


I guess the memory reduction from data structures might help rust-analyzer too? That would be pretty useful since it's always running in the background.


AFAIR rust-analyzer is a completely separate implementation with its own data structures, so I don't think that will help much.


Aren't there a lot of sorts of things that are just impossible or difficult to do in rust, like GUI, or need to be entirely rewritten in rust?

Rust can be interfaced with C, but I don't see if you can really benefit from rust safety since it can interact with unsafe languages.

It's still better than not, but if the problem is safety, mixing languages might not be easy.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: