') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); Prewarm only appended replay payloads by NathanColosimo · Pull Request #3131 · vercel/workflow · GitHub
Skip to content

Prewarm only appended replay payloads - #3131

Merged
NathanColosimo merged 4 commits into
mainfrom
codex/prewarm-appended-payloads
Jul 27, 2026
Merged

Prewarm only appended replay payloads#3131
NathanColosimo merged 4 commits into
mainfrom
codex/prewarm-appended-payloads

Conversation

@NathanColosimo

@NathanColosimoNathanColosimo commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

What

Have the invocation-scoped ReplayPayloadCache remember the index of the next event it has not scanned, then inspect only the appended suffix on later prewarm passes.

Why

Prepared payloads were already cached, so old payloads were not decrypted or decompressed again. However, every inline replay still walked the complete accumulated event log to rediscover that those payloads were cached.

Impact

This does not change event fetching, decryption, decompression, or deserialization. It removes only the repeated prefix scan. The cache retains one numeric cursor; there are no new runtime variables, array copies, or call parameters.

Verification

  • existing replay payload-cache tests: 8 passed
  • @workflow/core typecheck
  • Biome and diff checks
  • reuse, quality, and efficiency simplify reviews

@changeset-bot

changeset-botBot commented Jul 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d3d226d

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

This PR includes changesets to release 16 packages
NameType
@workflow/corePatch
@workflow/buildersPatch
@workflow/cliPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/vitestPatch
@workflow/web-sharedPatch
@workflow/webPatch
workflowPatch
@workflow/world-testingPatch
@workflow/astroPatch
@workflow/nestPatch
@workflow/nuxtPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
@workflow/vitePatch

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

@vercel

vercelBot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

@github-actions

github-actionsBot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

📊 Workflow Benchmarks

commit d3d226d · Mon, 27 Jul 2026 21:49:10 GMT · run logs

Backend: vercel · app: nextjs-turbopack

MetricScenarioBest (ms)P75 (ms)P90 (ms)P99 (ms)Samples
TTFSstep1239 (+24%) 🔻1274 🔴 (+12%)1292 🔴 (+8.8%)1576 🔴 (-2.0%)30
TTFSstream1229 (+306%) 🔻1300 🔴 (+13%)1307 🔴 (+9.2%)1466 🔴 (+9.3%)30
TTFShook + stream1125 (+149%) 🔻1489 🔴 (+3.8%)1497 🔴 (+0.7%)1566 🔴 (-16%) 💚30
STSO1020 steps (1-20)157 (-15%) 💚280 🔴 (-3.8%)380 🔴 (+12%)613 🔴 (+51%) 🔻19
STSO1020 steps (101-120)176 (-9.3%)247 🔴 (-15%) 💚262 🔴 (-52%) 💚263 🔴 (-59%) 💚19
STSO1020 steps (1001-1020)459 (-14%)535 🔴 (-21%) 💚761 🔴 (-20%) 💚3069 🔴 (+211%) 🔻19
WO1020 steps369283 (-17%) 💚369283 (-17%) 💚369283 (-17%) 💚369283 (-17%) 💚1
SLstream latency78 (-22%) 💚137 🔴 (-36%) 💚145 🔴 (-67%) 💚176 🔴 (-69%) 💚30
SOstream overhead (text)89 (-30%) 💚124 (-49%) 💚149 (-47%) 💚232 (-75%) 💚30
SOstream overhead (structured)84 (-29%) 💚124 (-55%) 💚131 (-55%) 💚254 (-39%) 💚30
📜 Previous results (2)

05f346e

Mon, 27 Jul 2026 20:59:05 GMT · run logs

vercel / nextjs-turbopack

MetricScenarioBest (ms)P75 (ms)P90 (ms)P99 (ms)Samples
TTFSstep390 (-45%) 💚1369 🔴 (+33%) 🔻1398 🔴 (+28%) 🔻1464 🔴 (+3.2%)30
TTFSstream1250 (+46%) 🔻1347 🔴 (+41%) 🔻1380 🔴 (+42%) 🔻1542 🔴 (+55%) 🔻30
TTFShook + stream1446 (+32%) 🔻1571 🔴 (+28%) 🔻1633 🔴 (+30%) 🔻1749 🔴 (+19%) 🔻30
STSO1020 steps (1-20)169 (-6.6%)287 🔴 (+4.0%)313 🔴 (+3.0%)354 🔴 (-10%)19
STSO1020 steps (101-120)191 (+2.7%)273 🔴 (+2.2%)279 🔴 (-7.3%)312 🔴 (-87%) 💚19
STSO1020 steps (1001-1020)490 (+9.6%)553 🔴 (+7.2%)569 🔴 (+5.6%)767 🔴 (+17%) 🔻19
WO1020 steps404521 (+5.2%)404521 (+5.2%)404521 (+5.2%)404521 (+5.2%)1
SLstream latency96 (+25%) 🔻148 🔴 (+19%) 🔻158 🔴 (+9.7%)184 🔴 (-28%) 💚30
SOstream overhead (text)105 (+8.2%)175 (+13%)218 (+25%) 🔻3223 🔴 (+1528%) 🔻30
SOstream overhead (structured)117 (+16%) 🔻185 (+10%)357 (+102%) 🔻3495 🔴 (+129%) 🔻30

63c7647

Mon, 27 Jul 2026 20:34:29 GMT · run logs

vercel / nextjs-turbopack

MetricScenarioBest (ms)P75 (ms)P90 (ms)P99 (ms)Samples
STSO1020 steps (1-20)170 (-6.1%)280 🔴 (+1.4%)344 🔴 (+13%)405 🔴 (+2.8%)19
STSO1020 steps (101-120)178 (-4.3%)240 🔴 (-10%)256 🔴 (-15%)358 🔴 (-85%) 💚19
STSO1020 steps (1001-1020)454 (+1.6%)564 🔴 (+9.3%)744 🔴 (+38%) 🔻2915 🔴 (+344%) 🔻19
WO1020 steps374666 (-2.6%)374666 (-2.6%)374666 (-2.6%)374666 (-2.6%)1
SLstream latency89 (+16%) 🔻131 🔴 (+5.6%)166 🔴 (+15%) 🔻325 🔴 (+27%) 🔻30
SOstream overhead (text)98 (+1.0%)154 (-0.6%)238 (+36%) 🔻572 (+189%) 🔻30
SOstream overhead (structured)95 (-5.9%)152 (-9.5%)190 (+7.3%)433 (-72%) 💚30
ℹ️ Metric definitions & methodology

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 · STSO (1-20) 20/30/60 · STSO (101-120) 30/45/90 · STSO (1001-1020) 40/60/120

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.

@github-actions

github-actionsBot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

E2E Test Summary

Summary
PassedFailedSkippedTotal
✅ ▲ Vercel Production145502391694
✅ 💻 Local Development162102271848
✅ 📦 Local Production162102271848
✅ 🐘 Local Postgres162102271848
✅ 🪟 Windows15400154
✅ 📋 Other102002121232
✅ vercel-multi-region270027
Total7519011328651
Details by Category

✅ ▲ Vercel Production

AppPassedFailedSkipped
✅ astro126028
✅ example126028
✅ express126028
✅ fastify126028
✅ hono126028
✅ nextjs-turbopack15103
✅ nextjs-webpack15103
✅ nitro126028
✅ nuxt126028
✅ sveltekit14509
✅ vite126028

✅ 💻 Local Development

AppPassedFailedSkipped
✅ astro-stable128026
✅ express-stable128026
✅ fastify-stable128026
✅ hono-stable128026
✅ nextjs-turbopack-canary135019
✅ nextjs-turbopack-stable15400
✅ nextjs-webpack-canary135019
✅ nextjs-webpack-stable15400
✅ nitro-stable128026
✅ nuxt-stable128026
✅ sveltekit-stable14707
✅ vite-stable128026

✅ 📦 Local Production

AppPassedFailedSkipped
✅ astro-stable128026
✅ express-stable128026
✅ fastify-stable128026
✅ hono-stable128026
✅ nextjs-turbopack-canary135019
✅ nextjs-turbopack-stable15400
✅ nextjs-webpack-canary135019
✅ nextjs-webpack-stable15400
✅ nitro-stable128026
✅ nuxt-stable128026
✅ sveltekit-stable14707
✅ vite-stable128026

✅ 🐘 Local Postgres

AppPassedFailedSkipped
✅ astro-stable128026
✅ express-stable128026
✅ fastify-stable128026
✅ hono-stable128026
✅ nextjs-turbopack-canary135019
✅ nextjs-turbopack-stable15400
✅ nextjs-webpack-canary135019
✅ nextjs-webpack-stable15400
✅ nitro-stable128026
✅ nuxt-stable128026
✅ sveltekit-stable14707
✅ vite-stable128026

✅ 🪟 Windows

AppPassedFailedSkipped
✅ nextjs-turbopack15400

✅ 📋 Other

AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable128026
✅ e2e-local-dev-tanstack-start-128026
✅ e2e-local-postgres-nest-stable128026
✅ e2e-local-postgres-tanstack-start-128026
✅ e2e-local-prod-nest-stable128026
✅ e2e-local-prod-tanstack-start-128026
✅ e2e-vercel-prod-nest126028
✅ e2e-vercel-prod-tanstack-start126028

✅ vercel-multi-region

AppPassedFailedSkipped
✅ nextjs-turbopack2700

📋 View full workflow run

@github-actionsgithub-actionsBot mentioned this pull request Jul 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

No backport to stable for d7553c4 (AI decision).

This is a pure performance optimization — it adds a cursor so replay prewarming skips the already-scanned event prefix — and the PR explicitly states it changes no fetching, decryption, decompression, or deserialization behavior, so it fixes no user-visible defect. Additionally, packages/core/src/replay-payload-cache.ts does not exist on stable (verified with git ls-tree origin/stable), so the change has nothing to apply to on the maintenance line.

To override, re-run the Backport to stable workflow manually via workflow_dispatch and paste this commit SHA into the ref input:

d7553c4517b98c0eef37e5701fdfd316a7d5c008

Sign up for freeto 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.

2 participants

@NathanColosimo@VaguelySerious