Skip to content

Report 95th percentile load times and let players fetch assets from R2 - #90

Merged
Mistium merged 2 commits into
mainfrom
load-time-p95
Nov 30, 2026
Merged

Mistium merged 2 commits into
mainfrom
load-time-p95

Conversation

@Mistium

@Mistium Mistium commented Nov 30, 2026

Copy link
Copy Markdown
Member

Summary

  • Load times as a 95th percentile. GET /v1/admin/stats adds p95LoadMs and p95LoadMsByDay, and GET /v1/projects/:id/diagnostics adds p95LoadMs and loadSamples. Both share a new summarizeLoadTimes helper. The average fields stay for older clients. One load left in a background tab (clamped at 600 s) no longer swamps a day's figure. On Nov 30 a single such load pushed the daily average to 15.8 s while the median was 3.9 s.
  • Direct R2 asset loading. Project and remix responses carry assetsMirrorBase, the public R2 asset folder (empty when R2 isn't configured). The editor uses it to fetch assets from R2 directly, instead of sending every asset through this server for a 307. A cold load of a 461-asset project drops from 922 asset requests (461 of them to this server) to 461, none of them to this server.
  • Cacheable redirect. The /blobs/assets/:name redirect is now private, max-age=86400 instead of no-cache, so a browser that still goes through it doesn't ask again for a day. It's private, so a CDN can't keep a stale route.
  • Immutable R2 assets. New R2 uploads of assets/<md5>.<ext> set Cache-Control: public, max-age=31536000, immutable. Existing objects are unchanged.
  • Version: 2.1.0 → 2.2.0.

Editor companion: MistWarp/scratch-gui load-time-p95. Deploy this API before the editor, because the new admin chart reads p95LoadMsByDay.

Verification

  • Ran osl test (68 files), osl lsp check main.osl and scripts/check_conventions.py, all with the CI-pinned OSL commit.
  • A local server with 3,447 synthetic load samples returned matching average, p95 and per-day fields from both endpoints. With R2 configured it returned assetsMirrorBase: https://mwassets.mistium.com/assets and the new redirect header.
  • 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.

No visible surface in this repo. The editor PR has screenshots.

…2 directly

The admin stats and project diagnostics now include p95LoadMs (and
p95LoadMsByDay for admin stats) next to the existing averages, so one
load left in a background tab no longer swamps a day's figure.

Project responses carry assetsMirrorBase, the public R2 asset folder, so
players can skip the API redirect for every asset. The redirect itself
is now cacheable for a week, and new asset uploads to R2 are marked
immutable for a year.
Both endpoints now use summarizeLoadTimes, which has its own tests for
timed samples, per-day grouping and the 95th percentile. The R2 asset
redirect is cached privately for a day, so a CDN cannot keep sending
players to R2 if an asset's location changes.
@Mistium
Mistium merged commit 8fc2799 into main 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