Rust compilation is impossible to solve for some reason.<p>I have a 4k line project that depends on serde-json, xxhash, crossbeam and rand.<p>It takes several seconds to compile in release mode.<p>This is insane compared to my 20k line project in C++ which compiles everything and runs all tests in 0.7 seconds.<p>The C++ project doesn't depend on libc or any external libraries but that is not a practical option in rust.<p>I tried bunch of different options and actually removed some dependencies but it seems like it is not possible to get the rust program to compile fast.<p>Does anyone know why it is this slow comparatively?
serde, crossbeam, and rand all involve generics so you may be getting a decent amount more code than 4k lines after macro expansion (aka #[derive(Serialize, Hash)) and generic instantiation.<p>you might also be able to drop crossbeam for stdlib types and rand for much smaller random library if you don't need it's comprehensive features.<p>cargo's release profile also uses opt level 3 and thin-local lto by default. Whether you need those is up to you, hard to say more without knowing your project!<p>but yes it is somewhat easy to allow rust projects to creep up in compile times especially with how easy it is to bring in big useful libraries that often come with a lot of features. disabling features where possible is the go to if you have big dependencies.
Nit: "et cetera" is two words.<p>It is a latin phrase that literally translates to "and the rest." "Et" means "and," and "cetera" means "the rest."<p>This is a great article! Apologies for being pedantic. I'm just noting this fun fact here in case the author is checking this thread.
It's interesting how much of the next gen compiler improves borrow heavily from logic programming. I don't know if any other compilers that have made the connection to logic programming as explicit as rustc.
There are compilers that use Z3 for type checking. I'd say that's even more explicit!
I mean any compiler that has a typeclass system basically does the same, since there is quits a deep connection between the two.<p>Of course any theorem prover will have an even deeper connection to logic in it's compiler and we've been building those since the 70s.
> I don't know if any other compilers that have made the connection to logic programming<p>Which other compilers do you know?
My C compiler rcc uses a handwritten solver in -O3 to solve contracts. I've tried z3 and others, but my own was way faster, no overhead. It's like MySQL vs sqlite in-proc.
C++ compilers when doing a mix of template and overload resolution?<p>Swift compilers when doing the same?<p>Haskell compilers when doing the same?<p>Idris, F*, Dafny, Koka,..... compilers doing the same?
type systems correspond to logics so this tends to be how it goes
If you name it constraint based programming, it all makes more sense.
The article is great but actually lacks data on overall performance. It looks like the big focus was handling pathological performance cases, which they have done a great job on. Overall though this looks like a mild performance regression (~6%) for the compiler based on an October test [0]<p>I like that Rust is principled about correctness, but as a mostly moved on long suffering C++ developer it’s disappointing the replacement suffers from the same poor compilation performance. At least rust has a culture of tracking and working on perf even if philosophically the community puts it low down their list.<p>0 - <a href="https://perf.rust-lang.org/compare.html?start=b5427502dab50cb27d9327d2893ddf2337dd4388&end=f1494a8d7038ea0295a71f4a3805766b8f0b561a&stat=instructions:u" rel="nofollow">https://perf.rust-lang.org/compare.html?start=b5427502dab50c...</a>
This is still work in progress, to be fair. Those results are already outdated, a number of optimizations landed since then. It'll probably take a bit more time to close the gap, but we expect the final result to be mostly similar to the old solver or faster. I'll also caveat that our benchmark suite is skewed towards pathological cases (when it comes to the type system code), so it doesn't necessarily indicate performance on average program.
Awesome work, seems an odyssey.<p>I think there is a little error in the code snippets near the caching section start where it claims variables are swapped but they are not? Though maybe I have just misunderstood something.
[dead]
Did it made it more faster or efficient?