Rust lang compile slow very slow

I am a bit worried about the Rust lang compile speed. When golang and Java coders finish their job and go home.
Rust coder still waiting and test their not working Rust code.
How can we getting life easier?

Write half an hour code. Waiting compile for half an hour. no, no way .
and we have not enough good hardware. so can not depends on upgrade hardware to boost the compile speed.

1 Like

It's definitely an issue, and people are working hard to improve it. One of the biggest upcoming projects is the Cranelift backend which will provide faster builds in non-release mode. The developer blog has more news and information.

1 Like

I think this is a bit of an exaggeration and over-hyped by people who don't like the language or use it frequently. While not as fast as a compiler explicitly designed for fast compile times (Go) or a compiler which leaves most of the work to the JIT at runtime (Java), Rust's compiler isn't that bad for compilation times.

Whenever I develop in Rust I'll have cargo watch running on another terminal, continually recompiling and running my tests whenever I make changes. Because of incremental compilation and cargo check I'll often see type errors pop up within 3 or 4 seconds of hitting save.

I was even seeing this when hacking on the rust-analyzer codebase (I made the inline-function assist), which is about 170k lines of Rust!

As long as your CI uses caching properly, I've found I can get my pipeline times down to 5-10 minutes. That's usually good enough for my purposes because it gives me a chance to add extra information to the PR or start on the next issue and hit "merge' when GitLab's "your build has passed" notification pops up.


Note that the first build is usually slow, because it builds all the dependencies and populates cache. However, a second build should be much faster, because it reuses cached results from the first build.

If you have a big project that takes so long to build, you can also try to split into multiple crates. This way rebuilds will only need to touch crates that have changed.