2 ms·
It's not a big-O thing. The optimization passes aren't necessarily huge either; right now, 50% of the time is in LLVM compiling IR -> machine code. The static c
by steveklabnik 9y ago
It's not a big-O thing. The optimization passes aren't necessarily huge either; right now, 50% of the time is in LLVM compiling IR -> machine code. The static checks, optimization passes, and everything else are minuscule overall. You can see this with -Z time-passes.
We have some hunches, but nothing super conclusive yet; basically, right now it's all about how much IR we generate.
Don't forget the differences in compilation model; C/C++'s compilation units are much smaller, so incremental isn't as big of a deal.
- Shoop 9y agoIs there a way to generate IR which is easier on LLVM? The Jai compiler compiles 60kloc with an llvm backend in seconds. Could performance like this be seen in rustc?
- steveklabnik 9y agoPossibly; we'll see. MIR optimization passes may help. It's hard to say what exactly Jai does since it's not public yet.
- e12e 9y agoApparently that's : https://inductive.no/jai/ https://inductive.no/jai/
- civility 9y ago> Don't forget the differences in compilation model; C/C++'s compilation units are much smaller Not everyone compiles C++ the same way. I prefer header-only libraries and a single compilation unit. Counting lines of code with "gcc -E" to get the headers, I just compiled 20,000 lines of C++ from scratch in .6 seconds with gcc and .4 seconds with clang. I don't have a comparable project in Rust.
- pcwalton 9y agoHow much code did the preprocessor strip out?
- civility 9y agoNo idea, maybe a lot from the system headers. However, it was 20,000 lines of code that survived the preprocessor, 11,000 of which were inline or template from the project itself.
- comex 9y ago- A large fraction of compiler time is spent on code generation; how many of those lines did the compiler actually generate code for? (i.e. not unused functions or uninstantiated templates) (And in the case of uninstantiated templates, a C++ compiler doesn't even need to type check them…) - Did you have optimizations enabled?
- civility 9y ago> how many of those lines did the compiler actually generate code for? Not many. How many lines would a comparable Rust program have to instantiate? (should be the same) All I was trying to do was make an apples to apples comparison by discrediting the implication that the clang++ and g++ compilers are only faster because people use separate compilation units. I think it's fair to compare Rust and C++ this way, and if Rust is slower to compile, then it's fair to ask why. > Did you have optimizations enabled? Yes, -O3. Also -Wall -Wextra and -fwrapv if you're interested.