Compiling Rust code is so sloooow.... I don't notice it that much on my M1 Pro Max which is still a somewhat decent machine, but on a bog standard VPS it takes about 10x longer and it's hurting the morale of my one man development team.

#rust #glacial

@chakie Yes, #Rust like C++ (#Cpp) needs beefy machines to build fast. But I wonder what's biggest bottleneck on your VPS, not drives by any chance? IOPS are often trimmed down on them.
@michalfita I don't know. It's pretty minimal VPS that I got aeons ago as my app backend does not need much. Once it's running it's snappy, but compiling is not fun.
@michalfita C++ compiles faster though. Not needed to compile that much though as I use Python and Rust nowadays for the backend stuff.
@chakie try `sccache`
@michalfita For Rust? When I deploy there’s usually a maximum of five changed files, the rest are unchanged. I don’t think a cache would help that much in this case?
@chakie Not for incremental builds, but for dependencies it can.
@chakie @michalfita both C and C++ also distribute easily across multiple threads and other machines to compile in parallel where rust often cant :/ (the c++20 modules feature also causes this problem with c++ as well though, though pretty much nobody uses that)
@raptor85 @chakie In the end most of the time is linking. As far as I'm aware Rust compiler is capable of multithreading for certain stuff, it's not single core pipeline, especially with multiple crates to compile first.
@michalfita @raptor85 In my simple case 97% of compilations have no new crates and no changed dependencies. A clean compilation takes 10-15 minutes for my 3600 line codebase with a bunch of dependencies.
@chakie @raptor85 15 minutes 😱 that VPS is *DAMN* slow.
@michalfita @raptor85 It’s what 10€ gets me at Digital Ocean. I should really move my stuff elsewhere to some European service.
@michalfita @chakie in theory, yes, but in practice most rust projects are structured in a way that can't be distributed or only in a limited fashion, so what you end up with is a massive early stage with dependencies and initial compilation, a decently fast middle, then a slow link at the end, it's not as bad as a single threaded compile or the mess that is Go but it's unfortunately FAR slower than C/C++ on an identical system (unless the c++ project uses modules of course)
@raptor85 @michalfita Could you elaborate on the Go part a bit? I'm definitely no fan of Go, but I've written a fair bit of it and the speed of the compilation/linking was never a problem.