Skip to content

perf(router-core): reuse idle match batch logic for fewer bytes - #8022

Closed
Sheraff wants to merge 2 commits into
mainfrom
perf-router-core-reuse-idle-match-batch
Closed

perf(router-core): reuse idle match batch logic for fewer bytes#8022
Sheraff wants to merge 2 commits into
mainfrom
perf-router-core-reuse-idle-match-batch

Conversation

@Sheraff

@Sheraff Sheraff commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Performance

    • Reduced package size by reusing match update batching logic.
    • Improved efficiency when restoring navigation state and hydrating the application.
  • Bug Fixes

    • Improved consistency when updating loading status and resolved location during refresh rollback and hydration.

@nx-cloud

nx-cloud Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit b37cab6

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ❌ Failed 11m 13s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 2m 12s View ↗

☁️ Nx Cloud last updated this comment at 2026-08-09 21:05:16 UTC

@github-actions

github-actions Bot commented Aug 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.21 → 1.171.22 Changeset
@tanstack/react-router 1.170.25 → 1.170.26 Dependent
@tanstack/react-start 1.168.42 → 1.168.43 Dependent
@tanstack/react-start-client 1.168.23 → 1.168.24 Dependent
@tanstack/react-start-rsc 0.1.41 → 0.1.42 Dependent
@tanstack/react-start-server 1.167.30 → 1.167.31 Dependent
@tanstack/router-cli 1.167.27 → 1.167.28 Dependent
@tanstack/router-generator 1.167.27 → 1.167.28 Dependent
@tanstack/router-plugin 1.168.29 → 1.168.30 Dependent
@tanstack/router-vite-plugin 1.167.29 → 1.167.30 Dependent
@tanstack/solid-router 1.170.24 → 1.170.25 Dependent
@tanstack/solid-start 1.168.41 → 1.168.42 Dependent
@tanstack/solid-start-client 1.168.23 → 1.168.24 Dependent
@tanstack/solid-start-server 1.167.30 → 1.167.31 Dependent
@tanstack/start-client-core 1.170.21 → 1.170.22 Dependent
@tanstack/start-plugin-core 1.171.33 → 1.171.34 Dependent
@tanstack/start-server-core 1.169.25 → 1.169.26 Dependent
@tanstack/start-static-server-functions 1.167.26 → 1.167.27 Dependent
@tanstack/start-storage-context 1.167.23 → 1.167.24 Dependent
@tanstack/vue-router 1.170.23 → 1.170.24 Dependent
@tanstack/vue-start 1.168.40 → 1.168.41 Dependent
@tanstack/vue-start-client 1.167.26 → 1.167.27 Dependent
@tanstack/vue-start-server 1.167.30 → 1.167.31 Dependent

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4adfba33-ac3c-431b-858f-c042c2ee3fe6

📥 Commits

Reviewing files that changed from the base of the PR and between 91a848e and bb7f463.

📒 Files selected for processing (2)
  • .changeset/good-plums-doubt.md
  • packages/router-core/src/load-client.ts

📝 Walkthrough

Walkthrough

load-client.ts centralizes idle match updates in setIdleMatches. Refresh rollback, transaction restoration, and hydration now use this helper. A patch changeset records the @tanstack/router-core release.

Changes

Idle match publication

Layer / File(s) Summary
Shared idle match update flow
packages/router-core/src/load-client.ts, .changeset/good-plums-doubt.md
setIdleMatches batches match publication and idle status updates. Refresh rollback, transaction restoration, and hydration use the helper. Hydration can also synchronize the resolved location when client loading is skipped. The changeset declares a patch release.

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

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: reusing idle match batch logic to reduce bundle size.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf-router-core-reuse-idle-match-batch

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.

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

  • Commit: c03538217be0
  • Measured at: 2026-08-09T20:55:13.027Z
  • Baseline source: history:91a848e979ac
  • Dashboard: bundle-size history

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

