Fast Rust Builds: Secrets to Sub-10 Minute CI

2025-06-20

It's a common complaint that Rust compiles slowly, but the author argues that most Rust projects compile far slower than they should. Using rust-analyzer (200k lines of code plus a million lines of dependencies) as an example, they achieve an 8-minute CI pipeline on GitHub Actions. The article details strategies for optimizing build times, including leveraging CI caching, splitting CI tasks, disabling incremental compilation and debug info, reducing dependencies, utilizing `cargo build -Z timings` for profiling, and carefully architecting code to avoid excessive generic instantiation across crate boundaries. The author stresses the impact of build time on developer productivity and recommends regularly optimizing build times to keep CI times for large Rust projects within a reasonable range, e.g., around 10 minutes.

Development Build Optimization