High CPU usage while running on OS X
Created by: dceddia
After running npm start
, the node
process consumes ~40% CPU on my machine:
I found that setting a polling interval in the the WebpackDevServer helped:
new WebpackDevServer(compiler, {
historyApiFallback: true,
hot: true, // Note: only CSS is currently hot reloaded
publicPath: config.output.publicPath,
quiet: true,
// added this:
watchOptions: {
poll: 1000
}
})
Here were the settings I tried, and the resulting CPU usage:
poll: 1000 => 4-6% CPU
poll: 500 => 8-10% CPU
poll: 250 => 14-16% CPU
There's a tradeoff between CPU usage and how snappy the dev experience feels. To me, 1000ms felt sluggish, but 500ms felt pretty good. I couldn't discern much difference between 500ms and 250ms.
It seems like adding some kind of polling interval would be a good idea to reduce the CPU usage.