4 ms·
While GATs are undeniably cool, I think I'm actually most excited by the enabling of MIR inlining. Rust level optimizations have a real potential to increase pe
by xavxav 4y ago
While GATs are undeniably cool, I think I'm actually most excited by the enabling of MIR inlining. Rust level optimizations have a real potential to increase performance and decrease compilation times, and inlining is one of the most important primitives for that.
- weinzierl 4y agoRust level optimizations sound promising. I could not find a good high level explanation what inlining means in this context and how it facilitates Rust level optimizations. I've read https://rustc-dev-guide.rust-lang.org/mir/index.html https://rustc-dev-guide.rust-lang.org/mir/index.html and https://blog.rust-lang.org/2016/04/19/MIR.html https://blog.rust-lang.org/2016/04/19/MIR.html but both did not enlighten me regarding inlining. Could you ELI5 or point me to relevant documentation?
- nicoburns 4y agoI think inlining is function inlining, which is an optimisation that lots of compilers do. The change here is to move (some of) that earlier in the compilation process (in the "middle end" of the Rust compiler rather than in the LLVM backend), which can make things more efficient by reducing the total amount of work that needs to be done.
- weinzierl 4y agoThat makes sense, thanks!
- xavxav 4y agoFor inlining in general, I think the wikipedia article is good https://en.wikipedia.org/wiki/Inline_expansion https://en.wikipedia.org/wiki/Inline_expansion. The reason it's so important is that inlining synergises with other optimizations, its often run before or after other passes like constant propagation. Consider something like: fn add(x : usize, y : usize) -> usize { x + y } fn main() { add(5, 1) } Without inlining we can't easily optimize the code of `main`. However, if we inline `add` into main, constant propagation will then directly see `5 + 1` and optimize that into `6`.
- weinzierl 4y agoI understand, thank you!
- nabakin 4y agoIs there anything we can do to bring an order of magnitude of improvement to compilation time? I know incremental compilation is by crate, how about by file like C and C++ do?
- Rusky 4y agoIncremental compilation is already even more fine-grained than by file- it is based on rustc's internal query system. There is room to improve parallelization, though. Cargo will parallelize invocations of rustc (by crate) and rustc will parallelize backend code generation (functions in a crate are load balanced automatically) but the frontend is still not parallel.