perf(router-core): derive match frame depth - #7973
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe route matcher removes computed depth from match frames and uses trie-node depth for specificity and optional-segment masks. Tests cover pathless-route selection, and a benchmark covers static and optional matching. ChangesRoute matching
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 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 |
|
View your CI Pipeline Execution ↗ for commit 67f46f9
☁️ Nx Cloud last updated this comment at |
🚀 Changeset Version Preview5 package(s) bumped directly, 18 bumped as dependents. 🟩 Patch bumps
|
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. |
Merging this PR will regress 4 benchmarks
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Memory | mem server request-churn (react) |
491.6 KB | 531.9 KB | -7.57% |
| ❌ | Simulation | ssr server-fn during document ssr (react) |
62.9 ms | 66.3 ms | -5.22% |
| ❌ | Memory | mem client navigation-churn (solid) |
580.3 KB | 606.2 KB | -4.28% |
| ❌ | Simulation | ssr dehydrate rich types (vue) |
135.2 ms | 139.6 ms | -3.2% |
| ⚡ | Memory | mem server server-fn-churn (vue) |
4,147.3 KB | 270.5 KB | ×15 |
| ⚡ | Memory | mem server error-paths unmatched (vue) |
2,142.1 KB | 478.7 KB | ×4.5 |
| ⚡ | Memory | mem server peak-large-page (react) |
1,737.5 KB | 953.5 KB | +82.23% |
| ⚡ | Memory | mem server error-paths redirect (solid) |
388 KB | 278.4 KB | +39.35% |
| ⚡ | Memory | mem server error-paths redirect (vue) |
338.6 KB | 313.9 KB | +7.88% |
| ⚡ | Memory | mem server error-paths unmatched (react) |
317.5 KB | 299.3 KB | +6.08% |
| ⚡ | Memory | mem client navigation-churn (vue) |
1.3 MB | 1.2 MB | +4.45% |
| ⚡ | Simulation | ssr control-flow unmatched 404 (react) |
58.1 ms | 56 ms | +3.69% |
| ⚡ | Memory | mem server error-paths not-found (react) |
277.7 KB | 268.6 KB | +3.36% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing codex/bundle-size-principles (67f46f9) with main (697ebb6)
Summary
depthfield from private route-match stack framesWhy
Every match frame already carries a trie node whose immutable
depthis the source used by branch construction. Copying that same fact onto every speculative frame adds a non-mangleable object key, a property store, and a larger frame shape.This applies the “one fact, one representation” principle without changing a public API or restructuring the matcher.
Measurements
react-router.minimal:The full 17-scenario matrix improved gzip by 29–54 bytes in every scenario, initial gzip in every scenario, and raw output by 90–110 bytes. Brotli varied from -115 to +127 bytes across differently chunked apps; gzip is the benchmark’s primary metric and raw output decreased everywhere.
Focused
findSingleMatchmeans also improved directionally:All benchmark RMEs were below 1%; the mixed-optional result is the clearest signal.
Checks
@tanstack/router-core:test:unit: 105 files passed; 1,524 passed, 3 expected failures@tanstack/router-core:test:types: TypeScript 5.6, 5.7, 5.8, 5.9, 6.0, and 7.0 passed@tanstack/router-core:test:eslint: 0 errors (26 existing warnings)Summary by CodeRabbit
Bug Fixes
Tests