') + ')', '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); } })(); })(); perf(core): cache local dev server port per process by VaguelySerious · Pull Request #2522 · vercel/workflow · GitHub
Skip to content

perf(core): cache local dev server port per process - #2522

Merged
VaguelySerious merged 2 commits into
mainfrom
peter/local-port-cache
Jun 18, 2026
Merged

perf(core): cache local dev server port per process#2522
VaguelySerious merged 2 commits into
mainfrom
peter/local-port-cache

Conversation

@VaguelySerious

Copy link
Copy Markdown
Member

Summary

The non-Vercel branch of runWorkflow calls getPortLazy() on every replay to locate the local dev server port. getPort() rediscovers the port each call by querying the OS for the process's listening sockets — on macOS that shells out to lsof (~60ms). This is paid on every replay and dominates local time-to-first-step.

The dev server's port is stable for the lifetime of the process, so this caches the resolved port per process and reuses it.

  • A transient undefined (server not listening yet on the very first replay) is not cached, so discovery retries until a concrete port appears.
  • Concurrent first calls share a single in-flight lookup (no double lsof).

Impact (local replay, macOS)

Measured against world-local with a one-step workflow, the getPortLazy phase of the replay window:

beforeafter
getPortLazy per replay (warm)~64 ms~0.02 ms (cached)
first call (cold)~64 ms~64 ms (paid once)

This is a local-dev-only path — on Vercel the port lookup is skipped entirely (isVercel short-circuit), so production is unaffected.

Tests

New get-port-lazy.test.ts verifies the caching contract via an injected resolver:

  • resolves once and reuses on subsequent calls (single OS query),
  • dedupes concurrent first calls into one resolution,
  • does not cache undefined (retries until a concrete port appears).

🤖 Generated with Claude Code

The non-Vercel branch of runWorkflow calls getPortLazy() on every replay
to find the local dev server port. getPort() rediscovers the port each
call by querying the OS for the process's listening sockets — on macOS
that spawns lsof (~60ms), paid on every replay and dominating local
time-to-first-step.
The port is stable for the process lifetime, so resolve it once and
reuse it. A transient undefined (server not yet listening) is not cached
so discovery retries; concurrent first calls share one in-flight lookup.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@VaguelySerious
VaguelySerious requested a review from a team as a code ownerJune 18, 2026 20:55
@vercel

vercelBot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

@changeset-bot

changeset-botBot commented Jun 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2ebca48

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/rollupPatch
@workflow/sveltekitPatch
@workflow/vitePatch
@workflow/nuxtPatch

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-actionsBot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

📈 Comparing against baseline from main branch. Green 🟢 = faster, Red 🔺 = slower.

workflow with no steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Express0.042s (-3.0%)1.006s (~)0.964s101.00x
💻 LocalNitro0.044s (+8.4% 🔺)1.007s (~)0.963s101.05x
💻 LocalNext.js (Turbopack)0.051s (-22.9% 🟢)1.006s (~)0.956s101.21x
🐘 PostgresNext.js (Turbopack)0.057s (-18.5% 🟢)1.013s (~)0.956s101.36x
🐘 PostgresExpress0.059s (-19.3% 🟢)1.018s (+0.7%)0.960s101.39x
🐘 PostgresNitro0.062s (-1.8%)1.013s (~)0.951s101.47x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro0.283s (-24.5% 🟢)2.534s (+12.8% 🔺)2.251s101.00x
▲ VercelExpress0.328s (-13.0% 🟢)2.193s (-4.4%)1.864s101.16x
▲ VercelNext.js (Turbopack)⚠️missing----

🔍 Observability: Nitro | Express

workflow with 1 step

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro1.093s (+0.7%)2.008s (~)0.915s101.00x
💻 LocalExpress1.101s (~)2.006s (~)0.906s101.01x
💻 LocalNext.js (Turbopack)1.101s (-4.1%)2.007s (~)0.906s101.01x
🐘 PostgresNext.js (Turbopack)1.102s (-3.4%)2.010s (~)0.908s101.01x
🐘 PostgresExpress1.104s (~)2.011s (~)0.907s101.01x
🐘 PostgresNitro1.108s (-1.1%)2.010s (~)0.902s101.01x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express1.599s (-17.4% 🟢)3.308s (-10.0% 🟢)1.709s101.00x
▲ VercelNitro1.650s (-28.8% 🟢)3.772s (-5.5% 🟢)2.122s101.03x
▲ VercelNext.js (Turbopack)⚠️missing----

🔍 Observability: Express | Nitro

workflow with 10 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express10.500s (~)11.020s (~)0.520s31.00x
💻 LocalNitro10.533s (~)11.024s (~)0.491s31.00x
🐘 PostgresNitro10.539s (~)11.014s (~)0.476s31.00x
💻 LocalExpress10.562s (~)11.024s (~)0.462s31.01x
💻 LocalNext.js (Turbopack)10.577s (-2.1%)11.024s (~)0.447s31.01x
🐘 PostgresNext.js (Turbopack)10.581s (-2.5%)11.026s (~)0.445s31.01x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro13.104s (-30.9% 🟢)14.753s (-30.8% 🟢)1.649s31.00x
▲ VercelExpress13.457s (-25.5% 🟢)14.912s (-25.3% 🟢)1.455s31.03x
▲ VercelNext.js (Turbopack)⚠️missing----

🔍 Observability: Nitro | Express

workflow with 25 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro13.719s (-0.9%)14.019s (~)0.301s51.00x
💻 LocalNitro13.728s (+0.7%)14.028s (~)0.300s51.00x
🐘 PostgresExpress13.834s (~)14.026s (~)0.192s51.01x
💻 LocalExpress13.850s (+0.7%)14.027s (~)0.177s51.01x
💻 LocalNext.js (Turbopack)13.926s (-3.1%)14.029s (-6.7% 🟢)0.103s51.02x
🐘 PostgresNext.js (Turbopack)13.959s (-3.3%)14.021s (-6.6% 🟢)0.062s51.02x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro19.588s (-37.1% 🟢)21.592s (-33.7% 🟢)2.004s31.00x
▲ VercelExpress20.273s (-16.3% 🟢)21.931s (-16.2% 🟢)1.658s31.03x
▲ VercelNext.js (Turbopack)⚠️missing----

🔍 Observability: Nitro | Express

workflow with 50 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express12.369s (-0.6%)13.021s (~)0.652s71.00x
💻 LocalNitro12.538s (+3.9%)13.026s (+1.1%)0.488s71.01x
🐘 PostgresNitro12.539s (~)13.018s (~)0.479s71.01x
💻 LocalExpress12.652s (+0.8%)13.026s (~)0.374s71.02x
🐘 PostgresNext.js (Turbopack)12.653s (-8.7% 🟢)13.023s (-8.0% 🟢)0.370s71.02x
💻 LocalNext.js (Turbopack)13.539s (-0.9%)13.885s (-1.0%)0.346s71.09x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro26.624s (-31.6% 🟢)29.632s (-27.6% 🟢)3.008s41.00x
▲ VercelExpress27.577s (-21.4% 🟢)29.843s (-19.1% 🟢)2.266s41.04x
▲ VercelNext.js (Turbopack)⚠️missing----

🔍 Observability: Nitro | Express

Promise.all with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Next.js (Turbopack)1.196s (-7.0% 🟢)2.009s (~)0.812s151.00x
🐘 PostgresNitro1.198s (~)2.008s (~)0.809s151.00x
🐘 PostgresExpress1.227s (+1.1%)2.009s (~)0.782s151.03x
💻 LocalNitro1.252s (+7.0% 🔺)2.006s (~)0.754s151.05x
💻 LocalExpress1.259s (+8.0% 🔺)2.007s (~)0.748s151.05x
💻 LocalNext.js (Turbopack)1.454s (+12.2% 🔺)2.007s (~)0.552s151.22x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express2.221s (~)3.433s (-11.7% 🟢)1.212s91.00x
▲ VercelNitro2.348s (-19.4% 🟢)4.051s (-8.1% 🟢)1.703s81.06x
▲ VercelNext.js (Turbopack)⚠️missing----

🔍 Observability: Express | Nitro

Promise.all with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.257s (-11.8% 🟢)2.008s (-16.1% 🟢)0.751s151.00x
🐘 PostgresNext.js (Turbopack)1.274s (-22.2% 🟢)2.315s (-3.3%)1.042s131.01x
🐘 PostgresNitro1.385s (+1.5%)2.152s (-14.2% 🟢)0.767s141.10x
💻 LocalNext.js (Turbopack)2.118s (+10.9% 🔺)2.735s (+19.3% 🔺)0.617s111.68x
💻 LocalNitro2.136s (+37.6% 🔺)2.917s (+45.1% 🔺)0.782s111.70x
💻 LocalExpress2.185s (+34.3% 🔺)2.919s (+45.5% 🔺)0.734s111.74x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express2.798s (-29.4% 🟢)4.412s (-22.2% 🟢)1.613s71.00x
▲ VercelNitro3.003s (-25.8% 🟢)4.910s (-13.9% 🟢)1.907s71.07x
▲ VercelNext.js (Turbopack)⚠️missing----

