Headstart patches cut Rust build/check times by up to 54%
Headstart patches let rustc emit early metadata, speeding up cargo check by up to 54% and cargo build by up to 42% with no regressions.
Headstart is an experimental set of rustc and cargo patches that lets dependent crates start compiling before their dependencies finish checking function bodies. rustc now writes an early .rmeta file right after a crate's interface is checked, and cargo starts downstream crates against that early metadata instead of waiting for full analysis to complete. For cargo check, dependents can run to completion on early metadata alone; for cargo build, they do their analysis early but pause before codegen until full metadata is ready, releasing their job slot in the meantime.
If a body has an error, builds still fail with the same diagnostics and exit status as today — only progress output and cross-crate JSON message ordering can differ. The tradeoffs are some wasted downstream work, slightly delayed error reporting, and higher peak memory use.
Across 13 real-world projects (rust-analyzer, zed, bevy, lemmy, polars, and others) on 16-core machines, Headstart speeds up clean cargo check by up to 54% and cargo build by up to 42%, with no regressions observed. Combined with the parallel front end (-Zthreads=8) it adds up to another 25%. Gains shrink on smaller machines — on 4 cores, rust-analyzer's check is 24% faster and its build 13-15% faster — since the speedup comes from cores that would otherwise sit idle.
The work is structured as a commit series intended for eventual upstream PRs to rustc and cargo, backed by correctness scripts (error-handling, incremental edits, metadata swapping, a 53-benchmark rustc-perf sweep) and a full benchmarking suite for reproducing the measured results.
This synthesis was produced from its source by AI; there is no human editor or manual review step. How we work