Commit a71d838
authored
feat(report): add cargo report rebuilds (#16456)
### What does this PR try to resolve?
This will improve <#2904>.
Part of <#15844>.
Adds a new command to analyze rebuild reasons from previous sessions.
The report includes:
* overview of rebuild/cached/new unit counts
* root rebuilds sorted by number of cascading rebuilds
* `-v` to show all root rebuilds (default showing 5)
* `-vv` to show affected unit lists (default collapsed)
This command doesn't have filtering by package or reason yet.
Can be added when we have use cases.
Example output:
```console
Session: 20251231T204416809Z-a5db680cc3bc96e4
Status: 3 units rebuilt, 0 cached, 0 new
Rebuild impact:
root rebuilds: 1 unit
cascading: 2 units
Root rebuilds:
0. [email protected] (check): file modified: common/src/lib.rs
impact: 2 dependent units rebuilt
[NOTE] pass `-vv` to show all affected rebuilt unit lists
```
```console
$ cargo report rebuilds --verbose`
Session: 20251231T204416809Z-a5db680cc3bc96e4
Status: 6 units rebuilt, 0 cached, 0 new
Rebuild impact:
root rebuilds: 6 units
cascading: 0 units
Root rebuilds:
0. [email protected] (check): declared features changed: [] -> ["feat"]
impact: no cascading rebuilds
1. [email protected] (check): file modified: pkg2/src/lib.rs
impact: no cascading rebuilds
2. [email protected] (check): target configuration changed
impact: no cascading rebuilds
3. [email protected] (check): environment variable changed (__CARGO_TEST_MY_FOO): <unset> -> 1
impact: no cascading rebuilds
4. [email protected] (check): file modified: pkg5/src/lib.rs
impact: no cascading rebuilds
5. [email protected] (check): file modified: pkg6/src/lib.rs
impact: no cascading rebuilds
```
### How to test and review this PR?
I found it awkward to logging fingerprint,
at least haven't found a reason way to implement that.
This came out first as a basic version of rebuild reporting.
### Open questions
* Should this show a tree view like `cargo tree`?
* Personally I think `cargo report builds` rignt how should have only a
basic version to show the usefulness of log messages, and we can expand
later if needed.
* Should we also show cached unit?
* Probably not. I aim to provide a command to answer the most frequently
asked question: What is the root cause of this rebuild. While some of
the info is not really useful and has no follow-up user action, we can
improve them later when dirty reason become more exposed to users.
### Screenshots
Built rustfix after `cargo update syn@2`
<img width="497" height="231" alt="image"
src="https://github.com/user-attachments/assets/50fc6291-0741-46be-8297-2b21d508d557"
/>
<img width="391" height="280" alt="image"
src="https://github.com/user-attachments/assets/03fa147d-b0c8-450f-8d57-4741ceefe6be"
/>20 files changed
Lines changed: 1287 additions & 122 deletions
File tree
- src
- bin/cargo/commands
- cargo
- core/compiler
- fingerprint
- job_queue
- timings
- ops
- cargo_report
- util
- tests/testsuite
- cargo_report_rebuilds
- cargo_report/help
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
47 | 52 | | |
48 | 53 | | |
49 | 54 | | |
| |||
75 | 80 | | |
76 | 81 | | |
77 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
78 | 96 | | |
79 | 97 | | |
80 | 98 | | |
| |||
112 | 130 | | |
113 | 131 | | |
114 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
678 | 678 | | |
679 | 679 | | |
680 | 680 | | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
681 | 691 | | |
682 | 692 | | |
683 | 693 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | | - | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
64 | | - | |
65 | | - | |
| 65 | + | |
| 66 | + | |
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| |||
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
| 77 | + | |
81 | 78 | | |
82 | 79 | | |
83 | 80 | | |
| |||
148 | 145 | | |
149 | 146 | | |
150 | 147 | | |
151 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
152 | 155 | | |
153 | 156 | | |
154 | 157 | | |
| |||
220 | 223 | | |
221 | 224 | | |
222 | 225 | | |
223 | | - | |
224 | | - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
225 | 232 | | |
226 | 233 | | |
227 | 234 | | |
| |||
301 | 308 | | |
302 | 309 | | |
303 | 310 | | |
304 | | - | |
| 311 | + | |
305 | 312 | | |
306 | 313 | | |
307 | | - | |
308 | 314 | | |
| 315 | + | |
309 | 316 | | |
310 | 317 | | |
311 | 318 | | |
312 | | - | |
| 319 | + | |
313 | 320 | | |
314 | 321 | | |
315 | | - | |
316 | | - | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
317 | 328 | | |
318 | 329 | | |
319 | 330 | | |
| |||
529 | 540 | | |
530 | 541 | | |
531 | 542 | | |
532 | | - | |
533 | | - | |
| 543 | + | |
| 544 | + | |
534 | 545 | | |
535 | 546 | | |
536 | 547 | | |
| |||
539 | 550 | | |
540 | 551 | | |
541 | 552 | | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
547 | | - | |
| 553 | + | |
548 | 554 | | |
549 | 555 | | |
550 | 556 | | |
551 | 557 | | |
552 | 558 | | |
553 | | - | |
554 | | - | |
555 | | - | |
556 | | - | |
| 559 | + | |
557 | 560 | | |
558 | 561 | | |
559 | 562 | | |
| |||
647 | 650 | | |
648 | 651 | | |
649 | 652 | | |
650 | | - | |
| 653 | + | |
651 | 654 | | |
652 | 655 | | |
653 | 656 | | |
| |||
659 | 662 | | |
660 | 663 | | |
661 | 664 | | |
662 | | - | |
| 665 | + | |
663 | 666 | | |
664 | 667 | | |
665 | 668 | | |
| |||
668 | 671 | | |
669 | 672 | | |
670 | 673 | | |
671 | | - | |
672 | | - | |
673 | | - | |
| 674 | + | |
674 | 675 | | |
675 | 676 | | |
676 | 677 | | |
677 | 678 | | |
678 | 679 | | |
679 | 680 | | |
680 | | - | |
| 681 | + | |
681 | 682 | | |
682 | 683 | | |
683 | 684 | | |
| |||
830 | 831 | | |
831 | 832 | | |
832 | 833 | | |
833 | | - | |
834 | | - | |
| 834 | + | |
| 835 | + | |
835 | 836 | | |
836 | 837 | | |
837 | 838 | | |
| |||
0 commit comments