Skip to content

Show 95th percentile load times and load player assets from R2 - #236

Merged
Mistium merged 3 commits into
developfrom
load-time-p95
Nov 30, 2026
Merged

Mistium merged 3 commits into
developfrom
load-time-p95

Conversation

@Mistium

@Mistium Mistium commented Nov 30, 2026

Copy link
Copy Markdown
Member

Summary

  • Load time chart. The admin chart, tile, daily table and CSV now show the 95th percentile instead of the average, and so does the project diagnostics card, which also shows how many loads were timed. A single load left in a background tab could push a day's average up by 10 seconds or more. The 95th percentile barely moves.
  • Background-tab loads. The embed no longer reports a load duration if the tab was hidden at any point while loading. Those samples measure how long someone left a tab in the background, not how long loading took.
  • Repeat visits skip the network for assets. Assets are named by their content, so a cached copy is now used without asking the server whether it changed. Before, every visit after the 5-minute cache window sent an API request, a 307 and a 304 for each asset.
  • Cold loads skip the API redirect. When the API offers an asset mirror (assetsMirrorBase, from Report 95th percentile load times and let players fetch assets from R2 api#90), players fetch assets from R2 directly. They fall back to the API for any asset R2 doesn't have yet. This covers the project page bridge, ?mw= public embeds and the editor.
  • Fetch bridge. It now checks origin and folder path instead of a string prefix, only treats md5-named files as immutable, and answers a refused URL at once instead of letting the player wait for its 60-second timeout.
  • Version: 3.16.2 → 3.17.0.

Deploy MistWarp/api#90 first. This chart reads p95LoadMsByDay, and the mirror only switches on once the API sends assetsMirrorBase.

Measurements

The Super Mario Bros. project (461 assets, 16 MB), loaded headless from this box:

Case Before After
Repeat visit after the 5-minute cache window 3.2 s, 922 asset requests 1.4 s, 0 asset requests
Cold load, asset requests (461 assets) 922, of which 461 went to the API 461, none to the API
Project page, time to last asset (Chromium / Firefox) 3.8 s / 4.8 s 3.2 s / 3.9 s

On a link throttled to 20 Mbps, cold loads are limited by download speed, so the mirror saves only about 0.3 s there. The biggest remaining cold-load cost is the player's 3.9 MB of JavaScript (one 10 MB shared chunk). That's a separate piece of work.

Screenshots

All four admin screenshots use the same 30 days of synthetic samples, served by a local API.

Before: the average chart is dominated by single slow loads.
Average load time chart

After: the 95th percentile chart in Chromium (dark theme).
95th percentile chart, dark

After: the same chart in Firefox (light theme).
95th percentile chart, light, Firefox

The load-time tile before and after.
Average load tile 95th percentile tile

Firefox: the project page player after loading all 461 assets from R2.
Project page in Firefox

No recording, since nothing here moves differently.

Verification

  • Ran lint, typecheck, conventions, both i18n checks, community CSS, deps:check, 4,283 unit tests, build:deploy and validate-deploy.
  • Checked in Chromium and Firefox: the project page, ?mw= and plain embeds with the mirror, a mirror that returns 404 for everything (falls back to the API), and no mirror. All loaded every asset.
  • Reviewed by Opus 5.5 over three rounds; the last round found nothing new. DeepSeek V4.1 Flash and GPT 6.2 Sol were skipped because both were over their usage limits.

Preview

Super Mario Bros. on the branch preview. Until MistWarp/api#90 is deployed, the preview talks to an API without the mirror, so assets still go through the redirect there.

The admin load time chart, tile, daily table and CSV, and the project
diagnostics card, now show the 95th percentile instead of the mean, so a
single load left in a background tab no longer swamps a day. Loads that
spent any time hidden no longer report a duration at all.

Assets are named by their content, so a cached copy is now used without
revalidating it. Repeat visits skip the network for every asset instead
of sending an API request, a redirect and a 304 per asset after five
minutes.

When the API offers an asset mirror, players fetch assets straight from
it and fall back to the API only for assets the mirror does not have
yet. That halves the requests for a cold load and takes them off the API
server.
Embeds opened with ?mw=<id> now carry the asset mirror too. The parent
page bridge compares origins and folder paths instead of string
prefixes, and only caches md5-named files as immutable. Detaching a
workspace also clears the mirror parameter, and the project diagnostics
card shows how many loads were timed.
A player asking the parent page for a URL it will not serve now gets an
empty reply straight away instead of waiting a minute for the bridge
timeout. Both the bridge and direct asset loads use one
isContentAddressedFile check to decide when a cached file never needs
revalidating.
@Mistium
Mistium merged commit 2ade624 into develop Nov 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant