perf: print --version without loading the command graph - #1590
productdevbook wants to merge 1 commit into
Conversation
`nuxt --version` imported dist/index.mjs (citty, every command stub, consola, clack) only to print the version from package.json, which made it 21% slower than v3.37.0. Answer it in the bin before that import, matching citty's own rule: `--version` or `-v` as the only argument. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
commit: |
CLI benchmark
Full report
|
| Setting | Value |
|---|---|
| Baseline | ref:f140924fb88992febb831316ac01bce275609336 (v4.0.0-alpha.1) |
| Head | local packages/nuxt-cli at d85c768 (v4.0.0-alpha.1) |
| Node | v24.21.0 |
| OS | Linux 6.17.0 (kernel 6.17.0-1022-azure) |
| CPU | AMD EPYC 9V74 80-Core Processor x 4 |
| Memory | 15.6 GB |
| Load average at start | 0.72, 0.22, 0.08 |
| Run started | 2026-10-03T16:49:50.001Z |
Cold CLI startup
Median of 15 interleaved runs per command, one warmup discarded.
| Command | baseline v4.0.0-alpha.1 median | head v4.0.0-alpha.1 median | Delta | baseline v4.0.0-alpha.1 min / p95 | head v4.0.0-alpha.1 min / p95 |
|---|---|---|---|---|---|
nuxt --version |
54 ms | 29 ms | -47.3% | 51 ms / 56 ms | 26 ms / 32 ms |
nuxt --version (first output byte) |
51 ms | 26 ms | -49.1% | 48 ms / 52 ms | 24 ms / 29 ms |
nuxt --help |
106 ms | 108 ms | +1.1% | 102 ms / 164 ms | 104 ms / 111 ms |
nuxt --help (first output byte) |
102 ms | 103 ms | +1.2% | 98 ms / 160 ms | 100 ms / 106 ms |
nuxt dev --help |
83 ms | 83 ms | -0.3% | 78 ms / 86 ms | 80 ms / 85 ms |
nuxt dev --help (first output byte) |
78 ms | 79 ms | +0.4% | 74 ms / 82 ms | 76 ms / 81 ms |
nuxt <unknown-command> (no-op) |
116 ms | 116 ms | +0.1% | 113 ms / 135 ms | 114 ms / 119 ms |
nuxt <unknown-command> (no-op) (first output byte) |
111 ms | 111 ms | -0.1% | 107 ms / 115 ms | 109 ms / 114 ms |
Module load cost
Counted with a module.registerHooks load hook, compile cache disabled. Counts every JS module actually evaluated on that code path (native addons excluded). Built-ins loaded after bootstrap are counted separately, including the internal modules they load.
| Command | baseline v4.0.0-alpha.1 modules | head v4.0.0-alpha.1 modules | Delta | baseline v4.0.0-alpha.1 source bytes | head v4.0.0-alpha.1 source bytes | Delta | baseline v4.0.0-alpha.1 built-ins | head v4.0.0-alpha.1 built-ins | Delta |
|---|---|---|---|---|---|---|---|---|---|
nuxt --version |
35 | 5 | -85.7% | 297.8 kB | 5.3 kB | -98.2% | 27 | 1 | -96.3% |
nuxt --help |
134 | 134 | 0.0% | 839.9 kB | 840.3 kB | +0.0% | 87 | 87 | 0.0% |
nuxt dev --help |
63 | 63 | 0.0% | 453.0 kB | 453.3 kB | +0.1% | 87 | 87 | 0.0% |
Install footprint and published tarball
Each version installed on its own into an empty project with nothing but @nuxt/cli as a dependency, so the tree is exactly the CLI and its transitive dependencies. npm cache is warm and the registry is only consulted for metadata, so install wall time is indicative, not a network benchmark.
| Metric | baseline v4.0.0-alpha.1 | head v4.0.0-alpha.1 | Delta |
|---|---|---|---|
Direct dependencies of @nuxt/cli |
23 | 23 | 0.0% |
| Packages in the installed tree (unique name@version) | 39 | 39 | 0.0% |
| Unique package names | 39 | 39 | 0.0% |
| Package directories on disk (cross-check) | 32 | 32 | 0.0% |
Installed node_modules on disk |
2.43 MB | 2.43 MB | +0.0% |
| Installed files | 434 | 434 | 0.0% |
| Install wall time (warm npm cache, median of 3) | 981 ms | 976 ms | -0.5% |
| Published tarball (packed) | 239.6 kB | 239.7 kB | +0.1% |
| Published tarball (unpacked) | 775.2 kB | 775.5 kB | +0.0% |
| Files in tarball | 99 | 99 | 0.0% |
Interleaved runs on a shared runner: trust the deltas, not the absolute timings. The dev, restart and build suites run locally via pnpm bench:cli.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1590 +/- ##
=======================================
Coverage ? 83.39%
=======================================
Files ? 177
Lines ? 11306
Branches ? 3246
=======================================
Hits ? 9429
Misses ? 1581
Partials ? 296 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughWhen the only argument is Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~5 minutes Merge Risk: ⚪ Minimal · up to The version-only shortcut preserves the existing CLI output, while other invocations retain the command-runner path. No actionable merge-blocking risk remains. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🧪 Generate unit tests (beta)
🛠️ Fix failing CI checks 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
nuxt --versionimporteddist/index.mjs(citty, every command stub, consola, clack) only to print the version frompackage.json. This answers it inbin/nuxi.mjsbefore that import, using citty's own rule:--versionor-vas the only argument. Any other argument list (--version extra,dev --version,--profile --version) still goes through citty unchanged.Benchmark
pnpm bench:cli --baseline ref:origin/main --fixture playground --suite startup --suite modules --startup-reps 21, run on an M3 Max with Node 24.21 and interleaved runs. The baseline ismainat f140924.nuxt --version--help,dev --helpand unknown commands load the same modules as before (134 / 63). Their timings stay within ±4%, which is run-to-run noise.Checks
eslint packages/nuxt-cli/bin/nuxi.mjspassesvitest runoncompile-cache,dev-boot,startup-checksande2e/commandspasses: 33 passed, 10 todo--versionand-vprint4.0.0-alpha.1, and--version extrastill shows usage🤖 Generated with Claude Code