Skip to content

perf(router-core): dehydrate SSR match IDs in one pass - #8091

Open
anonrig wants to merge 1 commit into
TanStack:mainfrom
anonrig:perf/ssr-match-id-one-pass
Open

perf(router-core): dehydrate SSR match IDs in one pass#8091
anonrig wants to merge 1 commit into
TanStack:mainfrom
anonrig:perf/ssr-match-id-one-pass

Conversation

@anonrig

@anonrig anonrig commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Split out of #8085 so bundle size and performance can be measured independently.

Typical route ids only contain slashes. Scan once, intern the result with a bounded cache (entry count and string-length limits), and skip hydrate work when the payload has no encoded characters.

Test plan

  • packages/router-core/tests/ssr-match-id.test.ts

Summary by CodeRabbit

  • Bug Fixes
    • Improved server-rendered match ID encoding and decoding for special characters, including slashes and replacement characters.
    • Added support for very long match IDs while maintaining reliable round-trip restoration.
    • Improved decoding performance when IDs contain no encoded characters.

Typical route ids only contain slashes. Scan once, intern the result
with a bounded cache, and skip hydrate work when the payload has no
encoded characters.
@coderabbitai

coderabbitai Bot commented Aug 16, 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: d8a5520e-6989-478c-bde9-19b8976a8859

📥 Commits

Reviewing files that changed from the base of the PR and between f97188f and 78eca7f.

📒 Files selected for processing (2)
  • packages/router-core/src/ssr/ssr-match-id.ts
  • packages/router-core/tests/ssr-match-id.test.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The SSR match ID codec now uses bounded dehydration caching, single-pass escaping, and hydration fast-path handling. Tests cover round-trip behavior for IDs longer than the cache limit.

Changes

SSR match ID codec

Layer / File(s) Summary
Codec optimization and round-trip validation
packages/router-core/src/ssr/ssr-match-id.ts, packages/router-core/tests/ssr-match-id.test.ts
Dehydration now uses a bounded cache and single-pass escaping. Hydration returns unchanged IDs without encoded markers. Tests cover 5,000-character IDs.

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

Merge Risk: ⚪ Minimal · up to 78eca

This localized performance change has no actionable merge-blocking risk remaining after normal checks and review.

Possibly related PRs

  • TanStack/router#8085: Modifies the same SSR match ID functions with equivalent caching, escaping, and hydration fast-path changes.
  • TanStack/router#7343: Modifies the same SSR match ID codec and route-ID encoding and hydration behavior.

Suggested labels: package: router-core

Suggested reviewers: sheraff

🚥 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 describes the main performance change: one-pass dehydration of SSR match IDs.
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 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.

@nx-cloud

nx-cloud Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 78eca7f

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

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

@pkg-pr-new

pkg-pr-new Bot commented Aug 16, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

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

@tanstack/eslint-plugin-router

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

@tanstack/eslint-plugin-start

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

@tanstack/history

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

@tanstack/nitro-v2-vite-plugin

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

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

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

@tanstack/react-start-client

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

@tanstack/react-start-rsc

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

@tanstack/react-start-server

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

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-router-ssr-query

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

@tanstack/solid-start

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

@tanstack/solid-start-client

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

@tanstack/solid-start-server

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

@tanstack/start-client-core

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

@tanstack/start-fn-stubs

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

@tanstack/start-plugin-core

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

@tanstack/start-server-core

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

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

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

@tanstack/valibot-adapter

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

@tanstack/virtual-file-routes

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

@tanstack/vue-router

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

@tanstack/vue-router-devtools

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

@tanstack/vue-router-ssr-query

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

@tanstack/vue-start

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

@tanstack/vue-start-client

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

@tanstack/vue-start-server

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

@tanstack/zod-adapter

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

commit: 78eca7f

@codspeed-hq

codspeed-hq Bot commented Aug 16, 2026

Copy link
Copy Markdown

Merging this PR will regress 11 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

⚡ 8 improved benchmarks
❌ 11 regressed benchmarks
✅ 161 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 not-found (react) 416.3 KB 509.7 KB -18.31%
Memory mem client unique-location-churn (react) 666.9 KB 754.8 KB -11.64%
Memory mem server error-paths redirect (react) 309.3 KB 344.6 KB -10.25%
Memory mem server peak-large-page (vue) 1 MB 1.1 MB -8.57%
Memory mem server aborted-requests (react) 872.2 KB 942.4 KB -7.45%
Memory mem server peak-large-page (solid) 1.1 MB 1.1 MB -6.58%
Memory mem server request-churn (solid) 712.2 KB 761 KB -6.42%
Memory mem server server-fn-churn (react) 381.4 KB 405.4 KB -5.92%
Memory mem server error-paths unmatched (react) 439.8 KB 463.2 KB -5.05%
Memory mem server request-churn (vue) 835 KB 864.7 KB -3.44%
Memory mem server serialization-payload (vue) 4.3 MB 4.4 MB -3.27%
Memory mem server serialization-payload (solid) 7.4 MB 4.7 MB +56.76%
Memory mem client navigation-churn (solid) 960.6 KB 696.2 KB +37.98%
Memory mem client unique-location-churn (solid) 415.5 KB 333.2 KB +24.7%
Memory mem client unique-location-churn (vue) 539.8 KB 489.8 KB +10.21%
Memory mem server aborted-requests (vue) 1,052.1 KB 957.7 KB +9.85%
Memory mem client interrupted-navigations (vue) 478 KB 440.2 KB +8.59%
Memory mem server server-fn-churn (vue) 379.5 KB 354.3 KB +7.1%
Simulation client-async-pipeline navigation loop (react) 107.9 ms 104.2 ms +3.61%

Tip

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


Comparing anonrig:perf/ssr-match-id-one-pass (78eca7f) with main (f97188f)

Open in CodSpeed

Sign up for free to 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