Skip to content

perf(router-core): gate JSON.parse attempts behind jsonStart guard in parseSearchWith - #8142

Draft
Sheraff wants to merge 2 commits into
mainfrom
perf/task1-jsonstart-parse-gate
Draft

perf(router-core): gate JSON.parse attempts behind jsonStart guard in parseSearchWith#8142
Sheraff wants to merge 2 commits into
mainfrom
perf/task1-jsonstart-parse-gate

Conversation

@Sheraff

@Sheraff Sheraff commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • parseSearchWith now skips the try/catch JSON.parse attempt for strings that cannot begin valid JSON, using the same jsonStart guard the stringify side already had (searchParams.ts).
  • Gated on parser === JSON.parse so custom parsers (public API) are untouched; false positives still fall through to try/catch — behavior strictly identical.

Performance

Parse-side bench (1k-string batches), before → after:

workload before after delta
ordinary string params 67 hz 1,183 hz ~17.6x
empty strings 67 hz 1,520 hz ~22.8x
punctuation-start strings 82 hz 992 hz ~12.2x
mixed values 116 hz 1,227 hz ~10.5x
fa/nu/tr-prefixed (still throw) ~64–84 hz ~60–77 hz ~0.9x
JSON-compatible values 845 hz 795 hz ~0.94x

Verification

  • Correctness: old vs new deep-equal on all bench inputs + 45 adversarial values (empty/whitespace/0/-/fa/tru/unicode/etc.) for JSON.parse and a custom parser.
  • test:unit ✅ (1609 tests + typecheck) · test:eslint ✅ · test:types ✅
  • New: parse-side bench (searchParams-parse.bench.ts) + 3 unit tests covering gated/pass-through/custom-parser paths.

@nx-cloud

nx-cloud Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit b68a1bf

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

☁️ Nx Cloud last updated this comment at 2026-08-22 05:55:19 UTC

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f2387779-fc0a-40b2-bf11-8d25336b131d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@pkg-pr-new

pkg-pr-new Bot commented Aug 21, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

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

@tanstack/eslint-plugin-router

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

@tanstack/eslint-plugin-start

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

@tanstack/history

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

@tanstack/nitro-v2-vite-plugin

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

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

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

@tanstack/react-start-client

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

@tanstack/react-start-rsc

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

@tanstack/react-start-server

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

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-router-ssr-query

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

@tanstack/solid-start

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

@tanstack/solid-start-client

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

@tanstack/solid-start-server

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

@tanstack/start-client-core

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

@tanstack/start-fn-stubs

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

@tanstack/start-plugin-core

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

@tanstack/start-server-core

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

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

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

@tanstack/valibot-adapter

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

@tanstack/virtual-file-routes

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

@tanstack/vue-router

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

@tanstack/vue-router-devtools

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

@tanstack/vue-router-ssr-query

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

@tanstack/vue-start

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

@tanstack/vue-start-client

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

@tanstack/vue-start-server

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

@tanstack/zod-adapter

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

commit: b68a1bf

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

4 package(s) bumped directly, 19 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/react-router 1.170.31 → 1.170.32 Changeset
@tanstack/router-core 1.171.26 → 1.171.27 Changeset
@tanstack/solid-router 1.170.29 → 1.170.30 Changeset
@tanstack/vue-router 1.170.28 → 1.170.29 Changeset
@tanstack/react-start 1.168.48 → 1.168.49 Dependent
@tanstack/react-start-client 1.168.29 → 1.168.30 Dependent
@tanstack/react-start-rsc 0.1.47 → 0.1.48 Dependent
@tanstack/react-start-server 1.167.36 → 1.167.37 Dependent
@tanstack/router-cli 1.167.32 → 1.167.33 Dependent
@tanstack/router-generator 1.167.32 → 1.167.33 Dependent
@tanstack/router-plugin 1.168.34 → 1.168.35 Dependent
@tanstack/router-vite-plugin 1.167.34 → 1.167.35 Dependent
@tanstack/solid-start 1.168.46 → 1.168.47 Dependent
@tanstack/solid-start-client 1.168.28 → 1.168.29 Dependent
@tanstack/solid-start-server 1.167.35 → 1.167.36 Dependent
@tanstack/start-client-core 1.170.26 → 1.170.27 Dependent
@tanstack/start-plugin-core 1.171.38 → 1.171.39 Dependent
@tanstack/start-server-core 1.169.30 → 1.169.31 Dependent
@tanstack/start-static-server-functions 1.167.31 → 1.167.32 Dependent
@tanstack/start-storage-context 1.167.28 → 1.167.29 Dependent
@tanstack/vue-start 1.168.45 → 1.168.46 Dependent
@tanstack/vue-start-client 1.167.31 → 1.167.32 Dependent
@tanstack/vue-start-server 1.167.35 → 1.167.36 Dependent

@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

  • Commit: d14b3fcda174
  • Measured at: 2026-08-22T05:51:51.549Z
  • Baseline source: history:d83a8964c250
  • Dashboard: bundle-size history

The following scenarios have bundle-size changes compared with the baseline:

Scenario Current (gzip) Initial (gzip) Raw Brotli Trend
react-router.minimal 83.9 KiB
+17 B
83.7 KiB
+19 B
262.8 KiB
+50 B
72.9 KiB
-82 B
▄▃▃▁▁▄▄▄▂▆▆█
react-router.full 87.4 KiB
+20 B
87.2 KiB
+18 B
274.5 KiB
+50 B
76.1 KiB
+78 B
▃▂▂▁▁▅▅▅▃▅▅█
solid-router.minimal 33.2 KiB
+7 B
33.1 KiB
+11 B
96.7 KiB
+50 B
30.0 KiB
+3 B
▁▁▁▆▆▇▇▇▇▇▇█
solid-router.full 38.1 KiB
+21 B
37.9 KiB
+21 B
111.3 KiB
+50 B
34.2 KiB
-38 B
▁▁▁▆▆▇▇▇▆▇▇█
vue-router.minimal 49.6 KiB
+17 B
49.4 KiB
+20 B
138.7 KiB
+50 B
44.7 KiB
+61 B
▁▁▁▁▁▆▆▆▃▆▆█
vue-router.full 55.2 KiB
+26 B
55.0 KiB
+27 B
156.9 KiB
+50 B
49.6 KiB
-4 B
▁▁▁▁▁▅▅▅▃▅▅█
react-start.minimal 96.8 KiB
+27 B
96.6 KiB
+24 B
305.1 KiB
+50 B
83.8 KiB
+11 B
▂▁▁▅▅▆▆▆▅▇▇█
react-start.deferred-hydration 97.5 KiB
+21 B
96.7 KiB
+24 B
306.5 KiB
+50 B
84.4 KiB
-98 B
▂▁▁▅▅▇▇▇▆▇▇█
react-start.full 99.9 KiB
+19 B
99.8 KiB
+16 B
314.8 KiB
+50 B
86.6 KiB
+86 B
▁▁▁▄▄▆▆▆▅▇▇█
react-start.rsbuild.minimal 100.1 KiB
+18 B
99.9 KiB
+18 B
315.4 KiB
+53 B
86.3 KiB
-110 B
▂▁▁▄▄███▆▇▇█
react-start.rsbuild.minimal-iife 100.5 KiB
+15 B
100.3 KiB
+15 B
316.3 KiB
+53 B
86.7 KiB
+35 B
▂▁▁▄▄███▆▇▇█
react-start.rsbuild.full 103.4 KiB
+15 B
103.2 KiB
+15 B
325.5 KiB
+52 B
89.0 KiB
+19 B
▂▁▁▄▄███▆▇▇█
solid-start.minimal 46.1 KiB
+15 B
45.9 KiB
+17 B
137.8 KiB
+48 B
40.9 KiB
-22 B
▁▁▁▆▆▇▇▇▇▇▇█
solid-start.deferred-hydration 49.1 KiB
+18 B
46.0 KiB
+18 B
145.3 KiB
+52 B
43.7 KiB
+10 B
▁▁▁▆▆▇▇▇▆▇▇█
solid-start.full 51.1 KiB
+1 B
51.0 KiB
+5 B
153.2 KiB
+46 B
45.4 KiB
+74 B
▁▁▁▆▆▇▇▇▇███
vue-start.minimal 65.7 KiB
+16 B
65.6 KiB
+19 B
189.6 KiB
+50 B
58.5 KiB
+51 B
▁▁▁▆▆▇▇▇▆▇▇█
vue-start.full 69.5 KiB
+21 B
69.4 KiB
+19 B
201.9 KiB
+50 B
61.8 KiB
+51 B
▁▁▁▅▅▇▇▇▆▇▇█

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.

@codspeed-hq

codspeed-hq Bot commented Aug 21, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 4.62%

⚠️ 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

⚡ 6 improved benchmarks
❌ 9 regressed benchmarks
✅ 165 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory mem server request-churn (react) 662.6 KB 2,460.5 KB -73.07%
Memory mem client unique-location-churn (solid) 265.7 KB 672 KB -60.46%
Memory mem server peak-large-page (vue) 1 MB 1.2 MB -14.13%
Memory mem server peak-large-page (solid) 1 MB 1.2 MB -11.39%
Memory mem server aborted-requests (react) 855.7 KB 904.9 KB -5.43%
Memory mem server request-churn (solid) 712.7 KB 747 KB -4.58%
Memory mem server server-fn-churn (vue) 345.7 KB 362.1 KB -4.53%
Memory mem server error-paths not-found (solid) 557.9 KB 583.1 KB -4.33%
Memory mem server server-fn-churn (react) 378.9 KB 391.8 KB -3.3%
Memory mem server error-paths not-found (vue) 2,304.3 KB 492 KB ×4.7
Memory mem server error-paths unmatched (react) 544.1 KB 420.2 KB +29.47%
Memory mem server aborted-requests (vue) 1,110.1 KB 1,017.7 KB +9.08%
Memory mem server peak-large-page (react) 1.2 MB 1.1 MB +8.5%
Memory mem server error-paths redirect (solid) 382.2 KB 370.7 KB +3.1%
Memory mem server error-paths redirect (react) 318.9 KB 309.6 KB +3.03%

Tip

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


Comparing perf/task1-jsonstart-parse-gate (b68a1bf) with main (d83a896)

Open in CodSpeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant