hyperkit icon indicating copy to clipboard operation
hyperkit copied to clipboard

High CPU when using file watchers and volumes

Open JeremyLoy opened this issue 4 years ago • 4 comments

My project (A small, ~8 endpoint express app) uses typescript compiler file watching (tsc --watch) and nodemon for local development.

The combination of these two processes running outside of docker, on MacOS, uses approximately 5% of one CPU core when idle, 25% cpu of one core when compiling/reloading, and finishes in approximately 2 seconds.

We've been experimenting with developing inside of Docker, as an alternative to using Node Version Manager and juggling multiple projects with different node versions.

Here is the example script we have been running:

yarnWatch.sh


#!/bin/sh

tsc --watch
nodemon app.js
docker run \
  --volume $(pwd):/proj \
  --workdir /proj \
  --rm \
  --publish 3030:3030 \
  --detach \
  node:12.16.1-alpine scripts/yarnWatch.sh

When running in this way, the hyperkit process idles at 200% CPU (my guess is 100% of two cores), uses 500%cpu when compiling/relaoding, and finishes in 20 seconds.

My hypothesis is this is some sort of bottleneck regarding volumes, as running the app in a custom built image has no performance problems.

JeremyLoy avatar Mar 24 '20 01:03 JeremyLoy

Did you find any workaround?

manast avatar Nov 23 '20 09:11 manast

Seeing very similar results (just for PHP). > 100% cpu is being used on a process that's essentially idle. Seems to be a Mac thing from googling this?

fatso83 avatar Oct 08 '21 22:10 fatso83

I also see this with Docker for Mac and nodemon — block I/O, CPU, and memory spiral out of control

adamkdean avatar Jun 02 '22 12:06 adamkdean

We experienced exactly same thing with watchfiles and uvicorn. This is a ampere arm64 host. I think something is notify handling.

baishi avatar Aug 10 '22 16:08 baishi