Files
ytplayer/plans/phase6-investigation.md

3.1 KiB

Phase 6 investigation

All comparisons use the current instrumented harness with matching frontend and server from detached worktrees beneath perf/.tmp. No production requests. Command template (three fresh contexts):

node perf/baseline.mjs --runs 3 --browser webkit --profile lte --scenario cold --source-root perf/.tmp/phase6-<variant> --out perf/results/phase6-<variant>.json
Source Commit LTE FCP median ms Wire bytes app.js positive responses/sample
Phase 2 4950d3e 1044 1191063 2
Immediately before lazy layouts d98d444 1032 1191686 2
First lazy-layout cut 5d6a154 1615 1106796 2
Phase 3 tip cd4a25a 1646 1108191 2
Phase 5 tip (same product as Phase 4) 21c1273 1736 1097007 2
Phase 5 + worker force-cache scratch 1745 1097006 2
Phase 5 + parser-owned classic CSS scratch 898 1097051 2
Phase 5 + classic preload scratch 909 1097032 2

The adjacent-commit measurements isolate 5d6a154, not the Phase 4 extraction. All three FCP samples, complete proxy waterfalls, and page Resource Timing are stored in each result. The first sample often includes startup compression cost; it is retained in every median, not discarded.

Phase 3 sample 2: common styles finish around 880 ms. The parser-written classic stylesheet is discovered at 416 ms but reaches the proxy only at 1434 ms and finishes at 1607 ms. FCP is 1646 ms. Phase 5 sample 2: classic reaches the proxy at 1540 ms, finishes at 1711 ms, FCP is 1736 ms. Speculatively discovered body scripts already occupy the request queue when the selected stylesheet arrives. Phase 2 discovers its declarative styles together around 231 ms, FCP 1044 ms.

The first service-worker request is at 2458 ms in Phase 3 and 2337 ms in Phase 5, AFTER paint. Worker install competition does not explain this FCP regression. Font preload URLs match the font CSS; late layout CSS is the final rendering barrier. Making classic CSS declarative again removes the delay without changing CSS bytes or cascade order. This scratch variant unconditionally applies classic and is diagnostic only; the shipping fix must retain selected-layout behavior.

The modern synchronizer already uses default fetch caching. Changing it to force-cache has no effect: every WebKit sample still transfers app.js twice. The page and worker cannot reuse these HTTP-cache responses in this harness. A same-build page handoff can reuse the page HTTP cache instead. Worker validation must check both the X-Asset-Hash header and SHA-256 of the decoded bytes. It must strip compressed transport headers before constructing the cached Response. Updates and legacy migration must continue through their existing worker path.

The shipping CSS fix is a preload, not an unconditional stylesheet. Its three-run FCP is 909 ms; the first classic request reaches the proxy at 250 ms and completes at 423 ms. Lazy still applies only the saved layout, in the original cascade order. Other selected layouts may speculatively download the small classic stylesheet; it never applies or blocks their rendering. No inline script or CSP change.