Repository navigation
Make vb start ~1.6x faster - #793
Open
NicolasMontone wants to merge 2 commits into
Open
NicolasMontone wants to merge 2 commits into
NicolasMontone wants to merge 2 commits into
Conversation
…/oidc only when needed Every vb command loaded 386 modules (2.3 MB) before doing anything: zod (94 files), jose (129), @vercel/oidc and the execa it pulls in, the board server. About 70-90 ms of every command was the CLI loading itself. - dist/cli.mjs is its own build, one file with its dependencies inlined: a command loads 10 modules (the file and node builtins). The SDK's build is unchanged. - decode-jwt.ts reads a token's claims the way jose's decodeJwt does, so reading an expiry or owner doesn't load jose. Signing and verifying still use jose, which those paths already import lazily. - @vercel/oidc loads on the Vercel credential paths that use it. The helper is named oidcModule so sandboxHeaders' local oidc can't shadow it. Measured with both builds alternating in one process, five commands (help, whoami, read, read --label, post) against a local board, same output for each: 1.345x on an M-series Mac (read: 133 -> 98 ms), ~1.5x on an 8-vCPU sandbox. The bundle alone is 1.28x; the two lazy loads add the rest. Found by a 12-agent swarm on Vercel Board (vercel-labs/board-swarm, vb-startup scenario); this patch is the verified wins, recombined by hand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Node's compile cache On top of the single-file CLI: - dist/cli.mjs is a 4-line launcher that calls module.enableCompileCache() and imports cli-main.mjs, so every command after the first loads V8's cached bytecode instead of parsing the CLI again. It has to be its own file: the cache covers only what loads after the call. Node skips it with NODE_DISABLE_COMPILE_CACHE. - The CLI's build splits again: what a command reaches only through import() is a chunk, parsed when that command needs it. The entry a command parses shrinks from 2.2 MB to 620 KB, minified. - @vercel/oidc stays in node_modules (it's a declared dependency, reached only through a dynamic import), so it isn't in the bundle at all. Against the single-file build, five commands, both builds alternating in one process: 1.21x on an M-series Mac, 1.34x on an 8-vCPU sandbox. A first run with an empty cache is faster too (~100 -> ~85 ms for --help). Against main, vb read goes from 133 to 83 ms here. All 1,714 tests pass. Found by 100 DeepSeek agents on Vercel Board (vercel-labs/board-swarm, vb-startup scenario), measured by 16 benchmark runners taking the agents' patches as board tasks; this is experiment #534's patch as it was. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
[by v0 factory / NOT VERCEL AGENT]
Looks good to me, nothing blocking.
Checked on a Linux sandbox (Node 24):
- Built 3 times in a row:
dist/cli.mjsandcli-main.mjssurvive the first config'sclean: trueevery time, so the two builds don't race. vb --helpaverages ~94ms on this branch vs ~212ms on main (10 runs each, warm compile cache), about 2.3x.whoamiagainst a real board still resolves its login.- The only bare package the minified CLI still imports at runtime is
@vercel/oidc(a declared dependency, dynamic import only). Everything else isnode:builtins. enableCompileCacheis fine as a named import, sinceenginesis>=22.18.- The
decodeJwtreplacement matches jose's checks for what board reads it for (exp,owner_id), and signature verification still goes through jose.
Small things, none blocking: CLI stack traces are minified now, as the PR body says. If bug reports start coming from vb, sourcemap: true on just the CLI config would keep them readable for a few hundred KB more.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
every vb command loaded 386 modules (zod, jose, @vercel/oidc + execa, the board server) before doing anything, ~70-90ms of every call. agents call vb thousands of times so it adds up
this takes `vb read` from 133ms to 83ms on my mac (~1.6x), more on sandboxes
• the cli is its own build: deps inlined, lazy parts split into chunks, minified
• `dist/cli.mjs` is a tiny launcher that turns on node's compile cache, so every command after the first skips compiling (`NODE_DISABLE_COMPILE_CACHE` turns it off)
• no jose at startup (a small `decodeJwt` for reading claims) and @vercel/oidc only loads on the vercel credential paths
tradeoffs: dist grows ~2mb since the cli carries its own copy of its deps, and cli stack traces are minified. the sdk build is untouched, and `vercel board` (cli-embedded) doesn't get faster
found by a swarm on board (board-swarm's `vb-startup` scenario: 12 agents, then 100 deepseeks with 16 benchmark runners taking patches as board tasks), verified wins recombined by hand. a verifier caught a shadowing bug in the first lazy-oidc attempt that all the tests missed, that's why the helper is `oidcModule`
tested: `pnpm check` (1715 tests), packed + npm installed it and ran serve/whoami/post/tasks/read/schedule/inspector against a local board, and the vercel login path gives the same output as main
🤖 Generated with Claude Code