A patch set called Headstart speeds up Rust compilation by letting crates that depend on a library start compiling before that library's compiler analysis is fully finished, according to the project's GitHub repository.
Normally, Cargo waits until a dependency's compiler analysis is completely done before starting work on anything that depends on it. Headstart's changes to rustc write an early metadata file once a dependency's type interface has been checked but before its function bodies are analyzed, and its changes to Cargo let a dependent crate start compiling against that early metadata, swapping in the full version before code generation, the repository says.
On a 16-core machine, the project reports clean builds across 13 real projects ran up to 54% faster for "cargo check" and up to 42% faster for "cargo build," with gains reaching 25% when combined with other parallel front-end flags. Smaller four-core machines saw gains of 13% to 24%, according to the repository.
The work ships as six patches against rustc, built around a new compiler query that splits analysis into item interfaces and function bodies, plus three patches against Cargo that request early metadata and reschedule paused compilation jobs, the repository says.
Compile times are one of the most common complaints among Rust developers, and a double-digit percentage off clean builds matters directly to any team running Rust in CI, without requiring a single line of their own code to change.