Skip to content

perf: reduce repeated Zod validation work - #8305

Open
LadyBluenotes wants to merge 7 commits into
mainfrom
perf/zod-validation-fast-path
Open

perf: reduce repeated Zod validation work#8305
LadyBluenotes wants to merge 7 commits into
mainfrom
perf/zod-validation-fast-path

Conversation

@LadyBluenotes

@LadyBluenotes LadyBluenotes commented Sep 9, 2026

Copy link
Copy Markdown
Member

🎯 Changes

Replaces #8301 with only the Zod validation work, based directly on main.

Compile the code-splitting grouping schema and check duplicates without flattening or copying arrays. Skip Zod parsing for Rspack modules without server-function metadata. Preserve grouping diagnostics and valid metadata parsing, including cloned output and unknown-key stripping.

Add behavior tests and Vitest benchmarks for grouping validation and metadata restoration.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with the relevant test commands, or tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Performance

    • Improved validation efficiency for code-splitting group configurations.
    • Reduced unnecessary processing when reading server-function metadata during builds.
  • Bug Fixes

    • Modules without server-function metadata are now handled safely during builds.
    • Code-splitting configurations continue to reject duplicate or invalid entries with clearer validation results.
  • Documentation

    • Updated Zod examples and usage guidance to reflect current import conventions.
  • Tests

    • Added coverage and performance benchmarks for validation and metadata handling.

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: c8a27c51-6f88-4377-9af6-37562963f1d8

📥 Commits

Reviewing files that changed from the base of the PR and between 572e1ad and 0a079c5.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (1)
  • docs/router/how-to/share-search-params-across-routes.md

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The router plugin compiles split-group validation and detects duplicate nodes incrementally. The Start plugin tests guarded server-function metadata parsing. The change also standardizes Zod namespace imports, updates Seroval ranges, and adds benchmark scripts.

Changes

Plugin performance updates

Layer / File(s) Summary
Split groupings validation
packages/router-plugin/src/core/config.ts, packages/router-plugin/tests/split-groupings.*, packages/router-plugin/package.json
The schema uses compiled validation and incremental duplicate detection. Tests cover valid, invalid, and duplicate groupings. Benchmarks compare compiled and uncompiled parsing.
Server-function metadata parsing
packages/start-plugin-core/src/rsbuild/start-compiler-host.ts, packages/start-plugin-core/tests/rsbuild/start-compiler-metadata.*, packages/start-plugin-core/package.json
Tests cover absent, invalid, empty, and valid metadata. Benchmarks compare guarded and unguarded parsing.
Package and import alignment
.changeset/sweet-lions-share.md, packages/*/package.json, benchmarks/ssr/package.json, docs/**, e2e/**, examples/**
The changeset declares patch releases. Benchmark scripts are added. Seroval ranges are updated. Zod examples, fixtures, source files, and tests use namespace imports.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: 🔵 Low · up to 0a079

The change improves validation and metadata parsing performance. One documentation page may lack a visible H1 if no generated title is provided, making this a minor follow-up rather than a functional blocker.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 5…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the primary change: reducing repeated Zod validation work through performance optimizations.
Description check ✅ Passed The description follows the repository template, explains the changes and motivation, completes all checklist items, and identifies the release impact with a changeset.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/zod-validation-fast-path

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.

@nx-cloud

nx-cloud Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 317562c

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

☁️ Nx Cloud last updated this comment at 2026-09-11 03:12:40 UTC

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

6 package(s) bumped directly, 17 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/router-core 1.171.29 → 1.171.30 Changeset
@tanstack/router-plugin 1.168.37 → 1.168.38 Changeset
@tanstack/start-client-core 1.170.29 → 1.170.30 Changeset
@tanstack/start-plugin-core 1.171.42 → 1.171.43 Changeset
@tanstack/start-server-core 1.169.34 → 1.169.35 Changeset
@tanstack/start-static-server-functions 1.167.34 → 1.167.35 Changeset
@tanstack/react-router 1.170.35 → 1.170.36 Dependent
@tanstack/react-start 1.168.52 → 1.168.53 Dependent
@tanstack/react-start-client 1.168.33 → 1.168.34 Dependent
@tanstack/react-start-rsc 0.1.51 → 0.1.52 Dependent
@tanstack/react-start-server 1.167.40 → 1.167.41 Dependent
@tanstack/router-cli 1.167.35 → 1.167.36 Dependent
@tanstack/router-generator 1.167.35 → 1.167.36 Dependent
@tanstack/router-vite-plugin 1.167.37 → 1.167.38 Dependent
@tanstack/solid-router 1.170.33 → 1.170.34 Dependent
@tanstack/solid-start 1.168.50 → 1.168.51 Dependent
@tanstack/solid-start-client 1.168.32 → 1.168.33 Dependent
@tanstack/solid-start-server 1.167.39 → 1.167.40 Dependent
@tanstack/start-storage-context 1.167.31 → 1.167.32 Dependent
@tanstack/vue-router 1.170.32 → 1.170.33 Dependent
@tanstack/vue-start 1.168.49 → 1.168.50 Dependent
@tanstack/vue-start-client 1.167.35 → 1.167.36 Dependent
@tanstack/vue-start-server 1.167.39 → 1.167.40 Dependent

@pkg-pr-new

pkg-pr-new Bot commented Sep 9, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

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

@tanstack/eslint-plugin-router

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

@tanstack/eslint-plugin-start

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

@tanstack/history

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

@tanstack/nitro-v2-vite-plugin

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

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

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

@tanstack/react-start-client

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

@tanstack/react-start-rsc

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

@tanstack/react-start-server

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

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-router-ssr-query

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

@tanstack/solid-start

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

@tanstack/solid-start-client

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

@tanstack/solid-start-server

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

@tanstack/start-client-core

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

@tanstack/start-fn-stubs

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

@tanstack/start-plugin-core

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

@tanstack/start-server-core

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

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

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

@tanstack/valibot-adapter

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

@tanstack/virtual-file-routes

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

@tanstack/vue-router

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

@tanstack/vue-router-devtools

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

@tanstack/vue-router-ssr-query

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

@tanstack/vue-start

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

@tanstack/vue-start-client

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

@tanstack/vue-start-server

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

@tanstack/zod-adapter

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

commit: 317562c

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

  • Commit: 9503e360e6ef
  • Measured at: 2026-09-11T03:19:55.827Z
  • Baseline source: history:6494e75362ff
  • Dashboard: bundle-size history

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

Scenario Current (gzip) Initial (gzip) Raw Brotli Trend
react-start.minimal 97.4 KiB
+556 B
97.3 KiB
+555 B
306.2 KiB
+1.6 KiB
84.4 KiB
+355 B
▁▁▃▃▃▃▃▃▃▂▂█
react-start.query-integration 104.8 KiB
+554 B
104.6 KiB
+556 B
332.7 KiB
+1.7 KiB
90.8 KiB
+517 B
▁▁▃▃▃▃▃▃▃▂▂█
react-start.deferred-hydration 98.2 KiB
+559 B
97.3 KiB
+560 B
307.6 KiB
+1.6 KiB
85.2 KiB
+451 B
▁▁▃▃▃▃▃▃▃▂▂█
react-start.full 100.6 KiB
+524 B
100.4 KiB
+520 B
315.9 KiB
+1.6 KiB
87.1 KiB
+393 B
▁▁▄▄▄▄▄▄▄▂▂█
react-start.rsbuild.minimal 100.7 KiB
+624 B
100.6 KiB
+624 B
316.7 KiB
+1.8 KiB
87.0 KiB
+541 B
▁▁▃▃▃▃▃▃▃▁▁█
react-start.rsbuild.minimal-iife 101.1 KiB
+619 B
101.0 KiB
+619 B
317.6 KiB
+1.8 KiB
87.3 KiB
+399 B
▁▁▃▃▃▃▃▃▃▁▁█
react-start.rsbuild.full 104.0 KiB
+636 B
103.9 KiB
+636 B
326.8 KiB
+1.8 KiB
89.7 KiB
+481 B
▁▁▃▃▃▃▃▃▃▁▁█
solid-start.minimal 46.9 KiB
+581 B
46.8 KiB
+581 B
139.5 KiB
+1.6 KiB
41.7 KiB
+490 B
▁▁▃▃▃▃▃▃▃▃▃█
solid-start.deferred-hydration 50.0 KiB
+575 B
46.8 KiB
+569 B
146.9 KiB
+1.6 KiB
44.5 KiB
+473 B
▁▁▃▃▃▃▃▃▃▃▃█
solid-start.full 52.0 KiB
+580 B
51.8 KiB
+580 B
154.9 KiB
+1.6 KiB
46.0 KiB
+436 B
▁▁▃▃▃▃▃▃▃▃▃█
vue-start.minimal 66.3 KiB
+563 B
66.2 KiB
+563 B
190.8 KiB
+1.6 KiB
59.1 KiB
+513 B
▁▁▅▅▅▅▅▅▅▁▁█
vue-start.full 70.2 KiB
+593 B
70.0 KiB
+593 B
203.1 KiB
+1.6 KiB
62.4 KiB
+550 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 Sep 9, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 22.7%

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

⚡ 10 improved benchmarks
✅ 170 untouched benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation ssr streaming deferred (react) 705.3 ms 445.7 ms +58.26%
Simulation ssr streaming deferred (vue) 759.9 ms 494 ms +53.81%
Memory mem server streaming-peak chunked (react) 1,159.4 KB 818.7 KB +41.61%
Simulation ssr streaming deferred (solid) 1,051.5 ms 788.6 ms +33.33%
Simulation ssr server-fn send-context (solid) 285.2 ms 248.9 ms +14.57%
Simulation ssr server-fn send-context (react) 284.2 ms 248.3 ms +14.48%
Simulation ssr server-fn send-context (vue) 285.9 ms 250 ms +14.36%
Simulation ssr global-mw server-fn (solid) 234.6 ms 225.7 ms +3.94%
Simulation ssr global-mw server-fn (react) 234.7 ms 225.9 ms +3.89%
Simulation ssr global-mw server-fn (vue) 235.3 ms 226.5 ms +3.88%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing perf/zod-validation-fast-path (317562c) with main (6494e75)

Open in CodSpeed

@LadyBluenotes
LadyBluenotes force-pushed the perf/zod-validation-fast-path branch from 572e1ad to 0a079c5 Compare September 10, 2026 16:48
@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedzod@​4.6.110010010096100

View full report

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