Skip to content

Commit 2f84763

Browse files
committed
feat(2025H2): add "cargo build analysis" goal
1 parent 0d0f95d commit 2f84763

File tree

1 file changed

+127
-0
lines changed

1 file changed

+127
-0
lines changed

src/2025h2/cargo-build-analysis.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Prototype Cargo build analysis
2+
3+
| Metadata | |
4+
|:-----------------|----------------------------------------------------------------------------------|
5+
| Point of contact | @weihanglo |
6+
| Teams | <!-- TEAMS WITH ASKS --> |
7+
| Task owners | <!-- TASK OWNERS --> |
8+
| Status | Proposed |
9+
| Tracking issue | |
10+
| Zulip channel | N/A |
11+
12+
## Summary
13+
14+
Prototype support for build analysis in Cargo by recording build metadata across invocations.
15+
This will introduce unstable subcommands in `cargo report`
16+
to explain why crates were rebuilt and to surface timing data from past builds,
17+
helping developers diagnose and improve their build performance.
18+
19+
## Motivation
20+
21+
As Rust's popularity grows and projects increase in size and complexity,
22+
long build times have become a growing pain point for the community and industry alike.
23+
Understanding why builds behave the way they do and why they slow down over time
24+
is critical to improving the developer experience of Rust and Cargo.
25+
26+
### The status quo
27+
28+
Other than caching build artifacts and future-incompatibility reports,
29+
Cargo does not persist information about previous builds.
30+
While the [`--timings`] flag provides per-build data on how long each unit takes to compile,
31+
this information:
32+
33+
* You have to know you will care about a timings report and can't look it up afterwards
34+
* Exists primarily in HTML form, which is not suited for machine analysis
35+
36+
Additionally, Cargo does not track:
37+
38+
* Build cache effectiveness and rebuild reasons
39+
* Invocation metadata (e.g., CLI flags, profiles, environment variables)
40+
* System resources usage (e.g., memory and CPU)
41+
42+
This limits our ability to:
43+
44+
* Understand real-world build behavior over time
45+
* Explain why crates were rebuilt between builds
46+
* Experiment with performance optimizations, such as adaptive scheduling
47+
48+
[`--timings`]: https://doc.rust-lang.org/nightly/cargo/reference/timings.html
49+
50+
### The next 6 months
51+
52+
Cargo will provide an opt-in unstable configuration option to collect the following data:
53+
54+
* The existing metrics collected by the `--timings` flag
55+
* Rebuild reasons and related information
56+
* CLI arguments for each build
57+
58+
Each data record will be associated with a build identifier,
59+
such as `CARGO_RUN_ID`,
60+
to make it possible to link related data within the same Cargo invocation.
61+
62+
Two new unstable commands in `cargo report` will be introduced (command name TBD):
63+
64+
* `cargo report rebuild-reasons`:
65+
Show which crates were rebuilt for a specific Cargo run and why.
66+
* `cargo report timing`:
67+
Display timing data for a specific build, including per-crate compile times.
68+
69+
During the prototyping phase,
70+
the data may be stored as JSON blobs in a simple database format, such as SQLite.
71+
This approach allows schema evolution without committing to a stable format.
72+
73+
### The "shiny future" we are working towards
74+
75+
* Experiment with adaptive scheduling to reduce critical path length in builds
76+
* Extend `cargo report` with richer insights, such as:
77+
* Highlighting frequently rebuilt crates and their triggers
78+
* Summarizing build metrics and offering actionable suggestions
79+
* Enable external tooling to:
80+
* Analyze historical trends and identify performance bottlenecks
81+
* Provide live insights into slow build steps during development
82+
* Record additional build metrics to unlock more future capabilities and analysis,
83+
such as build replay for debugging and CI reproducibility
84+
85+
## Design axioms
86+
87+
* The changes to Cargo should not impede the development of Cargo
88+
* Metric collection must avoid introducing privacy or performance concerns
89+
* No user-facing stability guarantees during the prototyping phase
90+
* Data collection is opt-in and disabled by default
91+
92+
## Ownership and team asks
93+
94+
| Task | Owner(s) or team(s) | Notes |
95+
|-----------------------------------|------------------------------------|-------|
96+
| Discussion and moral support | ![Team][] [cargo] | |
97+
| Implementation | ![Help wanted][] @weihanglo | |
98+
| Standard reviews | ![Team][] [cargo] | |
99+
| Author call for testing blog post | @weihanglo | |
100+
101+
### Definitions
102+
103+
For definitions for terms used above, see the [About > Team Asks](https://rust-lang.github.io/rust-project-goals/about/team_asks.html) page.
104+
105+
* *Discussion and moral support* is the lowest level offering, basically committing the team to nothing but good vibes and general support for this endeavor.
106+
* *Author RFC* and *Implementation* means actually writing the code, document, whatever.
107+
* *Design meeting* means holding a synchronous meeting to review a proposal and provide feedback (no decision expected).
108+
* *RFC decisions* means reviewing an RFC and deciding whether to accept.
109+
* *Org decisions* means reaching a decision on an organizational or policy matter.
110+
* *Secondary review* of an RFC means that the team is "tangentially" involved in the RFC and should be expected to briefly review.
111+
* *Stabilizations* means reviewing a stabilization and report and deciding whether to stabilize.
112+
* *Standard reviews* refers to reviews for PRs against the repository; these PRs are not expected to be unduly large or complicated.
113+
* *Prioritized nominations* refers to prioritized lang-team response to nominated issues, with the expectation that there will be *some* response from the next weekly triage meeting.
114+
* *Dedicated review* means identifying an individual (or group of individuals) who will review the changes, as they're expected to require significant context.
115+
* Other kinds of decisions:
116+
* [Lang team experiments](https://lang-team.rust-lang.org/how_to/experiment.html) are used to add nightly features that do not yet have an RFC. They are limited to trusted contributors and are used to resolve design details such that an RFC can be written.
117+
* Compiler [Major Change Proposal (MCP)](https://forge.rust-lang.org/compiler/mcp.html) is used to propose a 'larger than average' change and get feedback from the compiler team.
118+
* Library [API Change Proposal (ACP)](https://std-dev-guide.rust-lang.org/development/feature-lifecycle.html) describes a change to the standard library.
119+
120+
## Frequently asked questions
121+
122+
### Is this telemetry?
123+
124+
No. This is not.
125+
Cargo follows the principles described in <http://esteban.kuber.com.ar/rustc-metrics.html>
126+
and does not send data anywhere.
127+
All metrics are stored locally and remain under the user's control.

0 commit comments

Comments
 (0)