Add actionable suggestions to timings output #10542
Labels
A-timings
Area: timings
C-feature-request
Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Problem
The timings argument stabilised in 1.60 is accompanied by documentation with some tips for addressing build times.
https://doc.rust-lang.org/nightly/cargo/reference/timings.html
Those Tips are:
I want to suggest we use cargo to make those tips into workspace-specific actionable suggestions thus empowering people with less experience to optimise their build times.
Proposed Solution
I think the following suggestions listed in the cargo reference doc are converted into actionable suggestions informed by the stats collected by cargo:
Split large crates into smaller pieces.
We can identify a large crate internal to the workspace by calculating the % of build times higher than some threshold.
You can add an actionable diagnostic to the html and json report like the following:
Look for a crate being built multiple times with different versions. Try to remove the older versions from the dependency graph.
Collect all packages built in the DAG into a
HashMap<Package, Vec<CrateVersion>>
, sort the HashMap by the length of the vector of versions and generate suggestions for top K packages along the linesLook for slow dependencies. Check if they have features that you may wish to consider disabling.
For the crates that are slowest to compile, list all the features used and suggest turning some of them off.
Additional tips not in the reference
Linking the executable takes a long time
If we identify that the step that links binary crates takes longer than some threshold time, we can suggest other linkers (arch-dependant)
Notes
I would be happy to create a prototype PR even if the feature is considered too big to land given the current maintainer time constraints.
The text was updated successfully, but these errors were encountered: