4 ms·
How to speed up the Rust compiler in October 2022
- moomin 4y agoI 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?
- emi2k01 4y agoYes, 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/cranelift/README.md https://github.com/bytecodealliance/wasmtime/blob/main/crane... [2]: https://github.com/bjorn3/rustc_codegen_cranelift https://github.com/bjorn3/rustc_codegen_cranelift
- spoiler 4y agoI 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?
- PoignardAzur 4y agoIt'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)
- AndyKelley 4y agoThis is inspiring work - thank you for sharing. That timer bot is a game changer.
- mkj 4y agoI 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.
- PoignardAzur 4y agoAFAIR rust-analyzer is a completely separate implementation with its own data structures, so I don't think that will help much.
- jokoon 4y agoAren'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.