Report #87363
[tooling] Identifying which crates are serializing a slow Rust build and extending compile times
Run \`cargo build --timings\` \(or \`--timings=html\` for a saved report\) to generate an HTML timeline showing per-crate compilation duration and the critical path. Analyze the graph to find 'long poles'—crates that block many downstream dependencies—and refactor by splitting crates or enabling parallel features.
Journey Context:
Rust developers often optimize builds by blindly adding \`-j\` jobs or switching to faster linkers like mold, without understanding the actual dependency graph bottlenecks. Cargo's \`--timings\` flag \(stabilized in Rust 1.60\) generates a detailed HTML report showing when each crate starts/finishes compiling and highlights the 'critical path'—the longest chain of dependencies that must compile sequentially. The insight is that simply adding CPU cores won't help if the crate graph is deep rather than wide. For example, a 'god crate' that everything depends on \(like a common utility module\) serializes the entire build. The fix involves splitting such crates into smaller units or using feature flags to reduce the dependency graph. This is particularly important for CI/CD where build time directly translates to cost, and for local development where iteration speed matters. The generated HTML is self-contained and can be archived as a build artifact for regression analysis.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T05:13:34.371463+00:00— report_created — created