Repository navigation
feat(perf-kit): Cloudflare Worker startup mode - #11188
Merged
Merged
Conversation
✅ Deploy Preview for rolldown-rs canceled.
|
IWANABETHATGUY
force-pushed
the
feat/metrics-lab-worker
branch
from
October 15, 2026 01:43
2e7e50c to
ae6c8fa
Compare
This was referenced Oct 15, 2026
IWANABETHATGUY
force-pushed
the
feat/metrics-lab-worker
branch
from
October 28, 2026 03:50
ae6c8fa to
bc83ba4
Compare
IWANABETHATGUY
force-pushed
the
feat/metrics-lab-worker
branch
from
October 28, 2026 13:17
ce98f23 to
5f941c1
Compare
IWANABETHATGUY
force-pushed
the
feat/metrics-lab-worker
branch
from
October 28, 2026 15:34
5f941c1 to
f62d239
Compare
IWANABETHATGUY
force-pushed
the
feat/metrics-lab-worker
branch
from
October 28, 2026 15:50
f62d239 to
d40cb93
Compare
IWANABETHATGUY
force-pushed
the
feat/metrics-lab-worker
branch
2 times, most recently
from
November 3, 2026 17:10
62407ee to
ad57d3d
Compare
IWANABETHATGUY
marked this pull request as ready for review
November 3, 2026 17:13
IWANABETHATGUY
requested review from
h-a-n-a,
hyfdev,
sapphi-red and
shulaoda
as code owners
November 3, 2026 17:13
shulaoda
approved these changes
Nov 4, 2026
Chrome keeps a socket open with no finished request, and `server.close()` alone waits for it until Node's requestTimeout (300 s). Each parity run on a React app took 5 to 10 minutes; `closeAllConnections()` after `close()` ends the wait at once (3.6 s for the same run).
Measure a Vite-built Worker's startup under the app's own workerd and attribute it to modules, with the loop the browser and node modes have. `worker-config` writes a Vite config that puts the rolldown metrics report on every environment (one directory each; an environment built without it in the same process writes a full log under `unknown-session`). `worker-scan` times the main module's import on fresh workerd instances minus an empty-import floor, hits the pinned requests on the real entry, profiles the import over the external inspector, and takes precise coverage from inside the isolate through a `node:inspector` session (wrangler >= 4.108.0, or `--tools <dir>` for that run). `worker-attrib` charges startup CPU to the evaluating module from a preserveModules build, because chunk top-level frames carry no line ticks and ESM evaluation is not a call stack. `why <module>` lists the importers and the chain. Shared changes the mode needed, used by every mode: profile attribution splits a frame's self-time by its line ticks and maps every chunk that has a sourcemap (checklist A4); the ownership split counts multi-chunk source rows as app code; `cut --root a,b` keeps class modules eager so the cut lands below a Durable Object class instead of at the entry. Shaped on cloudflare/agents-starter and cloudflare/vibesdk; the vibesdk pass is cloudflare/vibesdk#466 (startup 102.5 ms -> 63.3 ms on `wrangler check startup`).
Report mode writes one report per output folder, so the config shim no longer sets `reportDir` per environment. The Worker lookup reads `node_modules/.rolldown/report/dist/<worker>`, and the attribution build reads `node_modules/.rolldown/report/dist-attrib/<worker>`.
One prompt each for a browser page load, a node or deno server startup and a Cloudflare Worker startup: the target, the number that counts, the Tools paragraph, the rules and the report. The Tools paragraph is the only part that names perf-kit, so the same prompt without it is the control prompt of an A/B run. The README points at the page and the package ships it.
IWANABETHATGUY
force-pushed
the
feat/metrics-lab-worker
branch
from
November 4, 2026 02:15
ad57d3d to
12bc024
Compare
shulaoda
pushed a commit
to raminjafary/rolldown
that referenced
this pull request
Nov 4, 2026
…1214) `scan` now reports static chunks that started downloading more than one RTT after their static parent finished, separately before FCP and before LCP, so that an agent can find a late-discovered chunk before it moves a preload or a chunk boundary. The chunk graph comes from a new `chunk-graph.json` that devtools report mode writes from the output after `generateBundle` (a Vite manifest also works), and a keep/revert decision now checks both FCP and LCP against the pinned baseline. Design notes: "Chunk discovery" in `packages/perf-kit/README.md`. requires rolldown#11188
shulaoda
pushed a commit
to raminjafary/rolldown
that referenced
this pull request
Nov 4, 2026
…lds (rolldown#11215) The lab measures a local copy with a fixed throttle, so a lab gain can vanish in production and a production stall can stay invisible in the lab. This PR adds `field`, which measures deployed variants in the user's own logged-in Chrome, and `record` / `replay`, which give field-like numbers for a build that is not deployed yet. ```mermaid sequenceDiagram participant A as Agent participant L as Lab (harness.mjs / replay.mjs) participant C as User's Chrome (logged in) participant S as Deployed site participant R as Replay server (local HTTP/2) participant H as Headless Chrome (new context per load) Note over A,S: 1. record: once per network A->>L: record --config field.json --variant base L->>C: attach over CDP, load the page (6 timing runs + 1 body run) C->>S: real requests: real data, network and server S-->>C: responses L->>L: archive in $TMPDIR: responses, server time per call,<br/>network model, field medians, HANDOFF.txt L-->>A: archive path, complete, gaps Note over A,H: 2. calibrate: the recorded build must reproduce the field A->>L: replay --dist recorded=stable/dist --calibrate L->>R: serve the archive for every host L->>H: load the page (--host-resolver-rules: real origin, nothing leaves the machine) H->>R: every request R-->>H: static files from the dist (drawn TTFB, shared bandwidth)<br/>API responses from the archive (recorded server time) L-->>A: verdict: pass / record-again / model-error Note over A,H: 3. A/B: only after pass loop each candidate change A->>A: edit the app or the bundler, build ./dist A->>L: replay --dist base=stable/dist --dist candidate=./dist L->>H: alternating pairs, base and candidate H->>R: same recorded network and server for both L-->>A: paired deltas (90% interval), late chunks, unrecorded requests A->>A: keep or revert end Note over A,S: 4. confirm on the real site after a preview deploy A->>L: field --config field.json (base vs candidate) L->>C: alternating pairs on the deployed variants C->>S: real requests L-->>A: paired deltas on the real network ``` A replay is trusted only after `--calibrate` reproduces the field medians with the recorded build. After that, local builds are compared in alternating pairs on the same recorded network and server, and a kept change is confirmed with `field` after a preview deploy. `replay.mjs` is a standalone entry with `--json` results and exit codes, so one agent can record and another can replay. Also in this PR: timed runs record Chrome's request priorities for chunk discovery, and CPU profiles map every chunk through its own sourcemap, with top-level code split by sampled lines. The worker mode from rolldown#11188 now uses that shared attribution. Design notes: "Field mode" and "Replay" in `packages/perf-kit/README.md`; the agent contract in `AGENTS.md`. requires rolldown#11214
shulaoda
added a commit
that referenced
this pull request
Nov 5, 2026
## [0.1.0] - 2026-11-05 ### 🚀 Features - perf-kit: add the Worker leads and keep rules from the startup A/B runs (#11479) by @IWANABETHATGUY - perf-kit: show module-scope calls and compare with the pinned build in the same Worker scan (#11415) by @IWANABETHATGUY - perf-kit: measure the deployed site and replay it for local builds (#11215) by @IWANABETHATGUY - perf-kit: diagnose chunk loading before FCP and LCP (#11214) by @IWANABETHATGUY - perf-kit: Cloudflare Worker startup mode (#11188) by @IWANABETHATGUY ### 🐛 Bug Fixes - perf-kit: Worker mode with nested rolldown, external bindings, redirects (#11498) by @IWANABETHATGUY - perf-kit: make Worker mode work on more app setups (#11414) by @IWANABETHATGUY ### 📚 Documentation - add build report and perf-kit in-depth pages (#11480) by @IWANABETHATGUY ### ⚙️ Miscellaneous Tasks - perf-kit: keep run details out of code comments (#11481) by @IWANABETHATGUY Co-authored-by: shulaoda <[email protected]>
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.
Measure a Vite-built Cloudflare Worker's startup under the app's own workerd and attribute it to modules, with the loop the browser and node modes have:
worker-configwrites a Vite config that puts the rolldown metrics report on every environment;worker-scantimes the main module's import on fresh workerd instances minus an empty-import floor, hits the pinned requests on the real entry, profiles the import, and takes precise coverage from inside the isolate (wrangler >= 4.108.0, or--tools <dir>for that run);worker-attribcharges startup CPU to the evaluating module from a preserveModules build;why <module>lists the importers and the chain;cut --root a,bkeeps Durable Object class modules eager so the cut lands below them.cloudflare/agents-starter after one scan:
Shared changes, used by every mode: profile attribution splits a frame's self-time by its line ticks and maps every chunk that has a sourcemap (checklist A4); the ownership split counts multi-chunk source rows as app code;
cut --root.Shaped on cloudflare/agents-starter and cloudflare/vibesdk; the vibesdk pass is cloudflare/vibesdk#466 (
wrangler check startup: 102.5 ms -> 63.3 ms). Design notes: "Worker startup mode (Cloudflare Workers)" inpackages/perf-kit/README.md; the agent contract inAGENTS.md.The first commit, the
serve.mjssocket fix, is a parity matter and can move down into #11140.requires #11140