I’ve noticed that when either webpack (in watch mode) or webpack-dev-server is running, each process consistently consumes about 50%% CPU. This seems relatively high for something that should be sitting relatively idly waiting for files to change. Is this a webpack limitation or a node one? Thanks!
7 thoughts on “High CPU usage”
Comments are closed.
I think maybe this was due to
fsevents
not being installed properly? I have it installed now and CPU usage seems to be much lower.Yes, it could be related to fsevents not being installed properly. I had an old version of node.js (v0.10.26) and fsevents didn’t install. My CPU usage was 130%% all the time when running gulp from webpack. I reinstalled node to v5.3.0 and reinstalled all the modules. This time fsevents installed correctly. And my CPU usage from gulp (devpack) is back to zero when idle.
FWIW, on OSX, if you’re locked to an older version of
chokidar
(part of watchpack) it won’t installfsevents
automatically. Runningnpm install fsevents
worked for me and dropped my CPU usage completely.You can see if webpack is polling using
sudo fs_usage -f pathname -w
and watch for lines withnode
at the end. If you see thousands of them, you’re polling.just came across this and found it very helpful in fixing my own problems.
i wonder if it would be possible for webpack to provide a warning when file polling is going nuts.
Facing the same issue but on Windows 10, and I can’t install fsevents, it’s an OS X-only module…
edit: ignoring node_modules solved it for me
I’m on Windows 10, and after installing the latest version of Node, I was able to turn polling off and get my cpu usage to drop to <1%% (from ~8%% constantly). I couldn’t do this before because polling-mode was the only way it would consistently pick up my file-saves.
Now I can, I assume because the latest version of Node had the fsevents module install correctly this time. (I know at one point before I was getting a warning about fsevents not being installed or something, which I don’t seem to get anymore–I forget where I saw it, so I can’t verify for certain)
45+%% cpu usage reduced to <8%% by adding
ignored: /node_modules/
towatchOptions
config option of webpack-dev-server