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.

Uses a ton of CPU in polling mode

See original GitHub issue

Hi,

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:

  1. Make this more efficient by coalescing into a single polling watcher instead of 100?
  2. 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:closed
  • Created 9 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

9reactions
kylebyerly-hpcommented, Aug 26, 2015

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.

3reactions
elliottsjcommented, Feb 23, 2016

I’ve created a PR which adds an ignored option: https://github.com/webpack/watchpack/pull/23

Read more comments on GitHub >

github_iconTop Results From Across the Web

Polling procs via net-snmp = high cpu usage - Forum
The problem is I need to monitor about 30-40 processes on this server and in doing that the net-snmp proc eats up a...
Read more >
Why is my vSRX always using 100% CPU?
“vSRX runs DPDK in polling mode, and thus consumes all available CPU. The vFP uses DPDK to continuously poll the NIC queues for...
Read more >
Difference between Interrupt and Polling - GeeksforGeeks
In interrupt, the device notices the CPU that it requires its attention. Whereas, in polling, CPU steadily checks whether the device needs ...
Read more >
Solutions for Consistently High CPU Usage - VMware Docs
Host CPU usage constantly is high. A high CPU usage value can lead to increased ready time and processor queuing of the virtual...
Read more >
How to Fix High CPU Usage - Intel
It's important to remember that high CPU usage while multitasking can be normal. Modern CPUs handle multitasking situations by splitting processes between ...
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