perf(start-plugin-core): speed up rsbuild client build normalization #8588
main fromrefs/pull/8588/head·opened 🎯 Changes#
normalizeRspackClientBuild converts the Rspack client compilation into the data used to build the Start manifest. It runs on every Rsbuild build and on every dev rebuild. This PR makes it faster for builds with many chunks. The output does not change.
- Chunk and chunk group properties (
files,auxiliaryFiles,groupsIterable,chunks,childrenIterable) are now read once per call. Rspack builds a new collection on every read, and the previous code read them many times per chunk. - Modules are now read only from chunks that contain a route-split or hydration module. The previous code called
getChunkModulesfor every chunk.
Benchmarks#
Median of 21 runs of normalizeRspackClientBuild on generated apps, Rspack 2.2.3, production unless noted:
| App | Chunks | Chunk groups | main | This PR | Speedup |
|---|---|---|---|---|---|
| Routes and shared vendor chunks | 760 | 481 | 61.1 ms | 14.3 ms | 4.3x |
| Large | 2,456 | 901 | 131.8 ms | 36.5 ms | 3.6x |
| Large (development) | 2,456 | 901 | 138.6 ms | 37.3 ms | 3.7x |
| Shared modules in route chunks | 1,397 | 901 | 97.0 ms | 39.4 ms | 2.5x |
| Many non-route async chunks | 3,245 | 3,101 | 235.1 ms | 53.4 ms | 4.4x |
For each app, the output was compared with main on Rspack 2.0.0, 2.1.1 and 2.2.3 and was identical.
Tests#
- New unit tests in
normalized-client-build.test.tsuse a small fake chunk graph. They check that:- imports and dynamic imports are listed in the same order as before (this test also passes on
main); - modules are read only from chunks with a route-split or hydration module;
- each chunk and chunk group property is read at most once.
- imports and dynamic imports are listed in the same order as before (this test also passes on
@tanstack/start-plugin-coretest:unit,test:typesandtest:eslintpass.- These Rsbuild e2e suites pass:
- react-start
rsbuild,rsc-rsbuildandhmr deferred-hydration(production and dev)- solid-start
deferred-hydration css-inline, with and without transform assets
- react-start
✅ 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
- Start manifest generation is faster for Rsbuild client builds containing many chunks, reducing build-time overhead in larger applications. This improvement preserves the generated manifest’s route and hydration information.
- 1
View your CI Pipeline Execution ↗ for commit aa5c89c783adb51c14cd622e0861e3ed639fa34b
Command Status Duration Result nx affected --targets=test:eslint,test:unit,tes...✅ Succeeded 23m View ↗ nx run-many --target=build --exclude=examples/*...✅ Succeeded 2m 9s View ↗
☁️ Nx Cloud last updated this comment at
2026-10-02 08:56:50UTCMore templates
- tanstack-router-react-example-authenticated-routes
- tanstack-router-react-example-authenticated-routes-firebase
- tanstack-router-react-example-basic
- tanstack-router-react-example-basic-default-search-params
- tanstack-router-react-example-basic-devtools-panel
- tanstack-router-react-example-basic-file-based
- tanstack-router-react-example-basic-non-nested-devtools
- tanstack-router-react-example-react-query
- tanstack-router-react-example-basic-react-query-file-based
- tanstack-router-react-example-basic-ssr-file-based
- tanstack-router-react-example-basic-ssr-streaming-file-based
- tanstack-router-react-example-basic-virtual-file-based
- tanstack-router-react-example-basic-virtual-inside-file-based
- tanstack-router-react-example-deferred-data
- tanstack-router-i18n-paraglide
- tanstack-router-react-example-kitchen-sink
- tanstack-router-react-example-kitchen-sink-file-based
- tanstack-router-react-example-kitchen-sink-react-query
- tanstack-router-react-example-kitchen-sink-react-query-file-based
- tanstack-router-react-example-large-file-based
- tanstack-router-react-example-location-masking
- tanstack-router-react-example-navigation-blocking
- tanstack-router-react-example-quickstart
- tanstack-router-react-example-quickstart-esbuild-file-based
- tanstack-router-react-example-quickstart-file-based
- tanstack-router-react-example-quickstart-rspack-file-based
- tanstack-router-react-example-quickstart-webpack-file-based
- router-monorepo-react-query
- router-mono-simple
- router-mono-simple-lazy
- tanstack-router-react-example-scroll-restoration
- tanstack-search-validator-adapters
- tanstack-start-example-bare
- tanstack-start-example-basic
- tanstack-start-example-basic-auth
- tanstack-router-react-example-basic-authjs
- tanstack-start-example-basic-cloudflare
- tanstack-start-example-basic-react-query
- tanstack-start-example-basic-rsbuild
- tanstack-start-example-basic-static
- tanstack-start-bun-hosting
- tanstack-start-example-clerk-basic
- tanstack-start-example-convex-trellaux
- tanstack-start-example-counter
- tanstack-start-i18n-paraglide
- tanstack-start-example-large
- tanstack-start-example-material-ui
- tanstack-start-example-next-migration
- tanstack-start-example-rscs
- tanstack-start-streaming-data-from-server-functions
- tanstack-start-example-supabase-basic
- tanstack-start-tailwind-v4
- tanstack-start-example-trellaux
- tanstack-start-example-workos
- tanstack-router-react-example-view-transitions
- tanstack-router-react-example-with-framer-motion
- tanstack-router-react-example-with-trpc
- tanstack-router-react-example-with-trpc-react-query
- tanstack-router-solid-example-authenticated-routes
- tanstack-router-solid-example-authenticated-routes-firebase
- tanstack-router-solid-example-basic
- tanstack-router-solid-example-basic-default-search-params
- tanstack-router-solid-example-basic-devtools-panel
- tanstack-router-solid-example-basic-file-based
- tanstack-router-solid-example-basic-non-nested-devtools
- tanstack-router-solid-example-basic-solid-query
- tanstack-router-solid-example-basic-solid-query-file-based
- tanstack-router-solid-example-basic-ssr-file-based
- tanstack-router-solid-example-basic-ssr-streaming-file-based
- tanstack-router-solid-example-basic-virtual-file-based
- tanstack-router-solid-example-basic-virtual-inside-file-based
- tanstack-router-solid-example-deferred-data
- tanstack-router-solid-i18n-paraglide
- tanstack-router-solid-example-kitchen-sink
- tanstack-router-solid-example-kitchen-sink-file-based
- tanstack-router-solid-example-kitchen-sink-solid-query
- tanstack-router-solid-example-kitchen-sink-solid-query-file-based
- tanstack-router-solid-example-large-file-based
- tanstack-router-solid-example-location-masking
- tanstack-router-solid-example-navigation-blocking
- tanstack-router-solid-example-quickstart
- tanstack-router-solid-example-quickstart-esbuild-file-based
- tanstack-router-solid-example-quickstart-file-based
- tanstack-router-solid-example-quickstart-rspack-file-based
- tanstack-router-solid-example-quickstart-webpack-file-based
- @tanstack/router-solid-mono-simple
- router-solid-mono-simple-lazy
- router-solid-monorepo-solid-query
- tanstack-router-solid-example-scroll-restoration
- tanstack-solid-router-search-validator-adapters
- tanstack-solid-start-example-basic
- tanstack-solid-start-example-basic-auth
- tanstack-solid-start-example-basic-authjs
- tanstack-solid-start-example-basic-cloudflare
- tanstack-solid-start-example-basic-netlify
- tanstack-solid-start-example-basic-nitro
- tanstack-start-example-basic-solid-query
- tanstack-solid-start-example-basic-static
- tanstack-solid-start-bun-hosting
- tanstack-solid-start-example-convex-better-auth
- tanstack-solid-start-example-counter
- tanstack-solid-start-i18n-paraglide
- tanstack-solid-start-example-large
- tanstack-solid-start-streaming-data-from-server-functions
- tanstack-solid-start-example-supabase-basic
- tanstack-solid-start-tailwind-v4
- tanstack-router-solid-example-view-transitions
- tanstack-router-solid-example-with-framer-motion
- tanstack-router-solid-example-with-trpc
- tanstack-router-vue-example-basic-jsx
- tanstack-router-vue-example-basic-file-based-jsx
- tanstack-router-vue-example-basic-file-based-sfc
@tanstack/arktype-adapter
npm i https://pkg.pr.new/@tanstack/arktype-adapter@8588@tanstack/eslint-plugin-router
npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@8588@tanstack/eslint-plugin-start
npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@8588@tanstack/history
npm i https://pkg.pr.new/@tanstack/history@8588@tanstack/nitro-v2-vite-plugin
npm i https://pkg.pr.new/@tanstack/nitro-v2-vite-plugin@8588@tanstack/react-router
npm i https://pkg.pr.new/@tanstack/react-router@8588@tanstack/react-router-devtools
npm i https://pkg.pr.new/@tanstack/react-router-devtools@8588@tanstack/react-router-ssr-query
npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@8588@tanstack/react-start
npm i https://pkg.pr.new/@tanstack/react-start@8588@tanstack/react-start-client
npm i https://pkg.pr.new/@tanstack/react-start-client@8588@tanstack/react-start-rsc
npm i https://pkg.pr.new/@tanstack/react-start-rsc@8588@tanstack/react-start-server
npm i https://pkg.pr.new/@tanstack/react-start-server@8588@tanstack/router-cli
npm i https://pkg.pr.new/@tanstack/router-cli@8588@tanstack/router-core
npm i https://pkg.pr.new/@tanstack/router-core@8588@tanstack/router-devtools
npm i https://pkg.pr.new/@tanstack/router-devtools@8588@tanstack/router-devtools-core
npm i https://pkg.pr.new/@tanstack/router-devtools-core@8588@tanstack/router-generator
npm i https://pkg.pr.new/@tanstack/router-generator@8588@tanstack/router-plugin
npm i https://pkg.pr.new/@tanstack/router-plugin@8588@tanstack/router-ssr-query-core
npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@8588@tanstack/router-utils
npm i https://pkg.pr.new/@tanstack/router-utils@8588@tanstack/router-vite-plugin
npm i https://pkg.pr.new/@tanstack/router-vite-plugin@8588@tanstack/solid-router
npm i https://pkg.pr.new/@tanstack/solid-router@8588@tanstack/solid-router-devtools
npm i https://pkg.pr.new/@tanstack/solid-router-devtools@8588@tanstack/solid-router-ssr-query
npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@8588@tanstack/solid-start
npm i https://pkg.pr.new/@tanstack/solid-start@8588@tanstack/solid-start-client
npm i https://pkg.pr.new/@tanstack/solid-start-client@8588@tanstack/solid-start-server
npm i https://pkg.pr.new/@tanstack/solid-start-server@8588@tanstack/start-client-core
npm i https://pkg.pr.new/@tanstack/start-client-core@8588@tanstack/start-fn-stubs
npm i https://pkg.pr.new/@tanstack/start-fn-stubs@8588@tanstack/start-plugin-core
npm i https://pkg.pr.new/@tanstack/start-plugin-core@8588@tanstack/start-server-core
npm i https://pkg.pr.new/@tanstack/start-server-core@8588@tanstack/start-static-server-functions
npm i https://pkg.pr.new/@tanstack/start-static-server-functions@8588@tanstack/start-storage-context
npm i https://pkg.pr.new/@tanstack/start-storage-context@8588@tanstack/valibot-adapter
npm i https://pkg.pr.new/@tanstack/valibot-adapter@8588@tanstack/virtual-file-routes
npm i https://pkg.pr.new/@tanstack/virtual-file-routes@8588@tanstack/vue-router
npm i https://pkg.pr.new/@tanstack/vue-router@8588@tanstack/vue-router-devtools
npm i https://pkg.pr.new/@tanstack/vue-router-devtools@8588@tanstack/vue-router-ssr-query
npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@8588@tanstack/vue-start
npm i https://pkg.pr.new/@tanstack/vue-start@8588@tanstack/vue-start-client
npm i https://pkg.pr.new/@tanstack/vue-start-client@8588@tanstack/vue-start-server
npm i https://pkg.pr.new/@tanstack/vue-start-server@8588@tanstack/zod-adapter
npm i https://pkg.pr.new/@tanstack/zod-adapter@8588commit:
aa5c89cMerging this PR will degrade performance by 14.02%#
:warning: Different runtime environments detected
Some benchmarks with significant performance changes were compared across different runtime environments, which may affect the accuracy of the results.
❌ 1regressed benchmark✅ 190untouched benchmarks⏩ 3skipped benchmarks1Warning
Please fix the performance issues or acknowledge them on CodSpeed.
Performance Changes#
Mode Benchmark BASEHEADEfficiency ❌ Simulation hydrate restored route state and mixed Links (react)213.4 ms 248.2 ms -14.02% Tip
Investigate this regression by commenting
@codspeedbot fix this regressionon this PR, or directly use the CodSpeed MCP with your agent.
Comparingguru-irl:perf/rsbuild-client-build-capture(aa5c89c) withmain(1f0f20a)Footnotes#
-
3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
-
The performance benchmark was executed on 2 different machine configs. The other 2 checks are failing with 403s
@schiller-manuel can I get a review? This cuts hot reloads by ~30% in large applications
Sign in to join this conversation.
Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository: TanStack/router/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
0d724f22-7a12-413d-af3d-13243beba842📥 Commits
Reviewing files that changed from the base of the PR and between 1f0f20a3206a28365d74fd2485b9a8eedbf74dd0 and aa5c89c783adb51c14cd622e0861e3ed639fa34b.
📒 Files selected for processing (3)
.changeset/rsbuild-client-build-capture.mdpackages/start-plugin-core/src/rsbuild/normalized-client-build.tspackages/start-plugin-core/tests/rsbuild/normalized-client-build.test.tsIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Walkthrough#
Rsbuild client build normalization now memoizes chunk and group graph reads and limits route and hydration metadata extraction to relevant chunks. Tests cover normalized metadata and graph-read limits.
Changes#
Rsbuild Client Build Normalization
packages/start-plugin-core/src/rsbuild/normalized-client-build.tspackages/start-plugin-core/src/rsbuild/normalized-client-build.ts,packages/start-plugin-core/tests/rsbuild/normalized-client-build.test.ts,.changeset/rsbuild-client-build-capture.mdPriority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Refactor
Merge Risk: ⚪ Minimal · up to
aa5c8No merge-blocking issue was established for this normalization change; it is ready to merge after normal checks.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
Full details: Docstring Coverage
Explanation
Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 2 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches
🧪 Generate unit tests (beta)
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