perf(router-core): consolidate interpolation caches - #8321
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe PR changes ChangesRoute interpolation and caching
Priority: ⬇️ Low Estimated code review effort: 4 (Complex) | ~45 minutes Change: Refactor Suggested reviewers: Merge Risk: ⚪ Minimal · up to The interpolation and cache redesign has no identified merge-blocking risk in the reviewed changes. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
2c2660e to
cb49a99
Compare
|
View your CI Pipeline Execution ↗ for commit f852898
☁️ Nx Cloud last updated this comment at |
Bundle Size Benchmarks
The following scenarios have bundle-size changes compared with the baseline:
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. |
🚀 Changeset Version Preview7 package(s) bumped directly, 22 bumped as dependents. 🟩 Patch bumps
|
Merging this PR will degrade performance by 41.23%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Memory | mem client interrupted-navigations (vue) |
386.3 KB | 657.2 KB | -41.23% |
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-route-caches (f852898) with optimize-link-navigation-params (597c134)1
Footnotes
cb49a99 to
71e419a
Compare
71e419a to
8115594
Compare
8115594 to
c01f3e0
Compare
c01f3e0 to
a41f1f2
Compare
a41f1f2 to
0338650
Compare
There was a problem hiding this comment.
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 detected a CSS module styling failure after client-side navigation (rsc-css-modules.spec.ts:124) that is isolated to this branch with a 0% historical flakiness rate and no similar failures found in other branches. Our analysis points to a likely indirect regression in client-side navigation behavior introduced by the interpolation consolidation changes in @tanstack/router-core, causing CSS module styles not to apply correctly post-navigation.
No code changes were suggested for this issue.
Trigger a rerun:
🎓 Learn more about Self-Healing CI on nx.dev
Remove the object-returning internal wrapper and keep one interpolatePath returning a pathname with optional metadata outputs. Migrate router, devtools, tests, and benchmarks while leaving parsing and cache limits unchanged. Devtools requests only missing-param status. Tests use direct expected paths and explicit metadata; cache benchmarks no longer carry obsolete factory compatibility dispatch. React Router minimal/full gzip are 85829/89413 bytes (+5/+4 from 8a9f57e, still 14/4 below measured main). Full units/types/exports and 76 browser cases pass; eight paired client/SSR workloads show no supported timing change. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Store branches and interpolation plans directly on route objects. Use the already-resolved destination route, remove the fixed outer limit for registered templates, and retain128 results per route. Keep a bounded32-template fallback for arbitrary templates and masks. Build/install route-tree indexes and string caches as one bundle for existing SSR reuse. Reinitialization clears ancestor branches; interpolation plans validate their exact template and decoder without unconditional resets. Loaded match data remains request-local. Against29509b9b98, paired core buildLocation batches over64/256 templates use40-43% less CPU; four fresh server routers generating200 hrefs each use8-9% less. Reversed import order corroborates these scoped results. Four real client/SSR Link cases remain statistically inconclusive. All18 bundle fixtures shrink19-37 gzip bytes versus the consolidation baseline. React Router minimal/full are85797/89379 bytes,46/38 below measured main. Tests cover SSR request cleanup, route reuse, decoder/trailing variants, reparenting, result bounds and fallback capacity. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Cover client/server matching with cold and Link-primed route plans, nested params, high-cardinality misses, optional params, and splats. Gate all additional cases behind TSR_LINK_PERF=1. Evaluate six matching-cache prototypes without retaining production changes. Eager variants regress repeated misses by24-64%. Read-through reuse improves warm matching microcases but adds65 gzip bytes; all26 application Link/SSR comparisons show no supported speedup, with one relative-Link slowdown. Real HTTP SSR ABBA means differ by only -0.41%, within observed variation. Restore production and all18 bundle metrics exactly to ec05cc6. Preserve detailed measurements and rejected prototypes in session artifacts and uncommitted LOG.md. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
0338650 to
f852898
Compare
* refactor(router-core): consolidate path interpolation Remove the object-returning internal wrapper and keep one interpolatePath returning a pathname with optional metadata outputs. Migrate router, devtools, tests, and benchmarks while leaving parsing and cache limits unchanged. Devtools requests only missing-param status. Tests use direct expected paths and explicit metadata; cache benchmarks no longer carry obsolete factory compatibility dispatch. React Router minimal/full gzip are 85829/89413 bytes (+5/+4 from 8a9f57e, still 14/4 below measured main). Full units/types/exports and 76 browser cases pass; eight paired client/SSR workloads show no supported timing change. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * perf(router-core): keep derived caches on routes Store branches and interpolation plans directly on route objects. Use the already-resolved destination route, remove the fixed outer limit for registered templates, and retain128 results per route. Keep a bounded32-template fallback for arbitrary templates and masks. Build/install route-tree indexes and string caches as one bundle for existing SSR reuse. Reinitialization clears ancestor branches; interpolation plans validate their exact template and decoder without unconditional resets. Loaded match data remains request-local. Against29509b9b98, paired core buildLocation batches over64/256 templates use40-43% less CPU; four fresh server routers generating200 hrefs each use8-9% less. Reversed import order corroborates these scoped results. Four real client/SSR Link cases remain statistically inconclusive. All18 bundle fixtures shrink19-37 gzip bytes versus the consolidation baseline. React Router minimal/full are85797/89379 bytes,46/38 below measured main. Tests cover SSR request cleanup, route reuse, decoder/trailing variants, reparenting, result bounds and fallback capacity. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * test(router-core): add opt-in matching interpolation benchmarks Cover client/server matching with cold and Link-primed route plans, nested params, high-cardinality misses, optional params, and splats. Gate all additional cases behind TSR_LINK_PERF=1. Evaluate six matching-cache prototypes without retaining production changes. Eager variants regress repeated misses by24-64%. Read-through reuse improves warm matching microcases but adds65 gzip bytes; all26 application Link/SSR comparisons show no supported speedup, with one relative-Link slowdown. Real HTTP SSR ABBA means differ by only -0.41%, within observed variation. Restore production and all18 bundle metrics exactly to ec05cc6. Preserve detailed measurements and rejected prototypes in session artifacts and uncommitted LOG.md. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Unfortunately, this PR breaks compatibility with the |
🎯 Changes
Consolidate internal interpolation, move derived caches onto routes, and add matching/interpolation benchmark coverage.
This is PR 6 of a stacked series and is based on
optimize-link-navigation-params.✅ Checklist
🚀 Release Impact
Summary by CodeRabbit
Performance
Bug Fixes