Skip to content

Minification makes JS parsing slower #57754

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
GuillaumeGomez opened this issue Jan 19, 2019 · 3 comments · Fixed by #57884
Closed

Minification makes JS parsing slower #57754

GuillaumeGomez opened this issue Jan 19, 2019 · 3 comments · Fixed by #57884
Assignees
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@GuillaumeGomez
Copy link
Member

This bug has been spotted by @est31:

Rustdoc search-index.js regression

There seems to be a regression in how quickly rustdoc pages load.

Just do the following with Firefox 64.0:

  1. visit https://doc.rust-lang.org/1.32.0/core/convert/trait.TryFrom.html
  2. open network tab in developer console
  3. reload the page with cold caches (ctrl+shift+R)
  4. At the bottom there is a number load: XXX in pink

Now do the same procedure for the nightly docs https://doc.rust-lang.org/1.32.0/core/convert/trait.TryFrom.html

What I see is a difference in the pink load time. For nightly, it's 466 ms and for stable, it's 1.6 seconds.

Now let's dig a little bit deeper. There is a "performance analysis" tab in the Firefox developer tools.
Here you can see what the browser is doing to load a page.

If you visit the nightly page, there is a clear yellow bar with 597 ms wait time for me. If you click this bar you can see that it's spending in search-index.js. If you visit the stable page, you have to search a bit for the yellow bar of search-index.js but if you find it, it's much much smaller. Only 52 ms!

So I'd claim that the regression in load time is due to a parsing time regression for search-index.js.

I can experience the bug on a personal project that uses nightly as well, and here it's far more grave (multiple seconds to wait), most probably because it's a bigger project.

I experience this bug only since a few days, thus I believe this to be a regression of this PR: #56869

One idea I had is to use an array instead of creating a lot of variables. It'll certainly take a bit more space but I think it'll allow to remove the parsing performance issue.

@GuillaumeGomez GuillaumeGomez added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jan 19, 2019
@GuillaumeGomez GuillaumeGomez self-assigned this Jan 19, 2019
@SimonSapin
Copy link
Contributor

Can the loading of this large data be delayed until search is actually used? Could it be JSON loaded over XHR instead of a script?

@jethrogb
Copy link
Contributor

jethrogb commented Feb 5, 2019

Related: https://internals.rust-lang.org/t/something-wrong-with-local-cargo-doc-documents/9282 . If your search-index.js gets big enough, it can take several seconds to load during which the entire page hangs. I think this should be a high-priority issue.

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Feb 7, 2019
…y, r=QuietMisdreavus

Update minifier version

Should fix rust-lang#57754 (at least it's a bit faster on my computer).

The whole point of this update is to create a huge array instead of creating a lot of variables.

r? @QuietMisdreavus
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants