Skip to content

test: add dev server benchmark for page route generation#34323

Merged
danielroe merged 3 commits intomainfrom
feat/pages-dev-benchmark
Feb 12, 2026
Merged

test: add dev server benchmark for page route generation#34323
danielroe merged 3 commits intomainfrom
feat/pages-dev-benchmark

Conversation

@danielroe
Copy link
Member

🔗 Linked issue

#34316

📚 Description

this adds a benchmark we can use to compare with new incremental model for route generation for #34316

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@danielroe danielroe changed the title Feat/pages dev benchmark test: add dev server lifecycle benchmark for page route generation Feb 12, 2026
@github-actions github-actions bot added the 4.x label Feb 12, 2026
@danielroe danielroe changed the title test: add dev server lifecycle benchmark for page route generation test: add dev server benchmark for page route generation Feb 12, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 12, 2026

Open in StackBlitz

@nuxt/kit

npm i https://pkg.pr.new/@nuxt/kit@34323

@nuxt/nitro-server

npm i https://pkg.pr.new/@nuxt/nitro-server@34323

nuxt

npm i https://pkg.pr.new/nuxt@34323

@nuxt/rspack-builder

npm i https://pkg.pr.new/@nuxt/rspack-builder@34323

@nuxt/schema

npm i https://pkg.pr.new/@nuxt/schema@34323

@nuxt/vite-builder

npm i https://pkg.pr.new/@nuxt/vite-builder@34323

@nuxt/webpack-builder

npm i https://pkg.pr.new/@nuxt/webpack-builder@34323

commit: 1209dab

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 12, 2026

Walkthrough

A new benchmark test file is added to packages/nuxt/test that simulates a Nuxt dev-server route-generation workflow. It defines medium and large sets of page file paths, constructs a simulator that rebuilds the route tree on every operation via generateRoutesFromFiles, and exposes coldStart, emit, addFile and removeFile operations. Vitest benches measure cold starts, emits with no FS change, file additions followed by emits (then reverted), and file removals followed by emits (then reverted).

Possibly related PRs

  • nuxt/nuxt PR 31454: Changes to generateRoutesFromFiles/getRoutePath behaviour and route sorting — directly touches the function repeatedly exercised by these benchmarks.
  • nuxt/nuxt PR 31450: Modifications to generateRoutesFromFiles usage and internals — affects the same code paths the bench repeatedly invokes.
  • nuxt/nuxt PR 34315: Adds benchmarks for route generation across datasets (small/medium/large) — similar benchmarking approach and dataset construction.
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a benchmark test for dev server page route generation performance.
Description check ✅ Passed The description is directly related to the changeset, explaining the benchmark's purpose for comparing route generation performance.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/pages-dev-benchmark

No actionable comments were generated in the recent review. 🎉


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@packages/nuxt/test/pages-dev.bench.ts`:
- Around line 62-65: The helper makeFiles creates file objects but sets
absolutePath to the relative string p (e.g. "pages/about.vue") which is
incorrect; update makeFiles to produce a real absolute path (use Node's
path.resolve or path.join with process.cwd() or the repo root) for absolutePath
so generateRoutesFromFiles and any path comparisons get proper absolute values;
ensure path is imported/required and replace the absolutePath: p assignment in
makeFiles with something like path.resolve(p) (or path.resolve(root, p)) to fix
identity/comparison issues.
- Around line 99-107: Bench callbacks are including reset calls so the timed
iterations measure both the operation and its reset (sim.addFile/
sim.removeFile), contaminating results; remove the in-bench reset calls (the
sim.removeFile(newFile) in the "add file + emit" bench and the sim.addFile(...)
reset in the "remove file + emit" bench) or move them into proper setup/teardown
hooks (Vitest bench setup/teardown or describe beforeEach/afterEach) so each
bench only measures the intended operation (use the same change for the large
app suite benches that reference mediumAppPaths/largeAppPaths).

Comment on lines +62 to +65
const makeFiles = (paths: string[]) => paths.map(p => ({
relativePath: p.replace(/^pages\//, ''),
absolutePath: p,
}))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

absolutePath is set to a relative path.

absolutePath: p assigns values like "pages/about.vue" which are not absolute paths. If generateRoutesFromFiles ever resolves or compares absolute paths (e.g. for file identity), this could produce incorrect results. For a benchmark this likely doesn't affect timing, but it's worth being aware of if results look unexpected.

🤖 Prompt for AI Agents
In `@packages/nuxt/test/pages-dev.bench.ts` around lines 62 - 65, The helper
makeFiles creates file objects but sets absolutePath to the relative string p
(e.g. "pages/about.vue") which is incorrect; update makeFiles to produce a real
absolute path (use Node's path.resolve or path.join with process.cwd() or the
repo root) for absolutePath so generateRoutesFromFiles and any path comparisons
get proper absolute values; ensure path is imported/required and replace the
absolutePath: p assignment in makeFiles with something like path.resolve(p) (or
path.resolve(root, p)) to fix identity/comparison issues.

Comment on lines +99 to +107
bench('add file + emit', () => {
sim.addFile(newFile)
sim.removeFile(newFile) // reset
})

bench('remove file + emit', () => {
sim.removeFile(mediumAppPaths[Math.floor(mediumAppPaths.length / 2)]!)
sim.addFile(mediumAppPaths[Math.floor(mediumAppPaths.length / 2)]!) // reset
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Reset operations inside bench callbacks are included in the measured time.

The removeFile (reset) call on line 101 is executed within the timed iteration, so each benchmark iteration measures "add + remove" rather than just "add + emit". Same issue on lines 105–106 for the remove benchmark. This contaminates the measurements, making add and remove benchmarks appear roughly equivalent and ~2× their true cost.

Vitest bench supports setup/teardown hooks (or you could use the beforeEach/afterEach pattern at the describe level). Alternatively, since the simulator is stateless (it rebuilds from scratch each call), the reset calls are actually no-ops in terms of mutating allFilesaddFile/removeFile don't mutate filePaths or allFiles, they create new arrays. So the resets are unnecessary and just add noise.

Proposed fix — remove unnecessary resets
   bench('add file + emit', () => {
     sim.addFile(newFile)
-    sim.removeFile(newFile) // reset
   })

   bench('remove file + emit', () => {
     sim.removeFile(mediumAppPaths[Math.floor(mediumAppPaths.length / 2)]!)
-    sim.addFile(mediumAppPaths[Math.floor(mediumAppPaths.length / 2)]!) // reset
   })

And similarly for the large app suite (lines 122–130).

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
bench('add file + emit', () => {
sim.addFile(newFile)
sim.removeFile(newFile) // reset
})
bench('remove file + emit', () => {
sim.removeFile(mediumAppPaths[Math.floor(mediumAppPaths.length / 2)]!)
sim.addFile(mediumAppPaths[Math.floor(mediumAppPaths.length / 2)]!) // reset
})
bench('add file + emit', () => {
sim.addFile(newFile)
})
bench('remove file + emit', () => {
sim.removeFile(mediumAppPaths[Math.floor(mediumAppPaths.length / 2)]!)
})
🤖 Prompt for AI Agents
In `@packages/nuxt/test/pages-dev.bench.ts` around lines 99 - 107, Bench callbacks
are including reset calls so the timed iterations measure both the operation and
its reset (sim.addFile/ sim.removeFile), contaminating results; remove the
in-bench reset calls (the sim.removeFile(newFile) in the "add file + emit" bench
and the sim.addFile(...) reset in the "remove file + emit" bench) or move them
into proper setup/teardown hooks (Vitest bench setup/teardown or describe
beforeEach/afterEach) so each bench only measures the intended operation (use
the same change for the large app suite benches that reference
mediumAppPaths/largeAppPaths).

@danielroe danielroe enabled auto-merge February 12, 2026 15:46
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 12, 2026

Merging this PR will not alter performance

✅ 10 untouched benchmarks
🆕 11 new benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
🆕 medium app (52 files) N/A 1.8 ms N/A
🆕 large app (202 files) N/A 5.1 ms N/A
🆕 small app (10 files) N/A 301.3 µs N/A
🆕 remove file + emit - large (202 files) N/A 12.5 ms N/A
🆕 add file + emit - medium (52 files) N/A 3.5 ms N/A
🆕 emit (no fs change) - large (202 files) N/A 6 ms N/A
🆕 cold start (initial build + emit) - medium (52 files) N/A 1.8 ms N/A
🆕 cold start (initial build + emit) - large (202 files) N/A 6 ms N/A
🆕 add file + emit - large (202 files) N/A 12.5 ms N/A
🆕 emit (no fs change) - medium (52 files) N/A 1.3 ms N/A
🆕 remove file + emit - medium (52 files) N/A 3 ms N/A

Comparing feat/pages-dev-benchmark (1209dab) with main (552ac64)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (b3830d3) during the generation of this report, so 552ac64 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@danielroe danielroe added this pull request to the merge queue Feb 12, 2026
Merged via the queue into main with commit 4be6ef1 Feb 12, 2026
56 checks passed
@danielroe danielroe deleted the feat/pages-dev-benchmark branch February 12, 2026 17:33
@github-actions github-actions bot mentioned this pull request Feb 12, 2026
@github-actions github-actions bot mentioned this pull request Feb 24, 2026
@github-actions github-actions bot mentioned this pull request Mar 8, 2026
This was referenced Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant