perf(router-core): optimize server search serialization - #8012
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 0ae9eb0
☁️ Nx Cloud last updated this comment at |
🚀 Changeset Version Preview2 package(s) bumped directly, 21 bumped as dependents. 🟩 Patch bumps
|
Bundle Size BenchmarksThis pull request does not affect bundle size in any measured scenario. |
Merging this PR will degrade performance by 0.08%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Memory | mem server error-paths redirect (vue) |
433.1 KB | 904.6 KB | -52.13% |
| ❌ | Memory | mem server error-paths unmatched (solid) |
428.5 KB | 454.6 KB | -5.75% |
| ❌ | Memory | mem server server-fn-churn (react) |
264.7 KB | 276.7 KB | -4.31% |
| ⚡ | Memory | mem server error-paths not-found (solid) |
728.6 KB | 418.6 KB | +74.03% |
| ⚡ | Memory | mem client preload-churn (vue) |
805.5 KB | 736.9 KB | +9.32% |
| ⚡ | Memory | mem client navigation-churn (solid) |
575 KB | 528.4 KB | +8.83% |
| ⚡ | Simulation | ssr dehydrate rich types (solid) |
99.7 ms | 95.9 ms | +4.01% |
| ⚡ | Memory | mem server error-paths unmatched (react) |
272.3 KB | 263.2 KB | +3.48% |
| ⚡ | Memory | mem client unique-location-churn (solid) |
352.4 KB | 341.5 KB | +3.18% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing codex/server-search-serialization (0ae9eb0) with main (44a8c3e)
What changed
isServerconditional export.JSON.parsecalls for impossible JSON and bypassing parsing for fully validated primitives.The environment check intentionally remains at serializer invocation time. The server
isServerexport also loads router code, so reading it while the serializer factory initializes can encounter theisServer -> load-server -> router -> searchParamsmodule cycle.Why
#8006 keeps the client fast path compact because every byte matters there. Server builds can dead-code-eliminate a larger implementation, allowing exact primitive validation and avoiding costly parser exceptions without increasing client bundles.
Performance
Measured with the same Vitest benchmark file against the exact merged #8006 implementation:
Inputs that still require the native parser remain within single-digit percentages of the baseline, and whitespace-prefixed structured inputs no longer have a length-amplifying double-scan regression.
The full 17-scenario client bundle matrix is byte-for-byte unchanged: zero delta for raw, gzip, Brotli, and initial gzip sizes.
Validation
@tanstack/router-core:test:unit: 106 files passed; 1,616 tests passed and 3 expected failures@tanstack/router-core:test:types: TypeScript 5.6 through 7.0 passed@tanstack/router-core:test:eslint: 0 errors