Skip to content

Make vb start ~1.6x faster - #793

Open
NicolasMontone wants to merge 2 commits into
mainfrom
vb-startup-swarm
Open

NicolasMontone wants to merge 2 commits into
mainfrom
vb-startup-swarm

Conversation

@NicolasMontone

Copy link
Copy Markdown
Member

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

NicolasMontone and others added 2 commits November 21, 2026 11:19
…/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>
@vercel

vercel Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
vboard-preview-publisher Ready Ready Preview Nov 21, 2026 7:23pm UTC

@vercel vercel Bot 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.

[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.mjs and cli-main.mjs survive the first config's clean: true every time, so the two builds don't race.
  • vb --help averages ~94ms on this branch vs ~212ms on main (10 runs each, warm compile cache), about 2.3x. whoami against 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 is node: builtins.
  • enableCompileCache is fine as a named import, since engines is >=22.18.
  • The decodeJwt replacement 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

No deployments
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.

1 participant