Commit 1d3fb78
authored
feat: support for rustdoc mergeable cross-crate info (#16309)
### What does this PR try to resolve?
This is an unstable feature that we designed to fix several performance
problems with the old system:
1. You couldn't easily build crate docs in hermetic environments. This
doesn't matter for Cargo, but it was one of the original reasons to
implement the feature.
2. We have to build all the doc resources in their final form at every
step, instead of delaying slow parts (mostly the search index) until the
end and only doing them once.
3. It requires rustdoc to take a lock at the end. This reduces available
concurrency for generating docs.
Part of
* rust-lang/rust#130676
* #16306
### How to test and review this PR?
Design decisions and questions:
* [ ] Doc parts are always stored in the new build dir layout:
#16309 (comment)
* [ ] Doesn't take `cargo clean` into account yet:
#16309 (comment)
* [x] A new `FileFlavor::DocParts` is added:
#16309 (comment)
* [ ] One doc-merge per target platform (and run in serial)
#16309 (comment)
* A new status "Merging" is added. Example output:
```
Documenting ...
Documenting cargo v0.94.0 (/Users/frodo/cargo)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 29.68s
Merging 300 docs for host
Finished documentation merge in 2.74s
Generated /Users/frodo/cargo/target/doc/cargo/index.html
```
* Who should garbage collect unneeded crate docs under mergeable CCI
mode, rustdoc or cargo? (or don't, we shouldn't do any garbage
collection?)
#16309 (comment)
* `.rustdoc_fingerprint.json` now stores doc part file paths in previous
builds.
### Simple benchmark
* Tested against this PR on top of
15fde07
* rustdoc 1.93.0-nightly (1be6b13be 2025-11-26)
* macOS Sequoia 15.7.1
* Apple M1 Pro 2021
* 32GB RAM; 10 cores
* 300 crate doc merge
* Test steps:
```bash
cargo check
cargo doc
cargo clean --doc && rm -rf target/debug/build/**/deps/*.json
cargo doc -Zrustdoc-mergeable-info
cargo clean --doc && rm -rf target/debug/build/**/deps/*.json
```
**With `-Zrustdoc-mergeable-info`**:
* <40s: ~30s documenting time + 3-5s merge time
* 76262 files, 970.5MiB total
**Without `-Zrustdoc-mergeable-info`**:
* ~500s: 8m10s - 8m30s
* 75242 files, 932.8MiB totalFile tree
14 files changed
+1235
-45
lines changed- crates/cargo-test-support/src
- src
- cargo
- core
- compiler
- build_context
- build_runner
- fingerprint
- ops
- doc/src/reference
- tests/testsuite
- cargo/z_help
14 files changed
+1235
-45
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
| 341 | + | |
341 | 342 | | |
342 | 343 | | |
343 | 344 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
| 83 | + | |
82 | 84 | | |
83 | 85 | | |
84 | 86 | | |
| |||
Lines changed: 26 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
278 | 287 | | |
279 | 288 | | |
280 | 289 | | |
| |||
495 | 504 | | |
496 | 505 | | |
497 | 506 | | |
498 | | - | |
| 507 | + | |
499 | 508 | | |
500 | 509 | | |
501 | 510 | | |
502 | 511 | | |
503 | | - | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
504 | 528 | | |
505 | 529 | | |
506 | 530 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
26 | | - | |
27 | | - | |
| 26 | + | |
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
| |||
178 | 177 | | |
179 | 178 | | |
180 | 179 | | |
181 | | - | |
| 180 | + | |
182 | 181 | | |
183 | 182 | | |
184 | 183 | | |
| |||
225 | 224 | | |
226 | 225 | | |
227 | 226 | | |
| 227 | + | |
| 228 | + | |
228 | 229 | | |
229 | 230 | | |
230 | 231 | | |
| |||
330 | 331 | | |
331 | 332 | | |
332 | 333 | | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
333 | 386 | | |
334 | 387 | | |
335 | 388 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
106 | 107 | | |
107 | 108 | | |
108 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
109 | 115 | | |
110 | 116 | | |
111 | 117 | | |
| |||
143 | 149 | | |
144 | 150 | | |
145 | 151 | | |
| 152 | + | |
146 | 153 | | |
147 | 154 | | |
148 | 155 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
410 | 410 | | |
411 | 411 | | |
412 | 412 | | |
413 | | - | |
| 413 | + | |
414 | 414 | | |
415 | 415 | | |
416 | 416 | | |
| |||
0 commit comments