Experiment with giving higher priority to proc-macros and their dependencies #8370
Labels
C-feature-request
Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Performance
Gotta go fast!
S-triage
Status: This issue is waiting on initial triage.
Currently, the dependency queue uses the number of transitive reverse dependencies to determine how to schedule jobs:
cargo/src/cargo/util/dependency_queue.rs
Lines 34 to 35 in 5847787
I think it would be a good idea to experiment with 'boosting' the priority of proc-macro crates and their dependencies. Unlike other crates, proc-macro crate building cannot be pipelined - since they are dynamically loaded into the compiler, any reverse-dependencies of proc-macro crates must wait for codegen, not just metadata.
By giving proc-macro crates a higher priority, we increase the likelihood that they will finish codegen by the time we are ready to start building their reverse dependencies. A similar argument applies to dependencies (not reverse-dependencies) of proc-macro crates: until rust-lang/rust#64191 is implemented, we still need to wait for all a proc-macro crates's dependencies to codegen before we can start building the proc-macro crate.
Anecdotally, I've noticed that some proc-macro dependencies (e.g.
syn
) seem to take a significant fraction of the total build time. By starting to build these crates earlier, we may be able to reduce the impact of their build times on the total build time.Concretely, I think we could add a flag
-Z prioritize-proc-macros
to Cargo. When enabled, we could either directly increase thepriority
entry by a certain factor, or just break ties in priority by proc-macro (or proc-macro-dependency) status.By using
-Z timings
, we can gather data on the impact of this change on build times.The text was updated successfully, but these errors were encountered: