Skip to content

perf(router-core): reduce empty location pipeline work - #8310

Open
schiller-manuel wants to merge 1 commit into
mainfrom
optimize-link-1
Open

perf(router-core): reduce empty location pipeline work#8310
schiller-manuel wants to merge 1 commit into
mainfrom
optimize-link-1

Conversation

@schiller-manuel

@schiller-manuel schiller-manuel commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Combine object-form parameter merges into one native call. Allocate a search middleware pipeline only when it is needed, and reuse the existing empty client search value. Preserve callback and structural-sharing behavior.

React Link rendering benchmark, measured separately for this commit and its parent using exact production builds:

  • Workload: benchmarks/client-nav/scenarios/links/react/speed.bench.ts (200 persistent Links, eight navigations per measured batch).
  • Apple M4, Node 24.20.0, Vitest 4.1.4, NODE_ENV=production.
  • 4 fresh parent processes and 8 fresh processes for this commit, each with warmupIterations=50 and time=10000 ms; counterbalanced run order.
  • Parent mean times (ms): 4.4180, 4.0844, 4.1333, 4.2867.
  • This commit mean times (ms): 3.9412, 3.8998, 3.8950, 4.2674, 4.0423, 3.8793, 3.9043, 4.1120.
  • Median run means: 4.2100 -> 3.9228 ms.
  • Incremental effect: 6.82% less time; throughput change +7.32%.
  • Largest within-run RME for this revision: 1.22%.

Incremental minimal/full React gzip impact: +44/+49 bytes. Benchmark sources and commit implementation trees are unchanged.

🎯 Changes

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with the relevant test commands, or tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Performance

    • Improved navigation location-building efficiency for object-form path parameters.
    • Reduced overhead when no search middleware is configured.
  • Bug Fixes

    • Preserved shared empty search state when clearing an already-empty search.
    • Corrected static parameter handling to avoid repeated getter evaluation.
    • Preserved existing paths when retaining current route parameters.

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: a327373f-68cb-43a2-9662-ae9e019de97d

📥 Commits

Reviewing files that changed from the base of the PR and between adaa9ec and 522e421.

📒 Files selected for processing (1)
  • packages/router-core/src/router.ts

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


📝 Walkthrough

Walkthrough

The router reduces location-building overhead by avoiding unused search middleware arrays and unnecessary functional updates for object-form parameters. Tests cover empty search sharing and parameter getter behavior. A patch changeset records the update.

Changes

Location building

Layer / File(s) Summary
Optimize location resolution
packages/router-core/src/router.ts, .changeset/slick-forks-beam.md
Search middleware allocation is lazy. Empty middleware pipelines use direct search handling. Object-form parameters merge directly without a functional update.
Validate location behavior
packages/router-core/tests/build-location.test.ts
Tests verify empty search structural sharing and single evaluation of parameter getters.

Priority: ➖ Normal

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

Suggested reviewers: sheraff, nstepien

Merge Risk: ⚪ Minimal · up to 522e4

The router now avoids unnecessary middleware allocation and parameter updates while preserving tested location-building behavior. No concrete merge-blocking risk is identified.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes a detailed summary and benchmark results, but the required Changes section still contains the template placeholder. All checklist items and release-impact options remain unche… Replace the Changes placeholder with a clear change description. Mark the applicable checklist items after verification. Select the published-code release-impact option and confirm the generated changeset, or explain why the alternative app…
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary performance change: reducing empty location pipeline work in router-core. It is concise and specific.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description includes a detailed summary and benchmark results, but the required Changes section still contains the template placeholder. All checklist items and release-impact options remain unchecked, including the changeset confirmation for a published-code change.

Resolution

Replace the Changes placeholder with a clear change description. Mark the applicable checklist items after verification. Select the published-code release-impact option and confirm the generated changeset, or explain why the alternative applies.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch optimize-link-1

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.

@nx-cloud

nx-cloud Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 522e421

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 11m 31s View ↗

☁️ Nx Cloud last updated this comment at 2026-09-10 21:40:59 UTC

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

