bootstrap: Enable rustdoc mergeable CCI for std and internal docs - #161716
bootstrap: Enable rustdoc mergeable CCI for std and internal docs#161716notriddle wants to merge 3 commits into
Conversation
This feature is unstable but will be stabilized soon, and this is a good way of dogfooding it to make sure it works properly. It should have no effect on the generated docs, but it provides a significant speedup. For example, I measure a 3x speedup locally (3m 11s -> 1m 1s) for `x doc src/tools` -- note that this is with the latest rustdoc perf improvements (PR 159854).
As discussed in the [old version of this PR][], we can build the original version of the docs in separate build directories, and then merge them by calling rustdoc directly. This way, the crates don't invalidate each other's build caches, and we don't have to mess with symlinks or copying things around. [old version of this PR]: rust-lang#160098 (comment)
|
|
This comment has been minimized.
This comment has been minimized.
21d745a to
5d40b2f
Compare
5d40b2f to
f8b95cc
Compare
There was a problem hiding this comment.
Note to myself and other bootstrap reviewers: bootstrap currently does a bunch of docs hacks. One of them is the (implicit) combination of rustc + various tools docs into a single directory. I wanted to refactor that by merging the files explicitly in a separate step. But since we also want to enable -Zrustdoc-mergeable-info, it seems wasteful to first do that refactoring and then enable the flag, which requires us to combine the files in a different way.
So this PR does two things:
- Create a separate step for building the compiler + tools shared documentation.
- Enable
-Zrustdoc-mergeable-infoto make documentation generation faster.
There are several cleanups that we should do on top of this, but for this PR, it is important to check whether it produces the same combined output as before. I will do that.
Would you mind if I did a few small refactorings and push them to this PR?
| // explicitly (https://github.com/rust-lang/cargo/issues/7677). | ||
| let proc_macro_out_dir = builder.stage_out(build_compiler, Mode::Rustc); | ||
| // Copy crate docs into place. | ||
| for krate in &*rustc_stage.crates { |
There was a problem hiding this comment.
Just so that I understand it correctly, there is no cargo or rustdoc command that would do this for us, right? And this is orthogonal to -Zrustdoc-mergeable-info?
|
Running the step failed for me locally with this: The copy happens at if proc_macro_doc_dir.exists() {
eprintln!("Copying {proc_macro_doc_dir:?} to {doc_out:?}");
builder.cp_link_r(&proc_macro_doc_dir, &doc_out);
}but it is quite suspicious, because the |
|
The rabbit hole goes deeper.. after these changes, just running So the combination happens even without joining compiler/tools docs, we still have to join target/host docs. That's quite annoying - is this a problem for all Rust crates that have proc macros?! If I understand it correctly, rustdoc can only merge the index page and the search index, but not the individual subdirectories with the actual docs. So the combining has to be done manually (is there really no way this can be done by cargo/rustdoc natively?), either by:
|
No problem. Go ahead.
Yes. Cargo itself doesn’t need rustdoc to take care of copying the docs, because Cargo still uses the same output directory for the HTML when documenting each crate. Since each crate puts its HTML in a separate subdirectory anyway, they’re already separate. Writing those HTML files to separate directories and then copying them into place at the end would be wasteful. |
If you delete your build dir and start over, does that problem go away? Or did I miss a spot? I thought I deleted all of the places where those symlinks were being created, but I didn’t write any code to clean up the existing structure if it was left over from a previous, older build. |
Takes a different approach to #160098, where the internal docs are merged by bootstrap directly invoking rustdoc. This requires bootstrap to gather the list of metadata directories by inspecting cargo's fingerprint files (which aren't stable). The first commit is written by @camelid, but I wrote the other two.
This feature is needed because:
cargo docwill just be faster.This rustdoc feature is unstable but will be stabilized soon, and this is a good way of dogfooding it to make sure it works properly. It should have no effect on the generated docs, but it provides a significant speedup. For example, I measure a 3x speedup locally (3m 11s -> 1m 1s) for
x doc src/tools-- note that this is with the latest rustdoc perf improvements (#159854).r? @Kobzol