🔍 Observability: Express | Nitro

Promise.all with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.389s (-21.2% 🟢)3.343s (-14.0% 🟢)1.955s91.00x
🐘 PostgresNitro1.476s (-7.5% 🟢)3.455s (-13.9% 🟢)1.979s91.06x
🐘 PostgresNext.js (Turbopack)1.502s (-52.4% 🟢)4.011s (-6.8% 🟢)2.509s81.08x
💻 LocalExpress5.488s (+25.5% 🔺)6.214s (+27.7% 🔺)0.727s53.95x
💻 LocalNitro5.720s (+67.1% 🔺)6.014s (+50.0% 🔺)0.294s54.12x
💻 LocalNext.js (Turbopack)6.576s (+13.9% 🔺)7.215s (+16.1% 🔺)0.639s54.74x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express4.189s (-23.9% 🟢)6.333s (-20.1% 🟢)2.144s51.00x
▲ VercelNitro5.852s (-4.5%)7.881s (-5.5% 🟢)2.029s41.40x
▲ VercelNext.js (Turbopack)⚠️missing----

🔍 Observability: Express | Nitro

Promise.race with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Next.js (Turbopack)1.173s (-8.4% 🟢)2.008s (~)0.835s151.00x
🐘 PostgresExpress1.174s (-3.6%)2.008s (~)0.834s151.00x
🐘 PostgresNitro1.232s (+1.7%)2.009s (~)0.777s151.05x
💻 LocalNitro1.235s (+2.8%)2.007s (~)0.773s151.05x
💻 LocalExpress1.248s (-20.9% 🟢)2.007s (~)0.759s151.06x
💻 LocalNext.js (Turbopack)1.280s (-8.5% 🟢)2.007s (~)0.727s151.09x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express2.307s (-0.7%)3.570s (-6.2% 🟢)1.263s91.00x
▲ VercelNitro2.474s (-30.6% 🟢)3.924s (-25.8% 🟢)1.450s81.07x
▲ VercelNext.js (Turbopack)⚠️missing----

🔍 Observability: Express | Nitro

Promise.race with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.239s (-9.3% 🟢)2.075s (-10.4% 🟢)0.835s151.00x
🐘 PostgresNext.js (Turbopack)1.272s (-17.6% 🟢)2.316s (+4.2%)1.044s131.03x
🐘 PostgresNitro1.301s (-9.8% 🟢)2.007s (-16.2% 🟢)0.706s151.05x
💻 LocalExpress1.981s (+4.4%)2.509s (+16.7% 🔺)0.528s121.60x
💻 LocalNitro2.097s (+23.8% 🔺)2.828s (+40.8% 🔺)0.731s111.69x
💻 LocalNext.js (Turbopack)2.211s (+2.0%)3.010s (~)0.799s101.78x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express2.960s (+8.6% 🔺)4.708s (+3.0%)1.748s71.00x
▲ VercelNitro3.530s (+26.1% 🔺)5.989s (+43.2% 🔺)2.459s61.19x
▲ VercelNext.js (Turbopack)⚠️missing----

🔍 Observability: Express | Nitro

Promise.race with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.426s (-20.8% 🟢)3.566s (-11.1% 🟢)2.140s91.00x
🐘 PostgresNitro1.446s (-19.9% 🟢)4.011s (-6.6% 🟢)2.565s81.01x
🐘 PostgresNext.js (Turbopack)1.463s (-64.0% 🟢)4.013s (-9.7% 🟢)2.549s81.03x
💻 LocalExpress5.720s (+24.6% 🔺)6.216s (+24.0% 🔺)0.496s54.01x
💻 LocalNitro6.331s (+41.0% 🔺)7.017s (+40.0% 🔺)0.686s54.44x
💻 LocalNext.js (Turbopack)7.641s (+31.6% 🔺)8.268s (+28.9% 🔺)0.626s45.36x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express5.877s (-30.3% 🟢)8.068s (-21.2% 🟢)2.192s41.00x
▲ VercelNitro304.323s (+2096.3% 🔺)306.837s (+1859.1% 🔺)2.514s351.79x
▲ VercelNext.js (Turbopack)⚠️missing----

