2 ms·
The rust compiler is pretty slow even in debug mode, with optimizations turned off. (Although macros and monomorphization still happen in debug mode). In gener
by josephg 6y ago
The rust compiler is pretty slow even in debug mode, with optimizations turned off. (Although macros and monomorphization still happen in debug mode).
In general I don't buy the complexity argument. Rust is more complex than Go, D or Delphi. But its not 50x more complex, or whatever we would guess from the compilation speed difference.
I suspect a lot of the compilation time bloat is a result of all the intermediate representations the code goes through, in order to play nice with LLVM's optimizers and codegen. (Or to put it another way, I suspect a compiler optimized for development mode iteration has the potential to be way faster than rustc.) If you mostly don't care about runtime performance, a debugging compiler could probably also skip monomorphization and just compile everything once and use dynamic dispatch for generics.
- mhh__ 6y agoRust doesn't have to be much slower but when your compiler has three IRs to go through it doesn't help. D is a pretty complex language, but it's explicitly designed around compile times in many locations. Changing the basic implementation of language features probably won't help a huge amount, you could probably get a lot back with a simple backend that does no optimisations other than register allocation. (The main D compiler can do more than this but it lags behind LLVM by quite a way so it's not useful for fast code)
- alex7o 6y agoD can, be a good language to compare compile time speeds, as it has LDC(LLVM D compiler), GDC(GCC D compiler) and the official compiler optimised for speed. This way we can see how much overhead stuff like llvm add. And how much the perf is better.
- deleted 6y ago[deleted]
- steveklabnik 6y agoThree IRs can actually help; it's not that simple. For example, https://blog.rust-lang.org/inside-rust/2019/12/02/const-prop-on-by-default.html https://blog.rust-lang.org/inside-rust/2019/12/02/const-prop... is an example of performing an optimization on an earlier IR, which gives you a 2%-10% speed boost. > Even though LLVM has its own constant propagation pass, we see improvements because our pass operates on MIR while it is still generic. The more concrete instances of a generic function that are instantiated, the larger the payoff from this optimization. It can be counter-intuitive, but it just really depends on the details. Of course, a single pass compiler will be faster to compile than a more complicated one, but it's not as straightforward as "more IRs == slower."
- mhh__ 6y agoMy point was more along the lines of the language is sufficiently complex to lose the bigger picture when it comes to compile time speed rather than that the compiler is definitely slower due to said IRs.