Skip to content

[benchmarks] Variance analysis + follow-up work - #3236

Draft
shalabhc wants to merge 3 commits into
mainfrom
shalabhc/benchmark-variance-followup
Draft

[benchmarks] Variance analysis + follow-up work#3236
shalabhc wants to merge 3 commits into
mainfrom
shalabhc/benchmark-variance-followup

Conversation

@shalabhc

@shalabhc shalabhc commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #3213. Starts with the analysis itself so it is durable and reviewable; the code changes it recommends land on this branch after.

What's here now

packages/core/e2e/BENCHMARK_VARIANCE.md — the measured run-to-run noise floor of each benchmark metric, derived from twelve real CI runs across both environments. benchmark.test.ts and 97_bench.ts gain pointers to it.

The dataset is the useful part: six preview runs with byte-identical runtime code (renderer-only commits on #3213, a // NO-OP line on #3101, docs-only on #3170 and #3236), plus three consecutive production runs so main can be compared against main.

Two headline results

1. Production is no more stable than preview — it's the deployment draw.

main 20:38  8bda7ce  408.2 s
main 22:20  4a9d26b  388.5 s
main 22:32  32ac8e7  440.4 s      ← 12 min after the previous, lint-only diff, 13% apart

Production null spread 12.6%, preview 13.2%. Ranges overlap and the single slowest of all twelve runs is a production run. Two runs of identical code agreed to 0.2%, so the instrument is precise — the deployments differ.

2. The queue-hop tag has a blind spot, and it contaminates the inline population.

It keys off process identity, so a hop onto a reused warm instance is tagged inline. Runs reporting zero hops still carry exactly three multi-second inline samples:

#3170  (0 hops reported):  ... 750, 791, 792, 1630, 2851, 3408
32ac8e7 (3 hops reported): ... 1152, 1216, 1318, 1346, 2064, 3663   ← 2 more

Actual boundary counts run 3-7 where the reported count runs 0-3. COMPUTE_INSTANCE_ID has the same blind spot by construction; the only invocation-scoped id in the tree is requestIdStorage in world-vercel/src/queue.ts, which step bodies can't see.

Detection floor

Signal Null spread Verdict
inline STSO — cumulative / mean sd ≈ 5%, range 13% treat ±10% as the floor
inline STSO — p99 ±12% ±15% 🔻 barely above noise
inline STSO — tail count (>700 ms) 8-28 samples do not gate on it
queue-hop count 0-3 reported, 3-7 actual unreliable until fixed
TTFS — p50 ±3% within an env usable; ~25% preview/production bias
TTFS — Best 0-17 fast samples of 30 not a usable signal

For scale, a branch with a genuine regression measured an inline mean of 1361 ms against a null mean of 388 ms. The metric catches real regressions comfortably; it's the sub-15% range that can't be trusted.

Refuted hypotheses (recorded so they don't get re-proposed)

  • Preview vs production explains the inline differencesno, ranges overlap and production holds the slowest run.
  • The TTFS fast mode is production-onlyno, a preview run hit it 11/30 and [repro] Bisect: known-good base + #3198 only #3238 hit 17/30.
  • WO is an independent signalno, it's Σ(gaps) + step-body time.
  • ±8% is the floorno, that came from the first four runs; six give 13.2%.

One environment effect is real: TTFS p50 is 966-1063 ms on production but 1240-1384 ms on preview, so every PR carries a built-in ~25% TTFS regression from the main-runs-production / PRs-run-preview split.

Follow-up items (in the doc, to land on this branch)

  1. Tag queue-hops by invocation, not process — needs an invocation-scoped id exposed to step bodies. Highest value; without it the inline population is silently contaminated.
  2. Keep raw in run order — stored sorted today, which makes the event-log-growth hypothesis for the slow tail untestable. One line, no output change.
  3. Baseline against a preview deployment of main, not production.
  4. Loosen or replace the p99 threshold for inline STSO.
  5. Report TTFS fast-mode fraction instead of / beside Best.
  6. Consider repeated runs per commit — with sd ≈ 5%, three runs put the standard error near 3%.
  7. Fix commit provenance on PR runs (artifacts record the refs/pull/N/merge sha despite the step env holding the head sha).

Empty changeset — no package behavior changes.

🤖 Generated with Claude Code

Records the run-to-run noise floor of each benchmark metric, measured
against five real CI runs rather than inferred: four preview runs of
byte-identical runtime code plus the production baseline they were
diffed against.

The core result is that the measurement is precise but the deployments
are not — two runs of identical code agreed to within 0.2% on cumulative
inline STSO, while a third was 8% slower across its entire distribution.
That sets a practical detection floor (inline STSO ±8%; TTFS Best not
usable at all, being a min over 30 samples drawn from a bimodal
population), which is why a no-op PR tripped a P99 regression flag on 15
samples out of 1016.

Also records the hypotheses this data refuted, so they aren't
re-proposed — notably that preview-vs-production explains the inline
differences (it does not; production sits inside the preview range) —
and five follow-up items, including the environment mismatch that gives
every PR a built-in ~+25% TTFS regression.

Co-Authored-By: shalabhc <shalabh.chaturvedi@vercel.com>
@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
example-nextjs-workflow-turbopack Ready Ready Preview Jul 30, 2026 11:29pm
example-nextjs-workflow-webpack Ready Ready Preview Jul 30, 2026 11:29pm
example-workflow Ready Ready Preview Jul 30, 2026 11:29pm
workbench-astro-workflow Ready Ready Preview Jul 30, 2026 11:29pm
workbench-express-workflow Ready Ready Preview Jul 30, 2026 11:29pm
workbench-fastify-workflow Ready Ready Preview Jul 30, 2026 11:29pm
workbench-hono-workflow Ready Ready Preview Jul 30, 2026 11:29pm
workbench-nestjs-workflow Ready Ready Preview Jul 30, 2026 11:29pm
workbench-nitro-workflow Ready Ready Preview Jul 30, 2026 11:29pm
workbench-nuxt-workflow Ready Ready Preview Jul 30, 2026 11:29pm
workbench-sveltekit-workflow Ready Ready Preview Jul 30, 2026 11:29pm
workbench-tanstack-start-workflow Ready Ready Preview Jul 30, 2026 11:29pm
workbench-vite-workflow Ready Ready Preview Jul 30, 2026 11:29pm
workflow-docs Ready Ready Preview, v0 Jul 30, 2026 11:29pm
workflow-swc-playground Ready Ready Preview Jul 30, 2026 11:29pm
workflow-tarballs Ready Ready Preview Jul 30, 2026 11:29pm
workflow-web Ready Ready Preview Jul 30, 2026 11:29pm

@changeset-bot

changeset-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ea1a046

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

E2E Test Summary

Summary
Passed Failed Skipped Total
✅ ▲ Vercel Production 1455 0 239 1694
✅ 💻 Local Development 1351 0 189 1540
✅ 📦 Local Production 1621 0 227 1848
✅ 🐘 Local Postgres 1621 0 227 1848
✅ 🪟 Windows 154 0 0 154
✅ 📋 Other 1020 0 212 1232
✅ vercel-multi-region 27 0 0 27
Total 7249 0 1094 8343
Details by Category

✅ ▲ Vercel Production

App Passed Failed Skipped
✅ astro 126 0 28
✅ example 126 0 28
✅ express 126 0 28
✅ fastify 126 0 28
✅ hono 126 0 28
✅ nextjs-turbopack 151 0 3
✅ nextjs-webpack 151 0 3
✅ nitro 126 0 28
✅ nuxt 126 0 28
✅ sveltekit 145 0 9
✅ vite 126 0 28

✅ 💻 Local Development

App Passed Failed Skipped
✅ astro-stable 128 0 26
✅ express-stable 128 0 26
✅ fastify-stable 128 0 26
✅ hono-stable 128 0 26
✅ nextjs-turbopack-stable 154 0 0
✅ nextjs-webpack-stable 154 0 0
✅ nitro-stable 128 0 26
✅ nuxt-stable 128 0 26
✅ sveltekit-stable 147 0 7
✅ vite-stable 128 0 26

✅ 📦 Local Production

App Passed Failed Skipped
✅ astro-stable 128 0 26
✅ express-stable 128 0 26
✅ fastify-stable 128 0 26
✅ hono-stable 128 0 26
✅ nextjs-turbopack-canary 135 0 19
✅ nextjs-turbopack-stable 154 0 0
✅ nextjs-webpack-canary 135 0 19
✅ nextjs-webpack-stable 154 0 0
✅ nitro-stable 128 0 26
✅ nuxt-stable 128 0 26
✅ sveltekit-stable 147 0 7
✅ vite-stable 128 0 26

✅ 🐘 Local Postgres

App Passed Failed Skipped
✅ astro-stable 128 0 26
✅ express-stable 128 0 26
✅ fastify-stable 128 0 26
✅ hono-stable 128 0 26
✅ nextjs-turbopack-canary 135 0 19
✅ nextjs-turbopack-stable 154 0 0
✅ nextjs-webpack-canary 135 0 19
✅ nextjs-webpack-stable 154 0 0
✅ nitro-stable 128 0 26
✅ nuxt-stable 128 0 26
✅ sveltekit-stable 147 0 7
✅ vite-stable 128 0 26

✅ 🪟 Windows

App Passed Failed Skipped
✅ nextjs-turbopack 154 0 0

✅ 📋 Other

App Passed Failed Skipped
✅ e2e-local-dev-nest-stable 128 0 26
✅ e2e-local-dev-tanstack-start- 128 0 26
✅ e2e-local-postgres-nest-stable 128 0 26
✅ e2e-local-postgres-tanstack-start- 128 0 26
✅ e2e-local-prod-nest-stable 128 0 26
✅ e2e-local-prod-tanstack-start- 128 0 26
✅ e2e-vercel-prod-nest 126 0 28
✅ e2e-vercel-prod-tanstack-start 126 0 28

✅ vercel-multi-region

App Passed Failed Skipped
✅ nextjs-turbopack 27 0 0

📋 View full workflow run

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

📊 Workflow Benchmarks

commit ea1a046 · Thu, 30 Jul 2026 23:49:10 GMT · run logs

Backend: vercel · app: nextjs-turbopack

Metric Scenario Best (ms) P75 (ms) P90 (ms) P99 (ms) Samples
TTFS step 414 (-59%) 💚 1408 🔴 (+25%) 🔻 1452 🔴 (+25%) 🔻 3551 🔴 (+181%) 🔻 30
TTFS stream 1266 (+518%) 🔻 1360 🔴 (+24%) 🔻 1379 🔴 (+22%) 🔻 1435 🔴 (-12%) 30
TTFS hook + stream 1259 (-5.0%) 1677 🔴 (+17%) 🔻 1727 🔴 (+18%) 🔻 1909 🔴 (+16%) 🔻 30
STSO 1020 steps (inline) 174 (-5.4%) 479 (-7.7%) 544 (-5.4%) 888 (+9.9%) 1016
STSO 1020 steps (queue-hop) 2270 (+12%) 2994 (-36%) 💚 2994 (-36%) 💚 2994 (-36%) 💚 3
WO 1020 steps 417666 (-7.4%) 417666 (-7.4%) 417666 (-7.4%) 417666 (-7.4%) 1
SL stream latency 101 (-9.8%) 144 🔴 (-13%) 157 🔴 (-25%) 💚 167 🔴 (-57%) 💚 30
SO stream overhead (text) 112 (-15%) 💚 163 (-43%) 💚 180 (-64%) 💚 362 (-87%) 💚 30
SO stream overhead (structured) 115 (-13%) 185 (-34%) 💚 245 (-36%) 💚 432 (-72%) 💚 30
📈 STSO distribution vs main (inline / queue-hop histograms)

1020 steps (inline)

Cumulative STSO time: main 440353ms → this run 408215ms (Δ -32138ms, -7%)

  150-200 ms  █░┃                       main   2  this  18   +16
  200-250 ms  █████████░░░┃             main  63  this  91   +28
  250-300 ms  █████████████████░┃       main 117  this 132   +15
  300-350 ms  ███████████████████░░░░┃  main 129  this 166   +37
  350-400 ms  ████████████████████┃     main 142  this 145    +3
  400-450 ms  ██████████████████┃       main 125  this 133    +8
  450-500 ms  ██████████████████┃       main 130  this 130    +0
  500-550 ms  ███████████████┃████████  main 163  this 109   -54
  550-600 ms  █████┃█████               main  74  this  41   -33
  600-650 ms  ██┃█                      main  29  this  20    -9
  650-700 ms  ┃█                        main  14  this   7    -7
  700-750 ms  ┃█                        main  12  this   7    -5
  750-800 ms  ┃                         main   5  this   4    -1
  800-850 ms  ┃                         main   2  this   2    +0
  850-900 ms  ┃                         main   1  this   1    +0
  900-950 ms  ┃                         main   0  this   2    +2
 950-1000 ms  ┃                         main   1  this   4    +3
1000-1050 ms  ┃                         main   0  this   1    +1
1100-1150 ms  ┃                         main   1  this   0    -1
1150-1200 ms  ┃                         main   1  this   0    -1
1200-1250 ms  ┃                         main   1  this   0    -1
1300-1350 ms  ┃                         main   2  this   1    -1
2050-2100 ms  ┃                         main   1  this   0    -1
2300-2350 ms  ┃                         main   0  this   1    +1
2850-2900 ms  ┃                         main   0  this   1    +1
3650-3700 ms  ┃                         main   1  this   0    -1

1020 steps (queue-hop)

Cumulative STSO time: main 9664ms → this run 8160ms (Δ -1504ms, -16%)

2000-2500 ms  ███████████┃              main 1  this 1  +0
2500-3000 ms  ████████████░░░░░░░░░░░┃  main 1  this 2  +1
4500-5000 ms  ┃███████████              main 1  this 0  -1
📜 Previous results (1)

cc0c16f

Thu, 30 Jul 2026 22:31:48 GMT · run logs

vercel / nextjs-turbopack

Metric Scenario Best (ms) P75 (ms) P90 (ms) P99 (ms) Samples
TTFS step 1324 (+530%) 🔻 1408 🔴 (+33%) 🔻 1448 🔴 (+34%) 🔻 1464 🔴 (+20%) 🔻 30
TTFS stream 1292 (+380%) 🔻 1390 🔴 (+30%) 🔻 1423 🔴 (+30%) 🔻 1643 🔴 (+40%) 🔻 30
TTFS hook + stream 1546 (+309%) 🔻 1690 🔴 (+35%) 🔻 1771 🔴 (+37%) 🔻 2026 🔴 (+29%) 🔻 30
STSO 1020 steps (inline) 171 (-3.9%) 482 (±0%) 559 (+4.5%) 835 (+22%) 🔻 1016
STSO 1020 steps (queue-hop) 1580 (-2.9%) 3439 (+15%) 3439 (+15%) 3439 (+15%) 3
WO 1020 steps 428555 (+3.0%) 428555 (+3.0%) 428555 (+3.0%) 428555 (+3.0%) 1
SL stream latency 102 (+26%) 🔻 149 🔴 (+1.4%) 163 🔴 (-11%) 258 🔴 (-28%) 💚 30
SO stream overhead (text) 118 (-5.6%) 171 (-22%) 💚 206 (-18%) 💚 581 (+35%) 🔻 30
SO stream overhead (structured) 106 (-8.6%) 155 (-33%) 💚 171 (-43%) 💚 251 (-33%) 💚 30
ℹ️ Metric definitions & methodology

The collapsed STSO distribution section above buckets every step gap of the sequential-steps run (not a sampled window), split by whether the step ending the gap ran inline — in the same warm process as the step before it, so the gap is pure framework overhead — or after a queue-hop — the first step of a fresh process, which pays queue dispatch, client reinit and event-log replay. Bars overlay the two runs: is main, marks where this run lands, bridges the gap when this run has more samples in a bucket.

Best/P75/P90/P99 deltas compare against the most recent benchmark run on main at the time of this run. 🔻 flags a delta worse than +15%, 💚 one better than −15%.

Metrics — TTFS: time to first step body (in-deployment start() → first step body, deployment clocks) · STSO: step-to-step overhead (gap between consecutive step bodies) · WO: workflow overhead (whole-run time outside step bodies, in-deployment anchored) · SL: stream latency (in-deployment write → read propagation, readAt - writtenAt) · SO: stream overhead (end-to-end write+consume time beyond the modelled generation window)

Scenarios — step: one trivial no-op step, no stream; no hooks, so the run stays in turbo mode (in-process fast path) · stream: one streaming step; no hooks, so the run stays in turbo mode (in-process fast path) · hook + stream: registers a hook before one step, which exits turbo mode (dispatch path) · 1020 steps: 1020 trivial sequential steps; STSO is measured between consecutive steps in the given step ranges, and WO is the whole-run overhead outside step bodies · stream latency: parallel reader/writer steps on a dedicated stream; SL is the in-deployment write->read propagation (readAt - writtenAt) · stream overhead (text): writer streams 300 variable-length text token deltas paced at 100/s for 3s (a haiku-size LLM's token throughput) while a parallel reader drains the whole stream; SO is the end-to-end write+consume time beyond the 3s generation window (overhead/backpressure) · stream overhead (structured): same workload as stream overhead (text), but each delta is an AI-SDK-style structured object ({ type: 'text-delta', id, text }) instead of a raw string, so the SO gap vs the text scenario is the added serialization cost

🔴 marks a percentile over its target (within target is left unmarked). Targets (p75/p90/p99, ms) — TTFS 200/300/600 · SL 50/60/125 · SO 250/500/1000

All metrics are measured from deployment-side timestamps only. Runs are triggered by an in-deployment route that stamps the anchor (clientStart) right before start(), so the CI runner’s request and its path through api.vercel.com sit outside every measured window. TTFS = in-deployment start() → first step body (turbo uses the in-process fast path, non-turbo the dispatch path), and includes the VQS dispatch hop plus any /flow cold start. STSO/WO are measured between step bodies on the deployment. SL is measured inside the workflow (parallel reader/writer steps), so it no longer includes the api.vercel.com read path.

Cold starts are kept in the numbers on purpose — they are part of real bursty-workload latency. The workbench deployment cold-starts the /flow invocation for a large fraction of runs, inflating P75+; the Best column shows the fastest (warm-start) sample for comparison.

Adds eight more CI runs, including three consecutive production runs so
main can be compared against main, and three more runtime-identical
preview runs (a no-op line, a docs-only PR, a documentation-only PR).

Two findings this data adds:

Production is no more stable than preview. Two main runs twelve minutes
apart, differing only by a lint-only commit, came out 13% apart (388.5s
vs 440.4s); the production null spread (12.6%) matches preview's
(13.2%). That kills the last version of the "it's the environment"
explanation for inline STSO, leaving the deployment draw itself.

The queue-hop tag has a blind spot: it keys off process identity, so a
hop onto a reused warm instance is tagged inline. Runs reporting zero
hops still carry exactly three multi-second inline samples, and one
production run reporting three hops carried two more. Actual boundary
counts run 3-7 where the reported count runs 0-3, so the inline
population is contaminated on an unpredictable subset of runs. Noted at
the tagging site in 97_bench.ts as well.

Also revises the detection floor: the earlier ±8% came from the first
four runs and understated it. Six runtime-identical preview runs give
sd ≈ 5% and an observed range of 13.2%.

Co-Authored-By: shalabhc <shalabh.chaturvedi@vercel.com>
The earlier "3-7 actual boundaries" was an artifact of treating every
inline sample over 1.5s as a mislabeled hop. The boundary count is not a
matter of inference: an invocation is capped at ~120s, so a run of
duration WO must cross ceil(WO/120s)-1 of them, which is exactly 3 for
every run in the set except the broken repl-det branch (11).

So the runs reporting 3 hops already found all of them, and their extra
multi-second inline samples are genuine stalls rather than mislabeled
hops. The >1.5s heuristic only finds hops on runs that reported none.

Detection turns out to be all-or-nothing — 3 of 3 or 0 of 3, never in
between, across eleven runs — which points at a per-run property rather
than a per-boundary coin flip. Also records the decisive test now that
#3186 persists the compute instance per step attempt: group one 0-hop
and one 3-hop run's attempts by instance id.

Co-Authored-By: shalabhc <shalabh.chaturvedi@vercel.com>
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