Compile Faster: Rust Optimization Tips!



Rust is slow

Really?

Looking at 500+ crates when building a simple hello world webapp…



Visualization

知彼知己百战百胜《孙子兵法》- The art of war

Show cargo build timings

$ cargo build --timings

cargo-timings



cargo check instead of cargo build



Remove unused dependencies



Find duplicate dependencies



Replace heavy dependencies



Use workspaces - split into mulitple small crates



Use cargo-nextest for faster test execution



Combine all integration tests into a single binary



Use a faster linker



tl;dr

control your dependencies



References