perf(router-core): classify simple segments before slicing - #8008
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 b57bc35
☁️ Nx Cloud last updated this comment at |
🚀 Changeset Version PreviewNo changeset entries found. Merging this PR will not cause a version bump for any packages. |
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 degrade performance by 20.07%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | ssr dehydrate rich types (solid) |
87.3 ms | 99.8 ms | -12.54% |
| ❌ | Simulation | ssr dehydrate plain control (solid) |
119.6 ms | 129.3 ms | -7.56% |
| ❌ | Simulation | ssr global-mw document (solid) |
161.9 ms | 169.6 ms | -4.55% |
| ❌ | Simulation | client-async-pipeline navigation loop (react) |
38.7 ms | 39.9 ms | -3.13% |
| ⚡ | Memory | mem server error-paths redirect (solid) |
588.2 KB | 272.8 KB | ×2.2 |
| ⚡ | Memory | mem client preload-churn (vue) |
776.2 KB | 735.7 KB | +5.5% |
| ⚡ | Memory | mem client interrupted-navigations (vue) |
499.5 KB | 480.6 KB | +3.92% |
| ⚡ | Memory | mem client navigation-churn (solid) |
570.2 KB | 549.8 KB | +3.71% |
| ⚡ | Simulation | ssr control-flow unmatched 404 (react) |
67.2 ms | 65.1 ms | +3.25% |
| 👁 | Memory | mem server error-paths not-found (solid) |
416.3 KB | 793.5 KB | -47.53% |
| 👁 | Memory | mem server error-paths not-found (vue) |
318.6 KB | 2,182.6 KB | -85.4% |
| 👁 | Memory | mem server streaming-peak chunked (vue) |
11.2 MB | 13.5 MB | -17.09% |
| 👁 | Memory | mem server error-paths not-found (react) |
256.3 KB | 266.2 KB | -3.73% |
| 👁 | Memory | mem server error-paths unmatched (react) |
263.6 KB | 602 KB | -56.21% |
| 👁 | Memory | mem client unique-location-churn (solid) |
341.6 KB | 498.5 KB | -31.47% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing agent/parse-segment-branch-order (b57bc35) with main (c568caf)
What changed
$paramand$segments from their boundaries before creating a substringWhy
parseSegmentpreviously allocated a substring before it knew whether the segment needed complex parsing. Simple params, wildcards, and static segments make up the common route grammar, so classifying them from the original path removes avoidable allocation while keeping one canonical parser.This PR does not require the separate interpolation cleanup.
parseSegmentis already used by route-tree processing and other core path operations, so the change is independently useful and mergeable in either order.Impact
Focused local parser benchmarks, each parsing 10,000 complete paths:
react-router.minimalchanges from 85,919 to 85,938 bytes gzip (+19 bytes; raw +23 bytes).Validation
@tanstack/router-core:test:unit: 105 files / 1,536 tests passed, plus 3 expected failures@tanstack/router-core:test:types: TypeScript 5.6 through 7.0 passed@tanstack/router-core:test:eslint: zero errors (existing warnings remain)tests/parseSegment.bench.tsrunsreact-router.minimalbundle-size scenario onmainand this branchgit diff --check