News for hackers. Stuff that matters.
Re:Why is my Rust build so slow? by brabel on Friday December 31, 2021 @04:31AM (#29746343)
> 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, it's mentioned in the beginning) was taking over a minute even on hot builds... To get a build to take this long in Java you would need to have several million LoC! Even if you don't use something like Gradle to cache compilation units and just compile everything from scratch with javac.

Re:Why is my Rust build so slow? by fasterthanlime on Friday December 31, 2021 @08:06AM (#29747635)
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.
Re:Why is my Rust build so slow? by yawaramin on Friday December 31, 2021 @11:59AM (#29749886)
You mean, by the time you split up the project into a bunch of tiny crates and mention:

> 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? by estebank on Friday December 31, 2021 @01:01PM (#29750617)
It's a tradeoff: if you make the file the language's compilation unit, then you can't have "circular imports" to allow end users divide their code in an ergonomic manner with fewer "arbitrary" restrictions. We can argue all year on whether Rust settled on the right side of that trade-off.
Re:Why is my Rust build so slow? by yawaramin on Friday December 31, 2021 @05:59PM (#29753405)
I'm just surprised that no one has (to my knowledge, anyway) tried this even experimentally. Wouldn't the potential build speed improvement be worth at least trying out the one-file-per-crate strategy?
Re:Why is my Rust build so slow? by Ygg2 on Friday December 31, 2021 @05:22AM (#29746588)
And I've worked on large Java projects.

Things that have like 420+ dependencies (spring boot + some other requirements). I timed the maven clean compile. And it takes around 2min.

Re:Why is my Rust build so slow? by brabel on Friday December 31, 2021 @10:26AM (#29748835)
Maven is very slow. Gradle and Bazel avoid doing wasteful things like Maven does so generally are a lot faster... if you want to know the speed of compiling Java you should just run `javac`, assuming Maven speed is Java compilation speed is far from correct even if a lot of projects still use Maven to build Java projects.
Re:Why is my Rust build so slow? by lenkite on Saturday January 01, 2022 @07:05PM (#29764245)
Use Maven Daemon. (https://github.com/apache/maven-mvnd) . With Maven Daemon, traditional maven builds get a spectacular boost factor that put them ahead of Gradle. (Haven't tried Bazel though)
Re:Why is my Rust build so slow? by dmitriid on Friday December 31, 2021 @04:41AM (#29746388)
> 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? by emn13 on Friday December 31, 2021 @11:59AM (#29749877)
Build times have regressed considerably the past few releases (at least for me). Not that I'm complaining about the tradeoffs, the new features are generally worth it. Whats most annoying is that it's often hard to tell which features are expensive until you've already wasted a bunch of time introducing em.

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? by yawaramin on Friday December 31, 2021 @12:03PM (#29749930)
Not surprising, considering the chief architect of C# is the guy famous for making Turbo Pascal.