Skip to content

chore: spike simulated throttling for soft navigations - #29

Open
ChristopherPHolder wants to merge 2 commits into
mainfrom
spike/simulated-throttling
Open

ChristopherPHolder wants to merge 2 commits into
mainfrom
spike/simulated-throttling

Conversation

@ChristopherPHolder

@ChristopherPHolder ChristopherPHolder commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #28. Background for #23.

What

A private workspace package, packages/simulated-throttling-spike, that prototypes the Lantern changes from docs/simulated-throttling.md and measures them against DevTools throttling. It doesn't change the published package, which keeps requiring devtools or provided. The README has the results and the method.

  • The changes (src/lantern/) replace Lantern functions at runtime, in the Lantern Lighthouse imports, so Lighthouse's own audits use them. Each one can be switched on its own:
    • root at the input of the soft navigation (1)
    • fetch chains from the v8::Debugger::AsyncTaskScheduled flows (3)
    • a paint graph (2)
    • warm connections and the HTTP/2 time to first byte (4)
    • two variants tried for comparison: keeping short tasks, and charging every request as a new connection
  • The fixture (src/app/server.mjs): 8 scenarios. Sequential and parallel fetches, an image as LCP, a long task, a lazily loaded chunk, an API on a cold origin, XHR, and HTTP/2.
  • The real sites (src/real-apps.mjs): react.dev, angular.dev, vite.dev and svelte.dev.
  • The measurement: record.mjs, evaluate.mjs and report.mjs, with the results committed in results/. Each soft navigation is recorded under simulate and under devtools, each in a fresh browser, 3 runs each.
  • The doc: docs/simulated-throttling.md gets a paragraph pointing to the spike.

Results

Median absolute error against DevTools throttling:

Configuration Fixture FCP Fixture LCP Sites FCP Sites LCP Sites within 20 %
Stock Lantern error error error error 0 %
Root only (1) 100 % 41 % 78 % 78 % 0 %
Root and chains (1, 3) 100 % 29 % 41 % 41 % 0 %
Root, chains and paint graph (1, 3, 2) 13 % 21 % 28 % 28 % 0 %
The same, with the HTTP/2 rule 13 % 17 % 26 % 26 % 17 %
Every change, warm connections included 13 % 17 % 44 % 44 % 0 %
  • Changes 1 to 3 hold and are needed together. Two things came up that the doc doesn't have:
    • linkCPUNodes prunes tasks under 10 ms before the new links could be added. A soft navigation's tasks are almost all that short, so the pruning has to run after the links.
    • The paint graph has to include every task that ran before the paint. On react.dev and vite.dev the soft navigation is mostly script work that isn't on the paint's path. Without that rule the sites' FCP is off by 96 %.
  • Change 4 makes it worse against DevTools throttling. DevTools throttling adds 562.5 ms to every request, warm connection or not, while Lantern charges a warm request one round trip. Lighthouse validates Lantern against DevTools throttling, so change 4 shouldn't be proposed as it stands.
  • 26–28 % on the sites isn't good enough to ship. Open points:
    • vite.dev is 44 % too fast in every run.
    • svelte.dev is 25 % too slow, and 54 % with the HTTP/2 rule. An earlier set of recordings swung between runs, probably because of prefetch timing.
    • Four sites isn't a dataset.
  • Measurement pitfalls, written up in the README:
    • browser contexts share connections
    • the HTTP cache carries over between measurements in one browser
    • a busy loop that waits on performance.now() isn't slowed down by CPU throttling

Verified

  • With every change installed, the simulate step's audits compute and report a Performance score. Their values match what evaluate.mjs computes for the same configuration, all 180 of them.
  • pnpm nx run-many -t lint test -p simulated-throttling-spike lighthouse-soft-navigation passes: 16 tests in the spike, 79 in the package.
  • pnpm nx format:check and pnpm nx affected -t lint test build typecheck pass.
  • The results come from recordings made on 2026-11-17, with record.mjs installing the all configuration explicitly. The HTTP/2 rule's fix in the second commit changes none of the 540 values on them.
  • The spike is private and isn't part of nx release or the e2e registry.

Related: #27 corrects change 3 in the doc. This PR only adds a paragraph to another section, so the two don't conflict.

A private workspace package that prototypes the Lantern changes from
docs/simulated-throttling.md and measures them against DevTools
throttling, on a fixture with 8 scenarios and on 4 public sites.

Changes 1 to 3 hold and are needed together, with two additions: the
pruning of short tasks has to wait for the new links, and the paint
graph has to include every task that ran before the paint. Warm
connections (change 4) make the result worse against DevTools
throttling.

Closes #28
…d results

- record.mjs installs the `all` configuration explicitly, which the README
  compares the step's audits with.
- evaluate.mjs and report.mjs reject configuration names they do not know.
- The root is the task at the input time, not the click task, which is
  usually pruned. Comments and README say so.
- The HTTP/2 rule turns multiplexing off for the whole simulation step, so
  overflow bytes of the previous request are not counted toward the next.
- The per-target tables count the runs that failed next to the median.

The recordings were lost with the worktree, so both sets are re-recorded
and the README numbers updated. The HTTP/2 fix changes none of the 540
values on these recordings.

This branch has not been deployed

No deployments
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.

Spike: simulated throttling for soft navigations

1 participant