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 9 commits into
Conversation
|
|
This comment has been minimized.
This comment has been minimized.
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. |
This comment has been minimized.
This comment has been minimized.
|
Oh, I see, you did the symlink from individual host doc subdirs to the target doc directory, interesting. If we did the symlinking same as it was done before (so symlink host doc -> shared and target doc -> shared), I wonder if the fingerprints files would collide? Because if we do it this way, then we don't have to figure out which subdirectories to symlink. |
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 symlinks the docs into place, and takes care of merging the CCI metadata so that local builds include macros in the list of items.
This was a feature I forgot about that generates crate-specific HTML, and thus needs merged. Like with docs, source pages are named after the crate they come from, so they can be merged by copying the directory.
…d some snapshot tests
9a72059 to
15604c7
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Ok, I pushed a refactoring that reduces some usage of implicit paths, and actually reads the generated output doc artifacts directly from Cargo, rather than having to provide them out of band or guess them from filesystem contents. While doing that, I noticed that Cargo also outputs the JSON files as artifacts, so I switched to using them, instead of reading the fingerprints. That might also make it a bit more resilient against changing the fingerprint file format. I also had to rebase on I'll now do a try build, both to test the docs build duration on CI, and to check the contents of the @bors try jobs=dist-x86_64-linux |
This comment has been minimized.
This comment has been minimized.
…try> bootstrap: Enable rustdoc mergeable CCI for std and internal docs try-job: dist-x86_64-linux
|
Docs build time still shorter by 20%, good. On slower hardware this will likely be an even bigger win. I manually checked the |
|
I'm happy with this and would r+ it, but since I pushed non-trivial code to it, I'd let @jieyouxu take a look (if you want). And also wait if notriddle has some feedback about my changes. |
| @@ -1624,35 +1572,24 @@ mod snapshot { | |||
| ctx | |||
| .config("dist") | |||
There was a problem hiding this comment.
Note: we no longer build all default doc steps when running dist rustc-docs 🎉
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