Skip to content

perf(navigation): skip unused leaf sibling searches - #3845

Open
onmax wants to merge 2 commits into
nuxt:mainfrom
onmax:perf/navigation-sibling-scan
Open

perf(navigation): skip unused leaf sibling searches#3845
onmax wants to merge 2 commits into
nuxt:mainfrom
onmax:perf/navigation-sibling-scan

Conversation

@onmax

@onmaxonmax commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🔗 Linked issue

No linked issue or discussion. Reproduction below.

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Navigation scanned earlier siblings when adding leaf pages. Skip the unused root lookup and check only newly appended children for placeholders. Once an array contains a placeholder, keep the original lookup and merge behavior.

 ordinary root page
- search siblings, discard the result
nested leaf page
- search all earlier siblings+ skip lookup while no placeholders exist

For 5,000 pages, the pinned fixtures count these find predicate calls:

PagesBeforeAfterRepro
Flat root pages12,497,5000Before · After
Pages under /guide12,502,4994,999Before · After

Index merging and caller order stay unchanged. Parent lookups and child arrays that have contained placeholders retain their existing cost.

Navigation generation time for the exact PR base and head, on Node 24.19.0 / Linux / AMD EPYC 7452. Medians of 25 samples after five warmups, alternating before and after. Brackets show the middle 50% of samples.

LayoutPagesBefore, msAfter, ms
Flat root pages1,00018.9 [13.7, 25.3]4.5 [2.9, 6.4]
Flat root pages5,000457.0 [360.7, 635.5]25.5 [22.2, 30.9]
Under /guide1,00031.8 [23.2, 37.0]10.8 [7.6, 14.5]
Under /guide5,000540.7 [457.5, 634.2]40.5 [33.7, 47.0]

Both versions produce equal trees for each input. Timings exclude SQL, input cloning, and setup. This shared machine has variable load; these are local navigation timings, not page-load measurements. Benchmark script, command, and raw samples.

Copy and run both comparisons with Node 24.19.0 and Corepack
forreproin nuxt-content-navigation-scan nuxt-content-nested-navigation;do
(
set -e
git clone --depth 1 --filter=blob:none --sparse --branch "repro/$repro" https://github.com/onmax/repros.git "$repro-repro"cd"$repro-repro"
git sparse-checkout set"$repro""$repro-fix"cd"$repro"
corepack pnpm install --frozen-lockfile --ignore-scripts
corepack pnpm verify
cd"../$repro-fix"
corepack pnpm install --frozen-lockfile --ignore-scripts
corepack pnpm verify
) ||exit 1
done

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Documentation: not applicable; public navigation behavior is unchanged.

@vercel

vercelBot commented Sep 4, 2026

Copy link
Copy Markdown

@onmax is attempting to deploy a commit to the Nuxt Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitaiBot commented Sep 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: d198ddcd-9426-4a86-a862-c51092ddf6c4

📥 Commits

Reviewing files that changed from the base of the PR and between dd8c61f and d999720.

📒 Files selected for processing (2)
  • src/runtime/internal/navigation.ts
  • test/unit/generateNavigationTree.test.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

generateNavigationTree now performs duplicate-link lookup only for index content. Ordinary first-level pages are appended directly. A unit test covers 100 ordinary root pages, verifies the generated tree, and confirms that no sibling searches occur.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk:⚪ Minimal · up to d9997

Navigation generation avoids unused root-page sibling searches while preserving index merging, placeholder behavior, and navigation ordering. No current merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Docstring Coverage✅ PassedDocstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
Title check✅ PassedThe title clearly summarizes the main performance change: skipping unnecessary leaf sibling searches during navigation generation.
Description check✅ PassedThe description directly explains the navigation performance enhancement, its behavior, benchmark results, and test coverage.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@pkg-pr-new

pkg-pr-newBot commented Sep 4, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@nuxt/content@3845

commit: d999720

@onmaxonmax changed the title perf(navigation): skip unused sibling searchperf(navigation): skip unused leaf sibling searchesSep 5, 2026
Sign up for freeto 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

@onmax