performance optimization #1
Open
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.
Platform
Prepare
Enable rspack tracing and JS profiler features by environment. This PR provides a simple implementation, more detail see
For Development
Steps
Optimization
From the js profiler, we can find that the red block is
openBrowserblocking the nodejs main thread and causing rspack to get stuck. We should be able to let theopenBrowserexecute in another thread to avoid this.openBrowser. The rebuild takes about 2.5s, but 1.8s are consumed in the make stage.It seems that many files are rebuilt on hot start, from the
NormalModule:buildparameter we can find that most of them come from thechangelogdirectory.From the source code, I found that the changelog directory will be regenerated when loadContent is called at https://github.com/facebook/docusaurus/blob/main/website/src/plugins/changelog/index.ts#L159. And a hot start will regenerate it which will make the persistent cache rebuild them since the modification time of those files has been updated.
Here are some solutions I can think of:
Performance
After disable
openBrowserand configexperiments.cache.snapshot.immutablePaths = [/\/changelog\//]