Skip to content

perf(start-plugin-core): avoid repeated work in Rsbuild compilation scans - #8799

Open
mattcosta7 wants to merge 4 commits into
TanStack:mainfrom
mattcosta7:perf/rsbuild-normalization-passes
Open

mattcosta7 wants to merge 4 commits into
TanStack:mainfrom
mattcosta7:perf/rsbuild-normalization-passes

Conversation

@mattcosta7

@mattcosta7 mattcosta7 commented Oct 23, 2026 •

Copy link
Copy Markdown

🎯 Changes

Two passes that run on every Rsbuild compilation did avoidable work.

Client build normalization scanned each chunk's modules twice, once for tsr-split and once for tss-hydrate, calling the native identifier() each time. It now reads both in one scan. The literal-key guards stay separate, so encoded keys and first-value semantics are unchanged; new tests cover repeated, empty, +-encoded and percent-encoded keys, lookalike keys, and concatenation on and off.

Server function metadata replay (finishMake, stage -20) ran serverFnBuildInfoSchema.safeParse on every module's buildInfo, although almost no modules have the field. It now returns early when the field is absent, which was already the result.

Measurement Before After
Metadata replay, 1,665-module dev compilation 5.7 ms 1.0 ms
Normalization, 128 routes, with hydration metadata — ~4% lower
Normalization, 128 routes, route split only — within noise

Normalization numbers are from the new tests/rsbuild/normalized-client-build.bench.ts (real Rspack compilations, 8 and 128 routes, concatenation on and off), same fixture before and after. Client bundle output is unchanged.

Overlap with open PRs

Both halves overlap older open PRs, and I'd rather those land:

So this PR is the small, low-risk fallback if those stay stalled; happy to close it once they move.

Written with an AI coding assistant.

✅ 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

  • Bug Fixes
    • Improved Rsbuild compilation handling for modules without server function metadata. Existing metadata continues to be validated, and invalid metadata is still rejected.

Normalizing the client build scanned every chunk's modules twice, once for
route split queries and once for hydration queries, calling the native
identifier() each time. Read both from one scan with the same literal-key
guards and first-value semantics.

Replaying server function metadata at finishMake validated every module's
buildInfo with zod, even though nearly all modules carry none. Validate only
modules that have the field.
@changeset-bot

changeset-bot Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b277e7b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@tanstack/start-plugin-core Patch
@tanstack/react-start-rsc Patch
@tanstack/react-start Patch
@tanstack/solid-start Patch
@tanstack/vue-start Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between da2adec and b277e7b.

Files selected for processing: 2
  • .changeset/rsbuild-cheaper-compilation-scans.md
  • packages/start-plugin-core/src/rsbuild/start-compiler-host.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Walkthrough

readServerFnBuildInfo now returns null before schema validation when server function metadata is absent. Present metadata continues to use the existing schema validation. A changeset requests a patch release for @tanstack/start-plugin-core.

Changes: Rsbuild metadata handling

Layer / File(s) Summary
Skip validation when metadata is absent
packages/start-plugin-core/src/rsbuild/start-compiler-host.ts, .changeset/rsbuild-cheaper-compilation-scans.md
readServerFnBuildInfo checks for undefined metadata before schema validation. The changeset requests a patch release and describes this update.

Priority: Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Refactor

Possibly related issues

  • TanStack/router issue 8810 — It tracks build-time speed work that includes skipping schema parsing for modules without server-function metadata.

Suggested labels: package: start-plugin-core

Suggested reviewers: schiller-manuel

Merge Risk: Minimal · up to b277e

No actionable merge-blocking risk is identified in the supplied changes.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies an Rsbuild performance change. It is broad because the current summary mainly covers avoiding unnecessary server-function metadata validation, but it remains related to th…
Description check Passed The description includes the required Changes, Checklist, and Release Impact sections. It explains the motivation, implementation, measurements, overlap with other pull requests, testing, AI assistanc…
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.
Full details: Title check

Explanation

The title clearly identifies an Rsbuild performance change. It is broad because the current summary mainly covers avoiding unnecessary server-function metadata validation, but it remains related to the pull request objective.

Full details: Description check

Explanation

The description includes the required Changes, Checklist, and Release Impact sections. It explains the motivation, implementation, measurements, overlap with other pull requests, testing, AI assistance, and changeset. One understanding-code checklist item remains unchecked, but the description is otherwise complete.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Sheraff added a commit that referenced this pull request Oct 25, 2026
…-hydrate query rules

Ports upstream #8799's normalization tests: literal query keys, first value,
+/% decoding, lookalike keys, concatenateModules on and off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mattcosta7
mattcosta7 marked this pull request as ready for review October 29, 2026 03:52

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant