Earlier quoted context omitted.
The third axis in compiler development is safety. The compiler writer’s dilemma can be framed as: fast execution, safe execution, fast compilation — choose 2.
ADA. This is a false(ish) dilema. The problem of Rust is that is made with a C++ mindset. Is VERY hard to make compiler fast if it follow what C/C++ do (Go is the only evidence against!). Is a death by thousands cut. The syntax is the FIRST and big one. How you chose it will impact all the pipeline. Then the rest...
Why is my Rust build so slow?
161–170 of 217 posts
Re: Why is my Rust build so slow?
#162Earlier quoted context omitted.
> they definitely never felt too long, compared to say Java. Woah... now I am the one who have to ask: what the hell are you on about?? I work on Rust and Java projects, if you exclude running tests, Java compiles very very fast compared to pretty much any language... Rust is a lot slower to compile even on the much smaller projects I've worked on... in this post, a very small project (I think it's like 16,000 LoC, i…
> Java compiles very very fast compared to pretty much any language In my experience C# compiles faster, but I still agree with you on all points.
But I've got to say I'm super jealous of the level of introspection the rust compiler allows here. I'd definitely be willing to change a few C# coding patterns in code bases I maintain to benefit build times, but as is, that's a really painful trial and error process. And sometimes you get lucky finding the root cause, but if you don't... well, it's not a great experience.
Re: Why is my Rust build so slow?
#163Earlier quoted context omitted.
Rust seems to have inherited two favorite C++ development process features: long compilation times and incomprehensible error messages that aren't really related to the actual issue (e.g. just how C++ barfed out a bunch of template errors, borrow checker really loves to barf out very obscure error messages when there's an issue with lifetimes).
I teach C++ and Rust to college students, and their number one praise of Rust over C++ is how much more helpful the error messages are. It’s really night and day, so I can’t even fathom how you would equate the two.
Re: Why is my Rust build so slow?
#164Earlier quoted context omitted.
> they definitely never felt too long, compared to say Java. Woah... now I am the one who have to ask: what the hell are you on about?? I work on Rust and Java projects, if you exclude running tests, Java compiles very very fast compared to pretty much any language... Rust is a lot slower to compile even on the much smaller projects I've worked on... in this post, a very small project (I think it's like 16,000 LoC, i…
Seems like you really need to finish reading the article: hot builds take 3s by the time I find the regression that caused pathological compile times.
> I don't love how the dependency graph looks
After adding this complexity to the project, yes, some of the crates are building in ~3s, if they are the only ones that needed to be rebuilt.
Meanwhile, in a Java project there is none of this artificial crate splitting. Sure, Java projects have other nonsense, but they don't force you to split up projects into tiny pieces to get decent compile times.
Re: Why is my Rust build so slow?
#165Earlier quoted context omitted.
> they definitely never felt too long, compared to say Java. Woah... now I am the one who have to ask: what the hell are you on about?? I work on Rust and Java projects, if you exclude running tests, Java compiles very very fast compared to pretty much any language... Rust is a lot slower to compile even on the much smaller projects I've worked on... in this post, a very small project (I think it's like 16,000 LoC, i…
> Java compiles very very fast compared to pretty much any language In my experience C# compiles faster, but I still agree with you on all points.
Re: Why is my Rust build so slow?
#166Earlier quoted context omitted.
That's a pretty bad incentive though and you end up with very large dependency trees similar to JS. And we know how that went. OTOH there might be a benefit too as more code becomes re-usable in independent crates.
> That's a pretty bad incentive though and you end up with very large dependency trees similar to JS. And we know how that went. That's... not the same thing at all. Rust lets you have multiple crate in a single workspace, which allows parallelising the build (because crates are the concurrency unit of building rust). That's got nothing whatsoever to do with pulling random crates, which is a separate issue.
Re: Why is my Rust build so slow?
#167Earlier quoted context omitted.
What was your heuristic for deciding if a crate is too big or not?
Going by feel, same as when I have a giant function I decide to split up. IIRC the crates ended up between 1k-10k LOC
Re: Why is my Rust build so slow?
#168Earlier quoted context omitted.
Including me! There’s a lot of daylight between “an old dual core laptop” and a last gen thread ripper. For example, I’m running on a quad core i7 from 2015.
My old dual core laptop from 2009 works just fine with Visual Studio 2022, even though I wasn't the OP. And long compile times kill the battery on the go, and cargo check hardly helps when writing GUI code.
Re: Why is my Rust build so slow?
#169This much complexity and the tribal knowledge required to bypass it, so early in the the life of a programming language, is a really bad sign. It means the complexity of the problem space is not solved by the language, and the responsibility of solving it is being passed on to the users. You might react to this by saying that slow build times are not a big deal. That's a mistake -- iteration is key to productivity an…
This is more of a step-by-step deep-dive into the ways to profile, diagnose and work through the timing and performance problems. Anyone who doesn't know about many of these tools will probably find them useful (or at least useful to know that they exist) in the future. Besides, for iteration people are probably in debug, not release mode, which the article mentions is initially 19s vs 2m+. As far as I can see the ma…
I'd argue that when it comes to doing work, I only want to deep-dive into my code. Not third party libraries that "vow" to have been tested + performant, let alone the language/build tools themselves.
Re: Why is my Rust build so slow?
#170Earlier quoted context omitted.
> That's a pretty bad incentive though and you end up with very large dependency trees similar to JS. And we know how that went. That's... not the same thing at all. Rust lets you have multiple crate in a single workspace, which allows parallelising the build (because crates are the concurrency unit of building rust). That's got nothing whatsoever to do with pulling random crates, which is a separate issue.
Why doesn't Rust default to one crate per source file then? Wouldn't that make the build massively parallelized :-)