1 package(s) bumped directly, 22 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/router-core 1.171.29 → 1.171.30 Changeset
@tanstack/react-router 1.170.35 → 1.170.36 Dependent
@tanstack/react-start 1.168.52 → 1.168.53 Dependent
@tanstack/react-start-client 1.168.33 → 1.168.34 Dependent
@tanstack/react-start-rsc 0.1.51 → 0.1.52 Dependent
@tanstack/react-start-server 1.167.40 → 1.167.41 Dependent
@tanstack/router-cli 1.167.35 → 1.167.36 Dependent
@tanstack/router-generator 1.167.35 → 1.167.36 Dependent
@tanstack/router-plugin 1.168.37 → 1.168.38 Dependent
@tanstack/router-vite-plugin 1.167.37 → 1.167.38 Dependent
@tanstack/solid-router 1.170.33 → 1.170.34 Dependent
@tanstack/solid-start 1.168.50 → 1.168.51 Dependent
@tanstack/solid-start-client 1.168.32 → 1.168.33 Dependent
@tanstack/solid-start-server 1.167.39 → 1.167.40 Dependent
@tanstack/start-client-core 1.170.29 → 1.170.30 Dependent
@tanstack/start-plugin-core 1.171.42 → 1.171.43 Dependent
@tanstack/start-server-core 1.169.34 → 1.169.35 Dependent
@tanstack/start-static-server-functions 1.167.34 → 1.167.35 Dependent
@tanstack/start-storage-context 1.167.31 → 1.167.32 Dependent
@tanstack/vue-router 1.170.32 → 1.170.33 Dependent
@tanstack/vue-start 1.168.49 → 1.168.50 Dependent
@tanstack/vue-start-client 1.167.35 → 1.167.36 Dependent
@tanstack/vue-start-server 1.167.39 → 1.167.40 Dependent

@pkg-pr-new

pkg-pr-new Bot commented Sep 9, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@8310

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@8310

@tanstack/eslint-plugin-start

npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@8310

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@8310

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/@tanstack/nitro-v2-vite-plugin@8310

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@8310

@tanstack/react-router-devtools

npm i https://pkg.pr.new/@tanstack/react-router-devtools@8310

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@8310

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@8310

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@8310

@tanstack/react-start-rsc

npm i https://pkg.pr.new/@tanstack/react-start-rsc@8310

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@8310

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@8310

@tanstack/router-core

npm i https://pkg.pr.new/@tanstack/router-core@8310

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@8310

@tanstack/router-devtools-core

npm i https://pkg.pr.new/@tanstack/router-devtools-core@8310

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@8310

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@8310

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@8310

@tanstack/router-utils

npm i https://pkg.pr.new/@tanstack/router-utils@8310

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@8310

@tanstack/solid-router

npm i https://pkg.pr.new/@tanstack/solid-router@8310

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/@tanstack/solid-router-devtools@8310

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@8310

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@8310

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@8310

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@8310

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@8310

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@8310

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@8310

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@8310

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/@tanstack/start-static-server-functions@8310

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@8310

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@8310

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@8310

@tanstack/vue-router

npm i https://pkg.pr.new/@tanstack/vue-router@8310

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/@tanstack/vue-router-devtools@8310

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@8310

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@8310

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@8310

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@8310

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@8310

commit: 522e421

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

  • Commit: 93f903334031
  • Measured at: 2026-09-10T21:17:50.010Z
  • Baseline source: history:6494e75362ff
  • Dashboard: bundle-size history

The following scenarios have bundle-size changes compared with the baseline:

