perf(core): cache port discovery for step invocations#2996
Conversation
Signed-off-by: Joey Hotz <joeyhotz1@gmail.com>
🦋 Changeset detectedLatest commit: f4e31ad The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
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/workflow |
|
@joeyhotz is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
|
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. |
|
Great catch! |
…worlds (#2996) Signed-off-by: Joey Hotz <joeyhotz1@gmail.com>
|
Backport PR opened against |
|
@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. |
|
@joeyhotz Anything landing on 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. |
Description
Reuse the process-level
getPortLazy()cache from #2522 for self-hosted step invocations. The step handler currently callsgetPort()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
undefinedresults retry. The existing Vercel branch still skips discovery.How did you test your changes?
pnpm --filter @workflow/core test(1,483 passed; 3 expected failures)pnpm --filter @workflow/core typecheckpnpm turbo build --filter='@workflow/core...'PR Checklist - Required to merge
pnpm changesetwas run to create a changelog for this PRgit commit --signoff)@vercel/workflowin a comment once PR ready and checklist complete