🔍 Observability: Express | Nitro

workflow with 10 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.499s (-12.6% 🟢)1.007s (~)0.508s601.00x
🐘 PostgresNext.js (Turbopack)0.553s (-33.7% 🟢)1.006s (-1.7%)0.453s601.11x
🐘 PostgresNitro0.572s (-3.8%)1.023s (-1.7%)0.452s591.15x
💻 LocalExpress0.586s (-6.2% 🟢)1.005s (-1.6%)0.419s601.17x
💻 LocalNitro0.597s (+19.4% 🔺)1.005s (~)0.408s601.20x
💻 LocalNext.js (Turbopack)0.663s (-25.3% 🟢)1.023s (-1.6%)0.360s591.33x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express3.354s (-26.2% 🟢)4.840s (-25.3% 🟢)1.486s131.00x
▲ VercelNitro4.864s (-26.4% 🟢)6.764s (-18.9% 🟢)1.899s91.45x
▲ VercelNext.js (Turbopack)⚠️missing----

🔍 Observability: Express | Nitro

workflow with 25 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.255s (-7.5% 🟢)2.030s (~)0.776s451.00x
🐘 PostgresNitro1.317s (-5.1% 🟢)2.029s (~)0.712s451.05x
🐘 PostgresNext.js (Turbopack)1.371s (-29.4% 🟢)2.030s (-2.2%)0.658s451.09x
💻 LocalExpress1.468s (-1.4%)2.006s (~)0.538s451.17x
💻 LocalNitro1.499s (+26.2% 🔺)2.007s (~)0.507s451.19x
💻 LocalNext.js (Turbopack)1.586s (-24.5% 🟢)2.007s (-33.3% 🟢)0.421s451.26x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express7.328s (-58.1% 🟢)8.856s (-53.8% 🟢)1.528s111.00x
▲ VercelNitro11.449s (-3.1%)13.446s (-5.1% 🟢)1.997s71.56x
▲ VercelNext.js (Turbopack)⚠️missing----

🔍 Observability: Express | Nitro

workflow with 50 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express2.327s (-14.1% 🟢)3.034s (-2.5%)0.706s401.00x
🐘 PostgresNitro2.657s (-5.1% 🟢)3.086s (-2.5%)0.429s391.14x
🐘 PostgresNext.js (Turbopack)2.715s (-29.8% 🟢)3.084s (-24.3% 🟢)0.369s401.17x
💻 LocalNitro3.219s (+17.9% 🔺)4.009s (+24.4% 🔺)0.791s301.38x
💻 LocalExpress3.232s (+1.1%)4.010s (~)0.778s301.39x
💻 LocalNext.js (Turbopack)3.385s (-22.1% 🟢)4.010s (-20.0% 🟢)0.625s301.45x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express17.667s (-32.2% 🟢)19.690s (-29.7% 🟢)2.023s71.00x
▲ VercelNitro25.272s (-3.9%)27.508s (-2.1%)2.236s51.43x
▲ VercelNext.js (Turbopack)⚠️missing----

🔍 Observability: Express | Nitro

workflow with 10 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Next.js (Turbopack)0.189s (-35.7% 🟢)1.006s (~)0.817s601.00x
🐘 PostgresExpress0.198s (-14.2% 🟢)1.007s (~)0.808s601.05x
🐘 PostgresNitro0.237s (~)1.007s (~)0.770s601.25x
💻 LocalExpress0.413s (-6.2% 🟢)1.005s (~)0.592s602.18x
💻 LocalNitro0.432s (+15.8% 🔺)1.005s (~)0.573s602.28x
💻 LocalNext.js (Turbopack)0.764s (+31.2% 🔺)1.005s (~)0.241s604.04x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express2.230s (+43.8% 🔺)3.657s (+27.5% 🔺)1.427s171.00x
▲ VercelNitro2.462s (+90.7% 🔺)4.234s (+47.3% 🔺)1.772s151.10x
▲ VercelNext.js (Turbopack)⚠️missing----

🔍 Observability: Express | Nitro

