Skip to content

perf(core): cache port discovery for step invocations#2996

Merged
VaguelySerious merged 1 commit into
vercel:mainfrom
joeyhotz:joeyhotz/cache-step-port-discovery
Jul 18, 2026
Merged

perf(core): cache port discovery for step invocations#2996
VaguelySerious merged 1 commit into
vercel:mainfrom
joeyhotz:joeyhotz/cache-step-port-discovery

Conversation

@joeyhotz

@joeyhotz joeyhotz commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Description

Reuse the process-level getPortLazy() cache from #2522 for self-hosted step invocations. The step handler currently calls getPort() for every step; in a production burst profile, process.report.getReport() beneath that lookup accounted for 83% of peak wall samples.

This is safe because the listening port is stable for the process lifetime, only concrete ports are cached, concurrent first calls are deduplicated, and undefined results retry. The existing Vercel branch still skips discovery.

How did you test your changes?

  • Added a regression test proving two step invocations share one port lookup.
  • pnpm --filter @workflow/core test (1,483 passed; 3 expected failures)
  • pnpm --filter @workflow/core typecheck
  • pnpm turbo build --filter='@workflow/core...'
  • Biome check on the changed TypeScript files

PR Checklist - Required to merge

  • 📦 pnpm changeset was run to create a changelog for this PR
    • correct bump (patch for bug fixes, minor for new features, major for breaking changes)
    • only changed packages included
  • 🔒 DCO sign-off passes (run git commit --signoff)
  • 📝 Ping @vercel/workflow in a comment once PR ready and checklist complete

Signed-off-by: Joey Hotz <joeyhotz1@gmail.com>
@joeyhotz
joeyhotz requested review from a team and ijjk as code owners July 18, 2026 09:01
@changeset-bot

changeset-bot Bot commented Jul 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f4e31ad

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

This PR includes changesets to release 16 packages
Name Type
@workflow/core Patch
@workflow/builders Patch
@workflow/cli Patch
@workflow/next Patch
@workflow/nitro Patch
@workflow/vitest Patch
@workflow/web-shared Patch
@workflow/web Patch
workflow Patch
@workflow/world-testing Patch
@workflow/astro Patch
@workflow/nest Patch
@workflow/nuxt Patch
@workflow/rollup Patch
@workflow/sveltekit Patch
@workflow/vite Patch

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

@joeyhotz

Copy link
Copy Markdown
Contributor Author

@vercel/workflow

@vercel

vercel Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

@joeyhotz is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@joeyhotz

joeyhotz commented Jul 18, 2026

Copy link
Copy Markdown
Contributor Author

Wow guys I'm testing this with a patch, I'm getting huge performance improvements for burst tests I'm doing. Before it was causing requests to not be served (I assume hogged too much of the event loop), but now it doesn't cause requests to not be served, and also goes through the queue looooads faster.

@VaguelySerious

Copy link
Copy Markdown
Member

Great catch!

@VaguelySerious
VaguelySerious merged commit d8071bb into vercel:main Jul 18, 2026
65 of 102 checks passed
github-actions Bot added a commit that referenced this pull request Jul 18, 2026
…worlds (#2996)

Signed-off-by: Joey Hotz <joeyhotz1@gmail.com>
@github-actions

Copy link
Copy Markdown
Contributor

Backport PR opened against stable: #2997. Merge conflicts were resolved by AI — please review carefully. (backport job run)

@joeyhotz

joeyhotz commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

@VaguelySerious hope it's okay to ask a question, as you know I got a few PRs through recently into the v5 beta, are the beta versions generally stable and usable in production? Or should I avoid? When something gets merged into main, does it instantly increment a version and useable? Honestly these are my first sets of OSS contributions.

@VaguelySerious

Copy link
Copy Markdown
Member

@joeyhotz Anything landing on main will be in a beta release within ~1 week usually, as we do some internal testing first. Some of these changes then get backported to stable after testing, which then gets released ~1-2 weeks later too.

We're hoping to release v5 beta as a stable release soon (weeks?) after we improve performance a bit more. If you pin your prod to the current latest beta release after testing it in preview/staging for a bit, it's unlikely you'll have any negative surprises.

VaguelySerious added a commit that referenced this pull request Jul 20, 2026
…#2997)

Co-authored-by: Joey Hotz <joeyhotz1@gmail.com>
Signed-off-by: Joey Hotz <joeyhotz1@gmail.com>
Co-authored-by: Peter Wielander <peter.wielander@vercel.com>
@github-actions github-actions Bot mentioned this pull request Jul 20, 2026
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.

2 participants