Report #80169
[tooling] Rust compilation is slow and need to identify which crates are blocking the build
Run \`cargo build --timings\` and open the generated \`target/cargo-timings/cargo-timing-\[date\].html\`. Examine the waterfall chart: the X-axis shows wall time, Y-axis shows parallel crate compilation units. Wide horizontal bars indicate long-compiling crates \(often proc-macros like \`syn\` or heavy dependencies like \`tokio\`\). Look for 'gaps' in the timeline indicating CPU idle time due to serialization \(one crate blocking others\). Optimize by updating slow crates \(newer versions often optimize compile times\), splitting heavy proc-macros into separate crates, or enabling \`lto = "thin"\` only for release builds.
Journey Context:
Developers often use \`time cargo build\` which only shows total duration, not which specific crate caused the slowdown. The \`--timings\` flag generates an HTML report with a Gantt-like visualization showing exactly when each crate starts and finishes compilation. This was stabilized in Rust 1.60 but remains obscure because it requires opening an HTML file outside the terminal workflow. The key insight is that Rust compilation is a directed acyclic graph \(DAG\) of crate dependencies; \`--timings\` visualizes this DAG against time. Common mistakes include ignoring the 'unit' vs 'metadata' distinction \(metadata is for pipelining\), or not realizing that \`--timings\` works with \`cargo check\` and \`cargo test\` too. This is the canonical method for justifying workspace crate splitting or identifying which dependency upgrade added 30 seconds to CI.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T17:09:49.727861+00:00— report_created — created