workflow with 25 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Next.js (Turbopack)0.284s (-47.2% 🟢)1.018s (-8.9% 🟢)0.734s891.00x
🐘 PostgresExpress0.303s (-14.8% 🟢)1.006s (-3.2%)0.704s901.07x
🐘 PostgresNitro0.343s (~)1.006s (-1.1%)0.663s901.21x
💻 LocalExpress2.132s (+2.1%)2.611s (-1.7%)0.479s357.50x
💻 LocalNitro2.277s (+49.4% 🔺)2.824s (+31.2% 🔺)0.547s328.01x
💻 LocalNext.js (Turbopack)2.725s (+16.9% 🔺)3.472s (+12.9% 🔺)0.747s269.59x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.343s (-14.7% 🟢)4.072s (-14.8% 🟢)1.730s231.00x
▲ VercelExpress2.726s (-6.9% 🟢)4.367s (-9.0% 🟢)1.642s211.16x
▲ VercelNext.js (Turbopack)⚠️missing----

🔍 Observability: Nitro | Express

workflow with 50 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.467s (-17.9% 🟢)1.220s (~)0.753s991.00x
🐘 PostgresNext.js (Turbopack)0.497s (-81.0% 🟢)3.059s (-11.9% 🟢)2.562s401.06x
🐘 PostgresNitro0.530s (-6.7% 🟢)1.032s (-16.2% 🟢)0.502s1171.13x
💻 LocalNext.js (Turbopack)10.327s (-4.0%)11.121s (-3.9%)0.794s1122.12x
💻 LocalExpress10.675s (+28.5% 🔺)11.484s (+29.3% 🔺)0.809s1122.87x
💻 LocalNitro10.686s (+69.3% 🔺)11.488s (+70.3% 🔺)0.801s1122.89x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.244s (-38.5% 🟢)5.171s (-26.3% 🟢)1.927s241.00x
▲ VercelExpress4.365s (-20.1% 🟢)6.244s (-11.9% 🟢)1.878s201.35x
▲ VercelNext.js (Turbopack)⚠️missing----

🔍 Observability: Nitro | Express

Stream Benchmarks(includes TTFB metrics)
workflow with stream

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.158s (-1.8%)2.003s (~)0.001s (-9.1% 🟢)2.011s (~)0.853s101.00x
💻 LocalNext.js (Turbopack)1.163s (-3.9%)2.004s (~)0.013s (+4.0%)2.021s (~)0.858s101.00x
🐘 PostgresNitro1.168s (~)1.997s (~)0.001s (~)2.011s (~)0.843s101.01x
💻 LocalNitro1.177s (+5.3% 🔺)2.006s (~)0.013s (-55.0% 🟢)2.021s (-0.8%)0.844s101.02x
🐘 PostgresNext.js (Turbopack)1.179s (-4.1%)2.002s (~)0.001s (~)2.012s (~)0.833s101.02x
💻 LocalExpress1.189s (+3.4%)2.005s (~)0.013s (+24.8% 🔺)2.021s (~)0.831s101.03x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express2.342s (-2.5%)3.217s (-12.6% 🟢)3.052s (+311.9% 🔺)6.668s (+36.8% 🔺)4.327s101.00x
▲ VercelNitro2.656s (+0.6%)3.769s (-1.0%)2.143s (+170.1% 🔺)6.416s (+26.9% 🔺)3.760s101.13x
▲ VercelNext.js (Turbopack)⚠️missing-----

🔍 Observability: Express | Nitro

stream pipeline with 5 transform steps (1MB)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Express1.577s (+0.6%)2.010s (~)0.012s (-3.4%)2.025s (~)0.448s301.00x
🐘 PostgresExpress1.607s (+1.4%)2.039s (+1.7%)0.004s (-5.7% 🟢)2.057s (+1.6%)0.450s301.02x
💻 LocalNitro1.609s (+11.9% 🔺)2.010s (~)0.013s (-24.2% 🟢)2.026s (~)0.417s301.02x
🐘 PostgresNext.js (Turbopack)1.638s (-8.2% 🟢)2.011s (~)0.005s (~)2.027s (~)0.389s301.04x
🐘 PostgresNitro1.645s (+4.2%)2.003s (~)0.005s (-5.6% 🟢)2.027s (~)0.382s301.04x
💻 LocalNext.js (Turbopack)1.676s (-4.2%)2.009s (~)0.016s (+26.1% 🔺)2.029s (~)0.353s301.06x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro7.003s (-2.3%)9.052s (+4.5%)0.528s (+122.5% 🔺)10.057s (+6.9% 🔺)3.054s61.00x
▲ VercelExpress8.055s (+26.2% 🔺)9.391s (+20.3% 🔺)0.160s (-10.6% 🟢)10.189s (+20.5% 🔺)2.134s61.15x
▲ VercelNext.js (Turbopack)⚠️missing-----

