The Rustdoc Redux

Right, that also confirms my observations. What happens with traditional web sites is:

  1. The web browser makes a request to HTTP/2 - Wikipedia
  2. The website does some processing and replies with an html page with the content
  3. Some minor needed content gets requested by the browser like images or css styles.

What happens right now with crates.io is:

  1. The browser makes a request to crates.io: Rust Package Registry
  2. The web server replies with an html page that contains a blank page and a <script tag for loading ember. I think its the same for all crates.
  3. The browser requests, parses and loads the ember javascript. I'm not very familiar with web development, but most probably stuff like that is already cached by the webserver. I think this step is pretty fast.
  4. Ember inside the browser does an XHR request to get a json file https://crates.io/api/v1/crates/winapi
  5. The server does some processing, and replies with the json file.
  6. Ember renders that content by traversing the json and modifying the DOM

With reloading with CTRL+R (having a warm cache), the process from 1 to 6 takes roughly 1 second until I get the "blue" line in my network tab (the DOMContentLoaded event of the page) on my desktop machine with Firefox 54. In comparison, loading the wikipedia page for HTTP/2 (which has far more content than the crates.io page!) through the traditional model takes roughly 0.48 seconds until the blue line. The blue line seems to be strongly correlated with when I see the page's content.

So there is clearly a difference here, and it might not be the direct fault of loading just the javascript (step 3), but instead I think its the combination of the steps above as each of them takes time. Also I have observed that the web server is slower (each network request takes hundreds of ms, while on wikipedia it takes roughly 10-20).

I don't know how this can be fixed. Maybe through ember fastboot, maybe through sending all the needed json inline inside a <script tag with the html page at step 2, maybe through sending it via HTTP/2 server push. But I don't think that this should be ignored, nor do I think that rustdoc should ship with that issue.

4 Likes