-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
perf(faster): Upgrade Rspack to 1.3.6+, fix persistent cache perf issue #11114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
✅ [V2]
To edit notification comments on pull requests, go to your Netlify site configuration. |
|
Size Change: +356 B (0%) Total Size: 11.3 MB
ℹ️ View Unchanged
|
⚡️ Lighthouse report for the deploy preview of this PR
|
|
Size Change: +315 B (0%) Total Size: 11.7 MB ℹ️ View Unchanged
|
Collaborator
Author
|
Will merge it later, once v1.3.6 is officially released |
This was referenced Apr 18, 2025
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
CLA Signed
Signed Facebook CLA
pr: performance
This PR does not add a new behavior, but existing behaviors will be more memory- / time-efficient.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
The Rspack persistent cache was enabled in Docusaurus with #10931
Unfortunately, the performance improvement wasn't significant because code-generated files would always recompile/reload, even if their content/hash didn't change.
After our feedback in web-infra-dev/rspack#9413, with v1.3.6, Rspack is changing its default strategy for the persistent cache, using a file content hash instead of the filesystem lastModified time.
This PR significantly improves the efficiency of the Rspack persistent cache, so that warm rebuilds will bundle the app faster, by avoiding recompiling all the code-generated files.
Many code-generated files are generated by Docusaurus core in
website/.docusaurus, but they can also be generated by plugins that generate MDX files (often the case of docsgen plugin like OpenAPI).This upgrade affects the speed of both the dev server and the production build.
On our own website, we use a custom changelog plugin which is a fork of the blog plugin that does MDX codegen. We can see that it's now faster on prod builds, and the persistent cache also significantly improve the startup time of the dev server (on 2nd startups).
Benchmarks
Impact of the persistent cache on total build times:
Note:
Cold build
Small site
yarn clear:website hyperfine --runs 5 'DOCUSAURUS_NO_PERSISTENT_CACHE=true yarn build:website:fast' Benchmark 1: DOCUSAURUS_NO_PERSISTENT_CACHE=true yarn build:website:fast Time (mean ± σ): 15.878 s ± 1.077 s [User: 49.951 s, System: 8.975 s] Range (min … max): 14.507 s … 17.140 s 5 runsMedium site
yarn clear:website hyperfine --runs 5 'DOCUSAURUS_NO_PERSISTENT_CACHE=true yarn build:website --locale en' Benchmark 1: DOCUSAURUS_NO_PERSISTENT_CACHE=true yarn build:website --locale en Time (mean ± σ): 37.432 s ± 1.609 s [User: 130.666 s, System: 20.958 s] Range (min … max): 34.742 s … 38.823 s 5 runsWarm build - before upgrading
Small site
yarn clear:website yarn build:website:fast hyperfine --runs 5 'yarn build:website:fast' Benchmark 1: yarn build:website:fast Time (mean ± σ): 10.442 s ± 0.878 s [User: 33.773 s, System: 7.245 s] Range (min … max): 9.524 s … 11.599 s 5 runsMedium site
yarn clear:website yarn build:website --locale en hyperfine --runs 5 'yarn build:website --locale en' Benchmark 1: yarn build:website --locale en Time (mean ± σ): 29.721 s ± 2.407 s [User: 103.784 s, System: 19.332 s] Range (min … max): 27.340 s … 33.297 s 5 runsWarm build - after upgrading
Small site
yarn clear:website yarn build:website:fast hyperfine --runs 5 'yarn build:website:fast' Benchmark 1: yarn build:website:fast Time (mean ± σ): 9.309 s ± 1.063 s [User: 30.241 s, System: 7.210 s] Range (min … max): 7.975 s … 10.314 s 5 runsMedium site
yarn clear:website yarn build:website --locale en hyperfine --runs 5 'yarn build:website --locale en' Benchmark 1: yarn build:website --locale en Time (mean ± σ): 24.992 s ± 3.595 s [User: 96.350 s, System: 19.542 s] Range (min … max): 22.522 s … 31.272 s 5 runsTest Plan
Local benchmarks on my M3 computer:
It should also speed up CI rebuilds
Test links
https://deploy-preview-11114--docusaurus-2.netlify.app/