🔍 Observability: Nitro | Express

10 parallel streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.803s (+3.9%)1.126s (+7.4% 🔺)0.000s (+3.8%)1.140s (+4.3%)0.337s531.00x
🐘 PostgresNext.js (Turbopack)0.886s (-13.1% 🟢)1.277s (-12.7% 🟢)0.000s (-100.0% 🟢)1.291s (-12.3% 🟢)0.405s471.10x
🐘 PostgresExpress0.935s (+22.4% 🔺)1.221s (+19.1% 🔺)0.000s (-70.9% 🟢)1.236s (+17.2% 🔺)0.302s491.16x
💻 LocalNitro1.486s (+38.2% 🔺)2.015s (+9.7% 🔺)0.000s (-72.5% 🟢)2.017s (+9.6% 🔺)0.531s301.85x
💻 LocalExpress1.517s (+11.3% 🔺)2.014s (~)0.001s (+200.0% 🔺)2.016s (~)0.500s301.89x
💻 LocalNext.js (Turbopack)1.817s (+20.1% 🔺)2.119s (+5.2% 🔺)0.000s (-42.5% 🟢)2.123s (+5.2% 🔺)0.306s292.26x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express4.404s (+45.3% 🔺)5.654s (+23.9% 🔺)0.000s (NaN%)6.083s (+20.7% 🔺)1.680s111.00x
▲ VercelNitro5.554s (+47.8% 🔺)6.749s (+25.4% 🔺)0.000s (-100.0% 🟢)7.278s (+24.2% 🔺)1.724s91.26x
▲ VercelNext.js (Turbopack)⚠️missing-----

🔍 Observability: Express | Nitro

fan-out fan-in 10 streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.723s (+11.1% 🔺)2.303s (+8.0% 🔺)0.000s (-100.0% 🟢)2.318s (+8.0% 🔺)0.595s261.00x
🐘 PostgresExpress2.026s (+25.5% 🔺)2.608s (+26.4% 🔺)0.000s (NaN%)2.621s (+25.5% 🔺)0.595s231.18x
🐘 PostgresNext.js (Turbopack)2.062s (-2.3%)2.543s (-1.7%)0.000s (-100.0% 🟢)2.551s (-1.7%)0.490s241.20x
💻 LocalExpress3.578s (+22.1% 🔺)4.225s (+15.1% 🔺)0.000s (+58.7% 🔺)4.238s (+15.4% 🔺)0.660s152.08x
💻 LocalNitro4.282s (+94.1% 🔺)4.800s (+75.0% 🔺)0.001s (+28.9% 🔺)4.806s (+74.5% 🔺)0.525s132.49x
💻 LocalNext.js (Turbopack)5.320s (+83.4% 🔺)5.755s (+71.4% 🔺)0.001s (+172.7% 🔺)5.765s (+71.4% 🔺)0.445s113.09x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express6.830s (+20.0% 🔺)7.786s (+7.7% 🔺)0.000s (NaN%)8.229s (+7.0% 🔺)1.398s81.00x
▲ VercelNitro9.006s (+71.6% 🔺)10.335s (+60.1% 🔺)0.003s (+Infinity% 🔺)10.940s (+58.0% 🔺)1.935s61.32x
▲ VercelNext.js (Turbopack)⚠️missing-----

🔍 Observability: Express | Nitro

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World🥇 Fastest FrameworkWins
💻 LocalExpress10/21
🐘 PostgresExpress12/21
▲ VercelExpress14/21
Fastest World by Framework

Winner determined by most benchmark wins

Framework🥇 Fastest WorldWins
Express🐘 Postgres18/21
Next.js (Turbopack)🐘 Postgres16/21
Nitro🐘 Postgres16/21
Column Definitions
  • Workflow Time: Runtime reported by workflow (completedAt - createdAt) - primary metric
  • TTFB: Time to First Byte - time from workflow start until first stream byte received (stream benchmarks only)
  • Slurp: Time from first byte to complete stream consumption (stream benchmarks only)
  • Wall Time: Total testbench time (trigger workflow + poll for result)
  • Overhead: Testbench overhead (Wall Time - Workflow Time)
  • Samples: Number of benchmark iterations run
  • vs Fastest: How much slower compared to the fastest configuration for this benchmark

