Skip to content
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

search-index.js slows down documentation browsing #56545

Closed
yacoob opened this issue Dec 5, 2018 · 8 comments
Closed

search-index.js slows down documentation browsing #56545

yacoob opened this issue Dec 5, 2018 · 8 comments
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@yacoob
Copy link

yacoob commented Dec 5, 2018

I'm just starting with Rust, so I'm using its documentation quite often. Primarily along the lines of "hmm, no idea if a thing like foo exists in stdlib... let's search the docs.". This means, I'm changing pages of documentation a lot. I've noticed that when I'm jumping to a specific method's docs, I get the following experience:

  • page loads entirely (judging by the side scrollbar)
  • load indicator keeps spinning
  • after couple of seconds, browser jumps down to method description

I've looked at Chrome's console, and I've noticed that search-index.js is the culprit.

screen shot 2018-12-05 at 19 34 08

Note that the above is loading from a file:// URI, after launching rustup doc. That index is 2MB, and it looks like it contains all keywords for the search. Not sure why it's equally slow on both online and local docs.

Any chance of improvement here, to speed up the initial load? Loading the index asynchronously, to have it ready for user search once user decides to use it?

@GuillaumeGomez
Copy link
Member

Funny enough: chrome is very slow to render Rust documentation (give a try to firefox if you want it to be faster). However, some PRs should greatly improve this situation (like #56005). Before then, we can't help you much on this...

@yacoob
Copy link
Author

yacoob commented Dec 10, 2018

No worries, I'm happy to wait. Let's see how much better will it get once the improvements are in. I'll leave this one open for the time being so other people who wonder about this have a reference point.

Thanks!

@jonas-schievink jonas-schievink added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jan 27, 2019
@tyehle
Copy link

tyehle commented Apr 11, 2020

This is a pretty serious issue for me. I've been trying to browse the documentation for the atsamd-rs crate and the search-index.js file is so large it has been crashing chrome and firefox. The only way to get the page to load reliably is by disabling js. Even when the page works "properly" it takes around 6 seconds to load, and when I checked the performance logs most of that time is spent compiling and executing search-index.js which makes some sense because it is ~2MB. Is there some way to reduce the size of this file? It seems like it is super large because its including information about all the dependent crates.

@GuillaumeGomez
Copy link
Member

I had the same issue when opening the page... Any idea to reduce the size of this file is very welcome. I opened #71144 recently but not sure we'll go forward with it considering it'd reduce the search usefulness. An idea I had was to rely on wasm. I need to investigate it too.

@ollie27
Copy link
Member

ollie27 commented Apr 16, 2020

It might help to convert search-index.js into a plain JSON file. I'm pretty sure that JSON.parse is significantly faster than trying to compile and execute JavaScript code.

@GuillaumeGomez
Copy link
Member

I think it's worth a try. I'll test it tomorrow.

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Apr 20, 2020
…js, r=kinnison

Replace big JS dict with JSON parsing

Part of rust-lang#56545.

@ollie27 suggested that using JSON instead of a JS dict might be faster, so I decided to test it. And the results far exceeded whatever expectations I had...

I used https://github.com/adamgreig/stm32ral for my tests. If you want to build it locally:

```bash
$ cargo doc --features doc --open
```

But I strongly recommend to do it with this PR. Some numbers:

 * Loading a page with the JSON search-index: less than 1 second
 * Loading a page with the JS search-index: crashed after 30 seconds

I think the results are clear enough...

r? @ollie27

cc @rust-lang/rustdoc
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Apr 20, 2020
…js, r=kinnison

Replace big JS dict with JSON parsing

Part of rust-lang#56545.

@ollie27 suggested that using JSON instead of a JS dict might be faster, so I decided to test it. And the results far exceeded whatever expectations I had...

I used https://github.com/adamgreig/stm32ral for my tests. If you want to build it locally:

```bash
$ cargo doc --features doc --open
```

But I strongly recommend to do it with this PR. Some numbers:

 * Loading a page with the JSON search-index: less than 1 second
 * Loading a page with the JS search-index: crashed after 30 seconds

I think the results are clear enough...

r? @ollie27

cc @rust-lang/rustdoc
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Apr 20, 2020
…js, r=kinnison

Replace big JS dict with JSON parsing

Part of rust-lang#56545.

@ollie27 suggested that using JSON instead of a JS dict might be faster, so I decided to test it. And the results far exceeded whatever expectations I had...

I used https://github.com/adamgreig/stm32ral for my tests. If you want to build it locally:

```bash
$ cargo doc --features doc --open
```

But I strongly recommend to do it with this PR. Some numbers:

 * Loading a page with the JSON search-index: less than 1 second
 * Loading a page with the JS search-index: crashed after 30 seconds

I think the results are clear enough...

r? @ollie27

cc @rust-lang/rustdoc
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Apr 20, 2020
…js, r=kinnison

Replace big JS dict with JSON parsing

Part of rust-lang#56545.

@ollie27 suggested that using JSON instead of a JS dict might be faster, so I decided to test it. And the results far exceeded whatever expectations I had...

I used https://github.com/adamgreig/stm32ral for my tests. If you want to build it locally:

```bash
$ cargo doc --features doc --open
```

But I strongly recommend to do it with this PR. Some numbers:

 * Loading a page with the JSON search-index: less than 1 second
 * Loading a page with the JS search-index: crashed after 30 seconds

I think the results are clear enough...

r? @ollie27

cc @rust-lang/rustdoc
@euclio
Copy link
Contributor

euclio commented Jul 3, 2020

@GuillaumeGomez Sounds like this can be closed with the switch to JSON?

@GuillaumeGomez
Copy link
Member

Absolutely!

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

No branches or pull requests

6 participants