4 ms·
Rustc normally spends way more time in LLVM than in the frontend. Rust parsing and type checking are very fast in comparison to LLVM's codegen. Here is a chart
by dtolnay 6y ago
Rustc normally spends way more time in LLVM than in the frontend. Rust parsing and type checking are very fast in comparison to LLVM's codegen.
Here is a chart from last September showing where the time goes in compiling a large Rust codebase (rustc itself):
https://gistpreview.github.io/?74d799739504232991c49607d5ce748a https://gistpreview.github.io/?74d799739504232991c49607d5ce7...
(Scroll down to the large horizontal bars once dependencies have been built.) (Sorry if GitHub is down at the moment; try later if it doesn't load.)
The blue part of each bar is time in the frontend, the purple part is time in LLVM. The largest bar (rustc) spans 105 seconds in LLVM out of 140 total, or 75% in LLVM. Many of the subcrates are even more dominated by LLVM time, for example look at rustc_metadata or rustc_traits where >95% of compile time is spent in LLVM.
- tick_tock_tick 6y agoRust is famous for throwing garbage IR at LLVM and hoping it cleans it all up. They've made a lot of progress but comparing the timing is very misleading when the work is intentionally offloaded to LLVM.
- int_19h 6y agoIsn't that kind of the point of having a relatively high-level backend - to avoid the need for every front-end to do the same tedious optimizations?
- nitwit005 6y agoYou do have to have some sort of balance. With a large enough input, any program will become slow.
- dtolnay 6y agoMy comment is in response to "super cool idea, but I don't think it's going to help Rust compile speeds". Even a compiler that emits garbage IR from the frontend would get 20x faster with a magic instant backend if 95% of time is currently spent in the backend. A magic instant backend is unrealistic, so Rust will need to move some of the current backend work to frontend work for things that can be done more efficiently on the frontend. But the fact remains that there is an opportunity for big improvement from a much faster backend.
- nerdponx 6y agoIt sounds like this is addressed in the post, no? LLVM IR doesn't always map cleanly to Rust representations, so a backend that supports a cleaner mapping should obviate the need for more frontend optimization. I'm basically a layperson when it comes to this topic, but that's my understanding of one of the potential benefits of a different backend.