Worlds:

  • 💻 Local: In-memory filesystem world (local development)
  • 🐘 Postgres: PostgreSQL database world (local development)
  • ▲ Vercel: Vercel production/preview deployment
  • 🌐 Turso: Community world (local development)
  • 🌐 MongoDB: Community world (local development)
  • 🌐 Redis: Community world (local development)
  • 🌐 Jazz: Community world (local development)
  • 🌐 Redis: Community world (local development)
  • 🌐 Redis + BullMQ: Community world (local development)
  • 🌐 Cloudflare: Community world (local development)
  • 🌐 MySQL: Community world (local development)
  • 🌐 Azure: Community world (local development)
  • 🌐 NATS JetStream: Community world (local development)
  • 🌐 Upstash: Community world (local development)

📋 View full workflow run


Some benchmark jobs failed:

  • Local: success
  • Postgres: success
  • Vercel: failure

Check the workflow run for details.

@github-actions

github-actionsBot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

Summary

PassedFailedSkippedTotal
✅ ▲ Vercel Production144202301672
✅ 💻 Local Development190902192128
✅ 📦 Local Production190902192128
✅ 🐘 Local Postgres189502332128
✅ 🪟 Windows15200152
✅ 📋 Other88501791064
Total8192010809272

Details by Category

✅ ▲ Vercel Production
AppPassedFailedSkipped
✅ astro125027
✅ example125027
✅ express125027
✅ fastify125027
✅ hono125027
✅ nextjs-turbopack14903
✅ nextjs-webpack14903
✅ nitro125027
✅ nuxt125027
✅ sveltekit14408
✅ vite125027
✅ 💻 Local Development
AppPassedFailedSkipped
✅ astro-stable127025
✅ express-stable127025
✅ fastify-stable127025
✅ hono-stable127025
✅ nextjs-turbopack-canary133019
✅ nextjs-turbopack-stable-lazy-discovery-disabled15200
✅ nextjs-turbopack-stable-lazy-discovery-enabled15200
✅ nextjs-webpack-canary133019
✅ nextjs-webpack-stable-lazy-discovery-disabled15200
✅ nextjs-webpack-stable-lazy-discovery-enabled15200
✅ nitro-stable127025
✅ nuxt-stable127025
✅ sveltekit-stable14606
✅ vite-stable127025
✅ 📦 Local Production
AppPassedFailedSkipped
✅ astro-stable127025
✅ express-stable127025
✅ fastify-stable127025
✅ hono-stable127025
✅ nextjs-turbopack-canary133019
✅ nextjs-turbopack-stable-lazy-discovery-disabled15200
✅ nextjs-turbopack-stable-lazy-discovery-enabled15200
✅ nextjs-webpack-canary133019
✅ nextjs-webpack-stable-lazy-discovery-disabled15200
✅ nextjs-webpack-stable-lazy-discovery-enabled15200
✅ nitro-stable127025
✅ nuxt-stable127025
✅ sveltekit-stable14606
✅ vite-stable127025
✅ 🐘 Local Postgres
AppPassedFailedSkipped
✅ astro-stable126026
✅ express-stable126026
✅ fastify-stable126026
✅ hono-stable126026
✅ nextjs-turbopack-canary132020
✅ nextjs-turbopack-stable-lazy-discovery-disabled15101
✅ nextjs-turbopack-stable-lazy-discovery-enabled15101
✅ nextjs-webpack-canary132020
✅ nextjs-webpack-stable-lazy-discovery-disabled15101
✅ nextjs-webpack-stable-lazy-discovery-enabled15101
✅ nitro-stable126026
✅ nuxt-stable126026
✅ sveltekit-stable14507
✅ vite-stable126026
✅ 🪟 Windows
AppPassedFailedSkipped
✅ nextjs-turbopack15200
✅ 📋 Other
AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable127025
✅ e2e-local-dev-tanstack-start-127025
✅ e2e-local-postgres-nest-stable126026
✅ e2e-local-postgres-tanstack-start-126026
✅ e2e-local-prod-nest-stable127025
✅ e2e-local-prod-tanstack-start-127025
✅ e2e-vercel-prod-tanstack-start125027

📋 View full workflow run

@pranaygppranaygp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean, well-scoped optimization with a clear rationale and good test coverage. The caching logic is correct: the fast path / in-flight dedup runs entirely synchronously before the first await, so concurrent first calls genuinely share one lookup; undefined is never cached, so the not-yet-listening window self-recovers; and the _getPort ?? (async () => undefined) fallback is actually a small robustness win over the previous _getPort!() (which would have thrown if the module loaded without a getPort export). I traced the three test scenarios against the exact logic and they pass.

Two non-blocking notes inline. Plus one drive-by that's out of this diff's scope: the comment at workflow.ts:147-150 still describes the cache as globalThis.__wkf_getPort, which hasn't matched the implementation (module-level _getPort, now _cachedPort) for a while — since this PR is exactly about that caching, it'd be a natural place to freshen that comment.

Comment on lines +56 to +62
.then((port) => {
// Only cache a concrete port. A transient `undefined` (e.g. the server is
// not listening yet on the very first replay) must not poison the cache —
// leaving it unset lets the next call retry discovery.
if (typeof port === 'number') {
_cachedPort = port;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth stating the core assumption explicitly: this caches the first concrete port for the whole process and never re-resolves. The previous per-replay getPort() had a (theoretical) self-healing property — if one call resolved the wrong port, a later replay could correct it; after this change the first concrete value is locked in.

In practice this is almost certainly fine: the runtime only runs inside the already-listening dev-server process, and getAllPorts() is documented as returning a deterministic order, so repeated calls return the same [0] anyway. The one case I'd sanity-check is multi-listener processes (e.g. node --inspect adds a :9229 listener): getPortLazy resolves via getPort() (first listening port), not the probed getWorkflowPort(), so if a non-dev-server socket ever sorts first, that value is now pinned for the process rather than re-evaluated each replay. That's a pre-existing getPort weakness, not something this PR introduces — just flagging that caching removes the per-call escape hatch. Non-blocking.

* hide it from bundlers), which also defeats module mocking, so injection is
* the only deterministic way to exercise the caching contract.
*/
export function setPortResolverForTesting(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional / FYI: setPortResolverForTesting and resetPortCacheForTesting are exported from the production module, so they ship in the built package. They're not re-exported from any public barrel (only reachable via a deep ./runtime/get-port-lazy.js import) and the JSDoc explains why injection is the only deterministic seam, so I think this is the right tradeoff — just noting the test-only surface is now part of the shipped output.

Minor latent footgun in the seam (not hit by the current tests, which all fully await): if a future test calls getPortLazy() without awaiting it, resetPortCacheForTesting() in afterEach clears _inFlight but can't cancel the already-scheduled .then, so a late resolution could set _cachedPort after the reset and bleed into the next test. A one-line note on these helpers that callers must let in-flight lookups settle before resetting would head that off.

Address PR review nits on the local port cache:
- Document that the first concrete port is pinned for the process and
why that is safe (runtime runs inside the listening dev server;
getAllPorts ordering is deterministic).
- Note on resetPortCacheForTesting that callers must let in-flight
lookups settle before resetting to avoid a late .then repopulating
the cache across tests.
- Fix the stale getPortLazy comment in workflow.ts that still referenced
the old globalThis.__wkf_getPort cache mechanism.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

No backport to stable for 722bb7c (AI decision).

This commit modifies packages/core/src/runtime/get-port-lazy.ts, which does not exist on stable — on stable, workflow.ts imports getPort from @workflow/utils/get-port and calls it directly rather than through a getPortLazy lazy-loader. The change builds on the main-only getPortLazy lazy-loading mechanism, so the caching optimization isn't applicable and wouldn't cherry-pick cleanly onto stable.

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

722bb7c6a20a7f255757280739d8b51661ed7792

@github-actionsgithub-actionsBot mentioned this pull request Jun 18, 2026
pranaygp added a commit that referenced this pull request Jun 18, 2026
…testing
* origin/main:
perf(core): decouple workflow VM seed/clock from startedAt (#2525)
[world-local] [core] Cache local dev server port per process (#2522)
Show pending runs as gray animated stripes in trace viewer (#2520)
[world-vercel] Route v4 event requests through global fetch (#2514)
[core] Send workflowName with step events (#2511)
Stamp run IDs on world spans (#2508)
Reject empty-string hook tokens in createHook() (#2490)
perf(core): cache compiled workflow-bundle vm.Script across replays (#2471)
perf(core): drain consumable replay events synchronously (#2473)
perf(core): lazy inline step start (save one world round-trip per step) (#2478)
@github-actionsgithub-actionsBot mentioned this pull request Jun 22, 2026
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

@VaguelySerious@pranaygp