Scenario Current (gzip) Initial (gzip) Raw Brotli Trend
react-router.minimal 84.0 KiB
+51 B
83.9 KiB
+46 B
262.5 KiB
+161 B
73.2 KiB
+21 B
▁▁███████▄▄▆
react-router.full 87.5 KiB
+52 B
87.4 KiB
+54 B
274.2 KiB
+161 B
76.2 KiB
-34 B
▁▁███████▅▅▆
solid-router.minimal 33.5 KiB
+41 B
33.4 KiB
+45 B
96.9 KiB
+161 B
30.3 KiB
-28 B
▁▁▆▆▆▇▇▇▇▇▇█
solid-router.full 38.3 KiB
+47 B
38.2 KiB
+48 B
111.5 KiB
+161 B
34.6 KiB
+78 B
▁▁▆▆▆▇▇▇▇▇▇█
vue-router.minimal 49.6 KiB
+46 B
49.5 KiB
+47 B
138.5 KiB
+161 B
44.9 KiB
+24 B
▁▂███████▁▁▂
vue-router.full 55.2 KiB
+52 B
55.1 KiB
+51 B
156.7 KiB
+161 B
49.8 KiB
+54 B
▂▂███████▁▁▂
react-start.minimal 96.9 KiB
+51 B
96.8 KiB
+50 B
304.7 KiB
+161 B
84.1 KiB
-24 B
▁▁███████▄▄▆
react-start.query-integration 104.3 KiB
+44 B
104.1 KiB
+48 B
331.2 KiB
+161 B
90.5 KiB
+125 B
▁▁███████▅▅▆
react-start.deferred-hydration 97.7 KiB
+53 B
96.8 KiB
+51 B
306.1 KiB
+161 B
84.7 KiB
-71 B
▁▁███████▄▄▆
react-start.full 100.1 KiB
+54 B
100.0 KiB
+52 B
314.5 KiB
+161 B
86.8 KiB
+47 B
▁▁███████▄▄▅
react-start.rsbuild.minimal 100.2 KiB
+43 B
100.0 KiB
+43 B
315.0 KiB
+157 B
86.5 KiB
+45 B
▁▁███████▃▃▅
react-start.rsbuild.minimal-iife 100.6 KiB
+43 B
100.4 KiB
+43 B
315.9 KiB
+157 B
86.7 KiB
-164 B
▁▁███████▃▃▅
react-start.rsbuild.full 103.5 KiB
+42 B
103.3 KiB
+42 B
325.1 KiB
+157 B
89.2 KiB
+42 B
▁▁███████▂▂▄
solid-start.minimal 46.4 KiB
+54 B
46.3 KiB
+53 B
138.0 KiB
+161 B
41.2 KiB
+38 B
▁▁▇▇▇▇▇▇▇▇▇█
solid-start.deferred-hydration 49.5 KiB
+52 B
46.3 KiB
+50 B
145.4 KiB
+161 B
44.0 KiB
+5 B
▁▁▇▇▆▇▇▇▇▇▇█
solid-start.full 51.4 KiB
+57 B
51.3 KiB
+57 B
153.4 KiB
+161 B
45.6 KiB
+73 B
▁▁▇▇▆▆▆▆▆▆▆█
vue-start.minimal 65.8 KiB
+48 B
65.6 KiB
+45 B
189.3 KiB
+161 B
58.7 KiB
+135 B
▂▂███████▁▁▂
vue-start.full 69.6 KiB
+53 B
69.5 KiB
+53 B
201.7 KiB
+161 B
61.8 KiB
+16 B
▁▁███████▁▁▃

Current gzip tracks all emitted client JS chunks. Initial gzip tracks only the entry/import graph. Trend sparkline is historical current gzip ending with this PR measurement; lower is better.

@nx-cloud nx-cloud 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.

Important

At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.

Nx Cloud has identified a possible root cause for your failed CI:

We classified this failure as an environment state issue rather than a code change. The error — a missing e2eStartDummyServer export in the compiled e2e/e2e-utils/dist/esm artifacts — points to stale build outputs unrelated to our router-core performance optimizations. No changes in this PR touch the tanstack-solid-start-e2e-basic project or the e2e utilities package.

No code changes were suggested for this issue.

Trigger a rerun:

Rerun CI

Nx Cloud View detailed reasoning on Nx Cloud ↗


🎓 Learn more about Self-Healing CI on nx.dev

@codspeed-hq

codspeed-hq Bot commented Sep 9, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 7.17%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 2 improved benchmarks
❌ 5 regressed benchmarks
✅ 173 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory mem client interrupted-navigations (solid) 384.6 KB 442.4 KB -13.08%
Memory mem client interrupted-navigations (react) 385.3 KB 442.5 KB -12.94%
Memory mem client interrupted-navigations (vue) 389.4 KB 446.4 KB -12.76%
Memory mem client navigation-churn (vue) 384.1 KB 437.7 KB -12.24%
Memory mem client navigation-churn (solid) 380.6 KB 416.8 KB -8.68%
Simulation client-links navigation loop (react) 216.8 ms 200.2 ms +8.29%
Simulation client-links navigation loop (vue) 344.7 ms 332.3 ms +3.72%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing optimize-link-1 (522e421) with main (6494e75)

Open in CodSpeed

Combine object-form parameter merges into one native call. Allocate a search middleware pipeline only when it is needed, and reuse the existing empty client search value. Preserve callback and structural-sharing behavior.

React Link rendering benchmark, measured separately for this commit
and its parent using exact production builds:
- Workload: benchmarks/client-nav/scenarios/links/react/speed.bench.ts
  (200 persistent Links, eight navigations per measured batch).
- Apple M4, Node 24.20.0, Vitest 4.1.4, NODE_ENV=production.
- 4 fresh parent processes and 8 fresh processes for this commit,
  each with warmupIterations=50 and time=10000 ms;
  counterbalanced run order.
- Parent mean times (ms): 4.4180, 4.0844, 4.1333, 4.2867.
- This commit mean times (ms): 3.9412, 3.8998, 3.8950, 4.2674, 4.0423, 3.8793, 3.9043, 4.1120.
- Median run means: 4.2100 -> 3.9228 ms.
- Incremental effect: 6.82% less time; throughput change +7.32%.
- Largest within-run RME for this revision: 1.22%.

Incremental minimal/full React gzip impact: +44/+49 bytes.
Benchmark sources and commit implementation trees are unchanged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant