Skip to content

perf(rsbuild): skip ordinary RPC source masking - #861

Merged
trueadm merged 1 commit into
mainfrom
jon/fix/skip-ordinary-rpc-masking
Aug 26, 2026
Merged

trueadm merged 1 commit into
mainfrom
jon/fix/skip-ordinary-rpc-masking

Conversation

@jonkwheeler

@jonkwheeler jonkwheeler commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • skip allocation-heavy syntax masking for ordinary Rsbuild project modules that contain neither RPC declaration token
  • preserve the existing syntax-aware mask and compiler validation for every possible module server candidate
  • publish the build-time improvement as a patch changeset for @octanejs/rsbuild-plugin

Why

Rsbuild's RPC owner discovery scans every project .tsx and .tsrx file. The common no-owner path split each entire source into a character array, rewrote it, and joined it again only to prove that module server was absent.

On a synthetic 32 MiB project of 256 ordinary components, the same seven-sample harness improved from a 332.6 ms median to 25.4 ms (92.4% lower, 13.1x faster). A control where every file contained both words still took 341.2 ms, confirming that candidate validation was not skipped or made artificially faster.

Changes

  • use allocation-free substring checks as a conservative candidate gate
  • retain masking and compilation whenever both tokens occur, including comment-separated declarations
  • add a patch changeset

Validation

  • pnpm format:check (targeted Prettier check passed for both changed files)
  • pnpm typecheck (tsgo --noEmit -p packages/rsbuild-plugin-octane/tsconfig.typecheck.json passed)
  • pnpm test (targeted Rsbuild validation used instead)
  • pnpm sync
  • Rsbuild non-browser suite: 6 files, 40 tests passed
  • final discovery/helper suite: 1 file, 10 tests passed
  • localhost integration rerun: 3 server/dev cases passed; 2 browser cases could not run locally because Playwright Chromium revision 1228 is not installed

Risk / follow-ups

  • Actual candidates pay two native substring scans before their existing mask and compiler pass. This is the rare path, and the both-token control showed no meaningful shortcut.
  • CI remains responsible for the two Chromium-backed integration cases unavailable locally.

Provenance

  • An agent produced this diff (agent-authored)

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Low Risk
Performance-only early return in discovery; candidate detection behavior stays the same when both tokens are present.

Overview
Rsbuild RPC owner discovery now bails out of ownsServerModule with cheap includes checks for module and server before running maskNonCode and server compilation on every scanned .tsx / .tsrx file.

Files that lack both substrings skip the allocation-heavy character-array masking path entirely. When both appear—including comment-separated module server candidates—the existing mask, regex gate, and compiler validation still run unchanged.

A patch changeset records the build-time improvement for @octanejs/rsbuild-plugin.

Reviewed by Cursor Bugbot for commit 173bd20. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work labels Aug 26, 2026
@jonkwheeler
jonkwheeler marked this pull request as ready for review August 26, 2026 14:34
@jonkwheeler
jonkwheeler requested a review from trueadm August 26, 2026 14:47
@trueadm
trueadm merged commit 5a8f0d4 into main Aug 26, 2026
50 checks passed
@trueadm
trueadm deleted the jon/fix/skip-ordinary-rpc-masking branch August 26, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants