Repository navigation
Make playground example switching instant - #3
Merged
Merged
Conversation
Each switch fetched the example over the network with the HTTP cache bypassed, and the first switch to a chart or diagram article downloaded its graphics library at click time, so a switch on the live site took about 1.2 seconds. Cache preset sources in memory, prefetch them and warm the graphics libraries on idle, and serve a switch synchronously from the cache once warmed.
Owner
Author
|
Live measured, deployed, milliseconds per switch:
A real switch (idle warmUp completes while the visitor reads) lands around 50 to 180ms, down from roughly 1.2 seconds. The cold "languages" outlier is the case where the visitor switches before the idle prefetch finishes and several charts render at once; still well under the old number. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #2. Switching the example dropdown on the live site took about 1.2 seconds; this brings a warmed switch down to roughly 150ms.
Cause
Two network costs paid at click time:
loadPresetfetched each.altwith{ cache: "no-cache" }, forcing a network round trip on every switch.Fix
requestIdleCallback), prefetch every preset source and warm the lazy graphics libraries, so the first switch to any example is instant too. The runtime imports the same specifiers, so the browser serves them from its module cache.Measured (live, before vs target)
Before, per switch on the deployed site: cybersecurity 1157ms, cs-lewis 1228ms, paradox-of-genius 1251ms, languages 1037ms. Warmed local (no network) is ~115 to 215ms; the live warmed numbers will be posted on this PR once deployed. No crate changes; playground-only.