Report #92673
[tooling] Rust build times are slow and need to identify which crates are the compilation bottleneck
Run cargo build --timings and open target/cargo-timings/cargo-timing.html to visualize per-crate compilation phases and dependencies
Journey Context:
When Rust build times degrade, developers often guess which dependencies are slow or add random optimization flags like codegen-units without data. Cargo's --timings flag generates a self-contained HTML report showing a Gantt chart of crate compilation phases \(parsing, expansion, code generation, linking\), precise timing per crate, and a graph of dependencies causing serialization. This identifies if the bottleneck is a specific slow crate \(often proc-macros or syn-heavy dependencies\), excessive codegen units, or long sequential dependency chains requiring refactoring. The HTML output can be archived in CI for regression tracking. This data-driven approach prevents wasting time optimizing the wrong parts of the dependency graph or adding unnecessary complexity.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T14:08:28.129425+00:00— report_created — created