Race Cache With Network

RCWN

Michal Novotny

Junior Hsu

Valentin Gosu

Chromium net-dev mailing list thread:

http://bit.ly/2kuk4uu

"This suggests that Firefox's cache is performing better than Chrome's on windows."

About 6.3% of all cached responses take more than 1 second (in Firefox)

How it started

Reasons

  • other applications doing IO
  • system updates
  • downloads
  • AV software
  • slow spinning disk
  • HDD failure?
  • cache architecture (too many files) ?
  • incorrect measuring

Solution: RCWN

  1. Start both the cache and network requests
  2. Use which response comes back first
  3. [maybe] cancel the other request

Why not always race?

  1. Wasting bandwidth unnecessarily
  2. More pressure on the servers
  3. May make other network requests slower
  4. We don't always prefer the first response

ex: large cached files, alt-data

Heuristic

If the request:
   - is not using appcache
   - is smaller than 256 kb
   - doesn't have alt-data
Then:

   - if the cache is slow: we race immediately

   - otherwise: set a timer for 3 * avgCacheTime

Can I use it yet?

Landed in Firefox 57

Turned on in Firefox 59

 

View stats at: about:networking#rcwn

Does it work?

72.08%

10.71%

3.61%

4.92%

0.23%

8.45%

RCWN network wins in ~4% of requests

We race ~17% of requests

Does it work well?

median: 145.34 ms

95th percentile: 7.08 seconds

0.8% requests: > 54 seconds !

Disclaimer

Results vary greatly with disk and network speed

What's next?

  • Show racing status in devtools panel
  • hacks.mozilla.org blog post
  • Improved heuristics
  • Look into cache performance
Made with Slides.com