Scenario Current (gzip) Delta vs baseline Initial gzip Raw Brotli Trend
react-router.minimal 83.95 KiB +25 B (+0.03%) 83.81 KiB 262.77 KiB 73.16 KiB ████▁▁▁▁▁▁▁▁
react-router.full 87.46 KiB +25 B (+0.03%) 87.32 KiB 274.48 KiB 76.12 KiB ████▁▁▁▁▁▁▁▁
solid-router.minimal 33.26 KiB +19 B (+0.06%) 33.14 KiB 96.60 KiB 30.03 KiB ████▁▁▁▁▁▁▁▁
solid-router.full 38.09 KiB +20 B (+0.05%) 37.96 KiB 111.23 KiB 34.32 KiB ████▁▁▁▁▁▁▁▁
vue-router.minimal 49.55 KiB +25 B (+0.05%) 49.42 KiB 138.34 KiB 44.73 KiB ████▁▁▁▁▁▁▁▁
vue-router.full 55.12 KiB +19 B (+0.03%) 55.00 KiB 156.52 KiB 49.65 KiB ████▁▁▁▁▁▁▁▁
react-start.minimal 96.76 KiB +1 B (+0.00%) 96.62 KiB 304.86 KiB 83.88 KiB ████▁▁▁▁▁▁▁▁
react-start.deferred-hydration 97.48 KiB -5 B (-0.01%) 96.64 KiB 306.22 KiB 84.42 KiB ████▁▁▁▁▁▁▁▁
react-start.full 99.91 KiB -14 B (-0.01%) 99.78 KiB 314.58 KiB 86.68 KiB ████▁▁▁▁▁▁▁▁
react-start.rsbuild.minimal 100.08 KiB +13 B (+0.01%) 99.91 KiB 315.42 KiB 86.27 KiB ▁▁▂▂▂▂▅▇▇▇▇█
react-start.rsbuild.minimal-iife 100.49 KiB +14 B (+0.01%) 100.32 KiB 316.35 KiB 86.65 KiB ▁▁▂▂▂▂▅▇▇▇▇█
react-start.rsbuild.full 103.39 KiB -1 B (-0.00%) 103.22 KiB 325.51 KiB 88.97 KiB ▁▁▃▃▃▃▆█████
solid-start.minimal 46.02 KiB +9 B (+0.02%) 45.89 KiB 137.55 KiB 40.87 KiB ████▁▁▁▁▁▁▁▁
solid-start.deferred-hydration 49.10 KiB +7 B (+0.01%) 45.96 KiB 145.01 KiB 43.74 KiB ████▁▁▁▁▁▁▁▁
solid-start.full 51.09 KiB -1 B (-0.00%) 50.97 KiB 152.93 KiB 45.32 KiB ████▁▁▁▁▁▁▁▁
vue-start.minimal 65.55 KiB +7 B (+0.01%) 65.43 KiB 189.06 KiB 58.39 KiB ████▁▁▁▁▁▁▁▁
vue-start.full 69.37 KiB -10 B (-0.01%) 69.24 KiB 201.33 KiB 61.64 KiB ████▁▁▁▁▁▁▁▁

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.

@pkg-pr-new

pkg-pr-new Bot commented Aug 9, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

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

@tanstack/eslint-plugin-router

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

@tanstack/eslint-plugin-start

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

@tanstack/history

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

@tanstack/nitro-v2-vite-plugin

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

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

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

@tanstack/react-start-client

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

@tanstack/react-start-rsc

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

@tanstack/react-start-server

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

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-router-ssr-query

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

@tanstack/solid-start

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

@tanstack/solid-start-client

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

@tanstack/solid-start-server

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

@tanstack/start-client-core

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

@tanstack/start-fn-stubs

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

@tanstack/start-plugin-core

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

@tanstack/start-server-core

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

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

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

@tanstack/valibot-adapter

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

@tanstack/virtual-file-routes

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

@tanstack/vue-router

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

@tanstack/vue-router-devtools

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

@tanstack/vue-router-ssr-query

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

@tanstack/vue-start

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

@tanstack/vue-start-client

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

@tanstack/vue-start-server

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

@tanstack/zod-adapter

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

commit: bb7f463

@Sheraff Sheraff closed this Aug 9, 2026
@Sheraff
Sheraff deleted the perf-router-core-reuse-idle-match-batch branch August 9, 2026 20:58
@codspeed-hq

codspeed-hq Bot commented Aug 9, 2026

Copy link
Copy Markdown

Merging this PR will regress 2 benchmarks

⚠️ 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

⚡ 6 improved benchmarks
❌ 2 regressed benchmarks
✅ 172 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory mem server error-paths redirect (solid) 288.7 KB 403.5 KB -28.47%
Memory mem server error-paths redirect (vue) 294.9 KB 372.5 KB -20.83%
Memory mem server error-paths not-found (solid) 658 KB 411.6 KB +59.88%
Memory mem client navigation-churn (solid) 665.6 KB 616 KB +8.05%
Simulation client-history navigation loop (react) 40 ms 37.1 ms +7.75%
Memory mem client unique-location-churn (vue) 1.3 MB 1.2 MB +4.99%
Memory mem server server-fn-churn (solid) 275 KB 264.6 KB +3.96%
Memory mem server error-paths unmatched (react) 272.1 KB 263.5 KB +3.27%

Tip

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


Comparing perf-router-core-reuse-idle-match-batch (bb7f463) with main (91a848e)

Open in CodSpeed

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

Nx Cloud is proposing a fix for your failed CI:

We updated the setIdleMatches function signature in load-client.ts to use Array<AnyRouteMatch> instead of AnyRouteMatch[], which fixes the @typescript-eslint/array-type ESLint error introduced by this PR. Our change aligns with the project's enforced generic array syntax rule while preserving the full intent of the refactor. No logic was altered — only the type annotation syntax was corrected.

Tip

We verified this fix by re-running @tanstack/router-core:test:eslint.

diff --git a/packages/router-core/src/load-client.ts b/packages/router-core/src/load-client.ts
index a56c5570..131ac76e 100644
--- a/packages/router-core/src/load-client.ts
+++ b/packages/router-core/src/load-client.ts
@@ -2630,7 +2630,7 @@ export async function hydrate(router: AnyRouter): Promise<void> {
 
 function setIdleMatches(
   router: AnyRouter,
-  matches: AnyRouteMatch[],
+  matches: Array<AnyRouteMatch>,
   skipClientLoad?: boolean,
 ) {
   router.batch(() => {

Apply fix via Nx Cloud  Reject fix via Nx Cloud


Or Apply changes locally with:

npx nx-cloud apply-locally xOEV-bEpW

Apply fix locally with your editor ↗   View interactive diff ↗



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

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