question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

High CPU usage while running on OS X

See original GitHub issue

After running npm start, the node process consumes ~40% CPU on my machine:

activity_monitor__all_processes_

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.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:10
  • Comments:31 (15 by maintainers)

github_iconTop GitHub Comments

5reactions
gaearoncommented, Dec 5, 2016

Closing then. If you’re having issues, try:

  1. Removing node_modules
  2. Updating react-scripts to the latest version in package.json (make sure you follow the migration instructions in changelog for every release you’re skipping)
  3. Updating npm (npm i -g npm@latest) or Yarn (yarn self-update)
  4. Running npm install (or yarn)
3reactions
ggregoirecommented, Nov 16, 2016

Can confirm here.

I updated from node 6.8.1 to node 7.1.0 yesterday and now the node process consumes 100% CPU on my machine.

screen shot 2016-11-16 at 15 40 02

I didn’t find anything relative to CPU usage and node 7 in Webpack issues.

I’m on El Capitan + latest version of CRA.

@gaearon @dceddia Should we reopen the issue or create a new one?

Edit: For those who have the same problem, you can downgrade with brew switch node x.x.x and list all the versions installed with brew info node.

Read more comments on GitHub >

github_iconTop Results From Across the Web

5 Ways to Fix High CPU Usage on macOS - MakeUseOf
5 Ways to Fix High CPU Usage on macOS · 1. Update Software and Restart Your Mac · 2. Use Activity Monitor to...
Read more >
How to lower CPU usage on Mac - Setapp
Find out how you can control CPU usage on your Mac at any time by optimizing and quitting unnecessary processes.
Read more >
How to reduce CPU usage on Mac - CleanMyMac X
High CPU usage on your Mac means your system will slow down and suffer from decreased performance; we've got all the troubleshooting tips ......
Read more >
high cpu usage even without apps running - Apple Community
The system is using a very high percentage of the CPU. The bar graph shows mostly red, indicating that system processes (rather than...
Read more >
How to Fix High CPU Usage on macOS 10.15 Catalina
Sometimes, when macOS 10.15 receives updates, especially security updates, it may result in high CPU usage. This update not only slows down your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found