this post was submitted on 26 Jan 2024
33 points (94.6% liked)

Rust

7232 readers
18 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 2 years ago
MODERATORS
top 7 comments
sorted by: hot top controversial new old
[–] Vorpal@programming.dev 37 points 2 years ago

I don't feel like rust compile times are that bad, but I'm coming from C++ where the compile times are similar or even worse. (With gcc at work a full debug build takes 40 minutes, with clang it is down to about 17.)

Rust isn't an interpreted or byte code compiled language, and as such it is hard to compete with that. But that is comparing apples and oranges really. Better to compare with other languages that compile to machine code. C and C++ comes to mind, though there are of course others that I have less experience with (Fortran, Ada, Haskell, Go, Zig, ...). Rust is on par with or faster than C++ but much slower than C for sure. Both rust and C++ have way more features than C, so this is to be expected. And of course it also depends on what you do in your code (template heavy C++ is much slower to compile than C-like C++, similarly in Rust it depends on what you use).

That said: should we still strive to optimise the build times? Yes, of course. But please put the situation into the proper perspective and don't compare to Python (there was a quote by a python developer in the article).

[–] Turun@feddit.de 12 points 2 years ago (1 children)

Wierd that mold was not mentioned. A significant amount of time is spent in linking. Mold is a new linker that is much faster than the default and a drop in replacement if it works.

[–] Nithanim@programming.dev 5 points 2 years ago

For my small hobby project compiling was absurdly slow. Switching to mold really cut down on waiting time.

[–] livingcoder@programming.dev 2 points 2 years ago (2 children)

Every so often rust-analyzer in VS Code doesn't use the latest code after a cargo update and the only way I've found to fix it is a cargo clean. This means that I have to wait 5 minutes for the next build, painful. Just because of one project update. I would LOVE a faster build.

Extra info: the updates come from my dependencies that utilize my private repositories via a git = "[path]". The rust-analyzer is pulling from a cache or older version for some reason and I don't know where it is or why.

[–] Vorpal@programming.dev 5 points 2 years ago (1 children)

Two tips that work for me:

  • After cargo add I have to sometimes run the "restart rust-analyzer" command from the vscode command pallette (exact wording may be off, I'm on my phone as of writing this comment). Much faster than cargo build.
  • Consider using sccache to speed up rebuilds. It helps a lot, though uses a bit of disk space. But disk space is cheap nowadays (as long as you aren't stuck with a laptop with soldered SSD, in which case you know what not to buy next time).
[–] livingcoder@programming.dev 1 points 2 years ago

Thanks for the suggestions. I appreciate it.

[–] Miaou@jlai.lu 1 points 2 years ago

Having 30min+ incremental compile times here (C++), I envy your situation ahah