rspack: [Bug]: watcher blocks CPU after each rebuild
System Info
ystem: OS: macOS 14.5 CPU: (10) arm64 Apple M1 Pro Memory: 167.59 MB / 32.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 20.11.0 - ~/.volta/tools/image/node/20.11.0/bin/node Yarn: 4.1.0 - ~/.volta/tools/image/yarn/1.22.10/bin/yarn npm: 10.2.4 - ~/.volta/tools/image/node/20.11.0/bin/npm Browsers: Chrome: 127.0.6533.99 Safari: 17.5 npmPackages: @rspack/cli: 1.0.0-beta.1 => 1.0.0-beta.1 @rspack/core: 1.0.0-beta.1 => 1.0.0-beta.1 @rspack/plugin-react-refresh: 1.0.0-beta.1 => 1.0.0-beta.1
Details
In our setup after each interactive rebuild the watcher is restarted and blocks the CPU for ~2 seconds. Subsequently HMR or live reloading is delayed for this amount of time.
It looks like watching is restarted from scratch after every rebuild here: https://github.com/web-infra-dev/rspack/blob/2bd905d47e731772365637188c929f5371e60267/packages/rspack/src/node/NodeWatchFileSystem.ts#L66
while it is not necessary and the watcher instance can be reused (watchpack supports watch to be called again so that it can only create watchers that don’t exists).
Reproduce link
No response
Reproduce Steps
N/A
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 30 (22 by maintainers)
bump
@jerrykingxyz @hardfist Since the added/removed compilation dependencies are now exposed, I can contribute the fix for the watcher, if you haven’t started working on it yet.
yes, https://github.com/web-infra-dev/rspack/issues/7490#issuecomment-2273955633 did call watch
@vkurchatkin-miro it seems create watcher itself shouldn’t cost too much but new watcher need to rewatch the old files that will cost time, can you help check whether the 1-2s is spent on
@vkurchatkin-miro can you share cpu-profile of before | after reuse watcher