Uses a ton of CPU in polling mode
See original GitHub issueHi,
I’m developing an app and switching over to using Docker containers for some of it. Since I’m running OS X, I’m running Docker in Vagrant and using NFS to share my working directory, then building containers from the code in that directory.
It can be difficult to find a file watcher that works properly over NFS. Nodemon fails, pm2 eats up CPU, but node-supervisor seems to do well by just doing a slow poll. I get great <1% CPU usage watching with supervisor.
Unfortunately, webpack-dev-server with the old watcher doesn’t catch changes at all, so I’m using NewWatchingPlugin. It does catch changes, but it pegs me at about 220% CPU (5 threads)!
I’ve played around with the invocation of Chokidar in DirectoryWatcher. Setting the polling interval to 5000 gets the CPU usage down quite a bit, to about 30%. It is obviously very slow to react, though, and that’s still much higher than I would like.
I stuck a logging statement at the invocation of Chokidar and found that it’s watching about 90-100 directories; every single module my project imports, as well as all of the project folders. It’s easy to see how, with polling, this could get expensive.
Is it possible to:
- Make this more efficient by coalescing into a single polling watcher instead of 100?
- Do the watching instead from the host OS (which can use FSEvents) and signal to webpack inside the container somehow (create a file, have it listen on a port, etc)? Either the host OS could rebuild, or webpack in the container could.
The solution doesn’t have to be super-elegant; this is just a dev environment.
Issue Analytics
- State:
- Created 9 years ago
- Comments:8 (2 by maintainers)

Top Related StackOverflow Question
If you add ignored: /node_modules/, as in this commit https://github.com/webpack/watchpack/commit/b13cefe0c4bf7e75d9b11affe0e77873139b952a into the chokidar.watch options in DirectoryWatcher.js you get a massive reduction in CPU usage when polling.
I’ve created a PR which adds an
ignoredoption: https://github.com/webpack/watchpack/pull/23