-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Greatly improve rustdoc rendering speed issues #56005
Conversation
I feel like this doesn't optimize the load time on my system (Chrome, Windows 7) enough to warrant displaying practically nothing while it loads. The total loss of information while it processes is way too much of a regression for not enough of a fix. I agree with @ollie27 that a better fix would be to render less information on the page to begin with, use less items that need processing, somehow make it so that the JS doesn't need to create all these elements, something like that. |
The problem is mostly on the DOM manipulation, not the JS execution. I can add a bit of text but I clearly prefer to wait 3 seconds rather than having a laggy page for 30 seconds. This also fixes the issue about the fact that the docs started while being expanded when it was expected that they were collapsed. |
c10321d
to
661ef14
Compare
@QuietMisdreavus Okay, I was able to make it a lot faster: Going from 13 seconds to 0.5 seconds for JS execution. I guess we're good now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While i don't see the dramatic speedup you're seeing (and my Firefox's dev tools won't cooperate to let me profile the code on the Iterator page), i can at least see some speedup. This is probably fine after these comments, but i'm going to try to summon more eyes on this to make sure we fully understand the ramifications here.
cc @rust-lang/rustdoc to get more eyes on this PR; the transformations here all look straightforward, but i'm not too familiar with JS so i'd like to get another review pass on it. I also want to ping @rust-lang/docs about what i think is the biggest problem with the PR. The idea is that by hiding everything to begin with, all the DOM changes we do to add fold-toggle elements won't trigger a bunch of repainting, speeding up the JS execution. However, this leads to the unfortunate consequence where generated docs require JavaScript to look at anything any more. Based on a totally informal and non-authoritative Twitter poll, at least some people browse the internet, including Rust docs, with JS turned off, so we will be leaving some people behind here. Whether we're okay with that, i'm not willing to call by myself. |
I'm pretty strongly of the opinion that we should support noscript browsers or users who run with JS disabled, unless and until someone demonstrates that there is no value to it. |
dc8d89a
to
d0236bd
Compare
The issue here is not that it doesn't have value. It certainly does. The issue is that if it has too much downside. We already make a number of choices, historically, that harm the average user, in order to support this use-case. The question isn't about value, it's about balancing the pros and cons of different approaches that have different values. |
a5387b7
to
9347839
Compare
After some discussion on Discord, we've added a couple new features to this:
This at least provides some notice to the user that the page is taking extra time to process. For the most part, this only shows up on pages with tons of content like Now that it has these changes, this PR looks good to me. Would like to see what the others (and travis) think before i r+ though. |
9347839
to
5d8da21
Compare
☔ The latest upstream changes (presumably #55707) made this pull request unmergeable. Please resolve the merge conflicts. |
5d8da21
to
bd9b981
Compare
Rebased. |
☔ The latest upstream changes (presumably #56549) made this pull request unmergeable. Please resolve the merge conflicts. |
bd9b981
to
d21e658
Compare
Rebased. |
☔ The latest upstream changes (presumably #56557) made this pull request unmergeable. Please resolve the merge conflicts. |
d21e658
to
b8c1726
Compare
@QuietMisdreavus travis is happy and we are getting new issues about this. Do you want to wait a bit longer or do you think it's ready to go? |
cc @rust-lang/rustdoc @rust-lang/docs to take another look. Does the new support of NoScript users and the new "loading" message make this PR mergeable? |
@@ -23,6 +23,9 @@ pub static RUSTDOC_CSS: &'static str = include_str!("static/rustdoc.css"); | |||
/// The file contents of `settings.css`, responsible for the items on the settings page. | |||
pub static SETTINGS_CSS: &'static str = include_str!("static/settings.css"); | |||
|
|||
/// The file contents of the `noscript.css` file, used in case JS isn't supported or is disabled. | |||
pub static NOSCRIPT_CSS: &'static str = include_str!("static/noscript.css"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just realized: New static file, need to update docs.rs when this is merged.
Given the rousing lack of comment, i'm going to go ahead and push this one out. @bors r+ |
📌 Commit b8c1726 has been approved by |
⌛ Testing commit b8c1726 with merge 56b30e2d526890835c7cbf4debeaf56355e28e8f... |
💔 Test failed - status-travis |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@bors retry |
…reavus Greatly improve rustdoc rendering speed issues Fixes #55900. So a few improvements here: * we're switching to `DOMTokenList` API when available providing a replacement if it isn't (should only happen on safari and IE I think...) * hide doc sections by default to allow the whole HTML generation to happen in the background to avoid triggering DOM redraw all the times (which killed the performances) r? @QuietMisdreavus
☀️ Test successful - status-appveyor, status-travis |
I haven't looked at this in detail yet, but I think that this PR made the experience of browsing e.g. the Compare:
On Chrome / macOS (with cache):
|
Currently, it'll be slow and the browser doesn't handle it well. but you can atleast scroll the page and read the docs you need while it loads, even jump to the method you want. At least on chrome After this change, you have to wait the full (slightly shorter) loading time to see anything at all, not really ideal. |
Fixes #55900.
So a few improvements here:
DOMTokenList
API when available providing a replacement if it isn't (should only happen on safari and IE I think...)r? @QuietMisdreavus