for-mac icon indicating copy to clipboard operation
for-mac copied to clipboard

Hyperkit process on MacOS continuously using approx 50% CPU

Open evoncken opened this issue 8 years ago • 67 comments

Expected behavior

With no user workload / containers running, expect CPU usage to be very low.

Actual behavior

"hyperkit" process using aprox. 50% CPU all the time

Information

Diagnostics ID: 1582F6B0-78F2-4F39-9BDC-67E37D52D34B

Steps to reproduce the behavior

  1. Install Docker for Mac (Edge, with Kubernetes enabled)
  2. Check hyperkit CPU usage in Activity Monitor

evoncken avatar Feb 13 '18 19:02 evoncken

I've also seen the memory usage at the top. About 1.85 GB. Not sure if it is normal.

w4-jungyeol avatar Mar 27 '18 08:03 w4-jungyeol

Still happening on Docker version 18.03.0-ce, build 0520e24

richardthombs avatar Apr 04 '18 04:04 richardthombs

Any updates on this? It's a little bit of a blocker for me to keep this on all the time. It drains my laptop battery when unplugged.

vinayan3 avatar Apr 26 '18 17:04 vinayan3

I think it went away when i shut down a container I forgot about.

anacrolix avatar Apr 30 '18 07:04 anacrolix

This urgently needs to be fixed. It's important to note that while there are many issues about Docker for Mac consuming an insane amount of CPU, those reports seem to be related to actual workloads. But this issues when there are no containers running (other than Kubernetes itself). A simple reset and restart will trigger the problem.

atombender avatar May 28 '18 18:05 atombender

Looking at the actual VM, this seems like a typical distribution of CPU usage among the Kubernetes processes:

18774 18757 root     S     153m   4%   0   7% kube-controller-manager --kubeconf
 1130  1015 root     S     787m  20%   0   6% /usr/local/bin/dockerd -H unix:///
 1016   906 root     S     247m   6%   0   4% kubelet --kubeconfig=/etc/kubernet
11142 11124 root     S     721m  18%   0   3% kube-apiserver --advertise-address
14329 14312 root     S    53468   1%   0   1% kube-scheduler --address=127.0.0.1

First, looking at the logs, something is continuously calling Docker's API with requests such as /v1.31/containers/json. I'm going to assume this is the Kubelet. But the Kubelet doesn't log any activity corresponding to the frequency of requests, and neither does kube-controller-manager. apiserver does log a little bit:

2018-05-28T19:03:15.431464400Z I0528 19:03:15.431266       1 controller.go:105] OpenAPI AggregationController: Processing item v1beta1.compose.docker.com
2018-05-28T19:03:16.387777600Z E0528 19:03:16.387645       1 controller.go:111] loading OpenAPI spec for "v1beta1.compose.docker.com" failed with: OpenAPI spec does not exists
2018-05-28T19:03:16.388078600Z I0528 19:03:16.387994       1 controller.go:119] OpenAPI AggregationController: action for item v1beta1.compose.docker.com: Rate Limited Requeue.
2018-05-28T19:03:17.368711500Z I0528 19:03:17.368437       1 controller.go:105] OpenAPI AggregationController: Processing item v1beta2.compose.docker.com
2018-05-28T19:03:17.371758900Z E0528 19:03:17.371636       1 controller.go:111] loading OpenAPI spec for "v1beta2.compose.docker.com" failed with: OpenAPI spec does not exists
2018-05-28T19:03:17.372081200Z I0528 19:03:17.372001       1 controller.go:119] OpenAPI AggregationController: action for item v1beta2.compose.docker.com: Rate Limited Requeue.
2018-05-28T19:04:16.316600800Z I0528 19:04:16.316422       1 controller.go:105] OpenAPI AggregationController: Processing item v1beta1.compose.docker.com
2018-05-28T19:04:16.321664900Z E0528 19:04:16.321553       1 controller.go:111] loading OpenAPI spec for "v1beta1.compose.docker.com" failed with: OpenAPI spec does not exists
2018-05-28T19:04:16.321878200Z I0528 19:04:16.321822       1 controller.go:119] OpenAPI AggregationController: action for item v1beta1.compose.docker.com: Rate Limited Requeue.
2018-05-28T19:04:17.304634900Z I0528 19:04:17.301377       1 controller.go:105] OpenAPI AggregationController: Processing item v1beta2.compose.docker.com
2018-05-28T19:04:17.311260900Z E0528 19:04:17.306398       1 controller.go:111] loading OpenAPI spec for "v1beta2.compose.docker.com" failed with: OpenAPI spec does not exists
2018-05-28T19:04:17.311302000Z I0528 19:04:17.306541       1 controller.go:119] OpenAPI AggregationController: action for item v1beta2.compose.docker.com: Rate Limited Requeue.

It doesn't seem enough to indicate high CPU usage, but the note about rate-limiting is interesting. strace on the API server also shows a continuous stream of activity, though it appears to be binary (gRPC and/or TLS-encrypted), and so I don't know what it is. I do see that the API server has 91 TCP connections open, which seems excessive.

atombender avatar May 28 '18 19:05 atombender

we are aware of this issue and track it internally. The amount of CPU taken varies from system to system and is only present when Kube is enabled. With Kube enabled a couple of fairly chunky containers are running and it is yet unclear if it is these containers taking up the CPU or interactions with HyperKit

from this thread

would like some public tracking of this issue

tristanpemble avatar May 29 '18 21:05 tristanpemble

I can confirm that this is happening for me too and most of the developers have complained about kubernetes using docker for desktop on their macs causes their computers to get very loud. It happens most frequently when deploying and then begins to quiet down, but it's been over 10 minutes since I used the kubernetes api server, all of the deployed stuff is running without any restarts, and I'm still getting a large amount of cpu used. I get these log lines once a minute from the api server:

I0712 14:28:57.714579       1 controller.go:105] OpenAPI AggregationController: Processing item v1beta1.compose.docker.com
E0712 14:28:57.721750       1 controller.go:111] loading OpenAPI spec for "v1beta1.compose.docker.com" failed with: OpenAPI spec does not exists
I0712 14:28:57.721794       1 controller.go:119] OpenAPI AggregationController: action for item v1beta1.compose.docker.com: Rate Limited Requeue.
I0712 14:28:58.679366       1 controller.go:105] OpenAPI AggregationController: Processing item v1beta2.compose.docker.com
E0712 14:28:58.683655       1 controller.go:111] loading OpenAPI spec for "v1beta2.compose.docker.com" failed with: OpenAPI spec does not exists
I0712 14:28:58.683702       1 controller.go:119] OpenAPI AggregationController: action for item v1beta2.compose.docker.com: Rate Limited Requeue.

jsternberg avatar Jul 12 '18 14:07 jsternberg

Same happens to me and pretty much everyone I know who's using Docker for Mac. Strangely it seems to happen mostly when no container is running.

IngaFeick avatar Jul 24 '18 19:07 IngaFeick

htop in privileged container when Kubernetes is enabled: image

disabled: image

ypresto avatar Jul 26 '18 16:07 ypresto

Any movement on this issue? A fresh install of Docker for Mac on a fresh install of OSX this morning sees CPU usage hovering at 35-50% and Activity Monitor's "Energy Impact" rating for Docker sitting around ~70, which is absurdly high.

Is there anything we users can do to help push this one forward? More data collection maybe, collecting logs or providing profiling output? If there's already a fix that needs tested, is there a way for us to chip in and verify it's working with our setups?

mitchellnemitz avatar Aug 27 '18 14:08 mitchellnemitz

On Mojave (18A377a), I am seeing large amounts of CPU usage (and fan spin) from hyperkit on a fresh install of both Docker stable and experimental (18.06.0-ce-mac69 26398). I did nothing outside of a fresh install, and have not enabled Kubernetes.

dwaite avatar Aug 28 '18 02:08 dwaite

Also experiencing this issue making it annoying to do any sort of Kubernetes work on my Macbook Pro. Battery runtime is cut approximately in half from ~4 hours to 2 hours with Kubernetes running in Docker for Mac.

10.13.6 15" MBP mid 2015

jamilbk avatar Sep 11 '18 19:09 jamilbk

I do hope this is going to be addressed in the near future, even if it requires an upstream patch to one of the k8s components. I see the CPU usage is primarily the kube-controller-manager which spins at about 10% of a core, followed by kube-apiserver at about 7% of a core. etcd and kube-scheduler take another 3% each or so.

HyperKit itself is spinning at 50-60%, so I don't know where the other compute is coming from but it definitely settles down after Kubernetes is disabled.

OSX 10.13.6 Docker 18.09.0-ce-beta1

jnicholls avatar Oct 10 '18 11:10 jnicholls

With a bare kube install, I see ~50% CPU utilization from HyperKit. Inside Hyperkit, the utilization doesn't look that high, but etcd is doing something odd.

2018-10-12_10-04-34

When I shut down Kube, everything goes back to normal.

2018-10-12_10-05-59

I'm running Mojave and Docker Version 18.06.1-ce-mac73 (26764)

if6was9 avatar Oct 12 '18 17:10 if6was9

The same issue reproduces on my mac: Mojave docker-machine version 0.15.0, build b48dc28 hyperkit: 0.20180403 Docker: not installed

ghost avatar Oct 12 '18 19:10 ghost

Same here: Mojave docker-for-mac: 2.0.0.0-beta1-mac75 (27117) Engine: 18.09.0-ce-beta1 Kubernetes: v1.10.3

Any hope of this getting fixed any time soon?

torbjornvatn avatar Oct 24 '18 19:10 torbjornvatn

Same here. Mojave Engine/Client: 18.06.1-ce-mac73 (26764)

teosoft123 avatar Oct 28 '18 17:10 teosoft123

im on high sierra

some update somewhere is causing this issue.

please give love to docker for mac, will give love back

ekhaydarov avatar Oct 31 '18 14:10 ekhaydarov

Same issue: osx: High Sierra docker-for-mac: 2.0.0.0-beta1-mac75 (27117) kubernetes: v1.10.3

Looks to me like there is some hypervisor related issue - load inside the VM is minimal (according to htop), but from the host (osx) it's eating basically as much CPU as I give it (more cores === more load)

Running dtruss on the hyperkit process shows that it's making and failing a ton of psynch_cvwaits:

psynch_cvsignal(0x1048AF180, 0x552FC100552FC200, 0x552FC100)		 = 257 0
psynch_cvwait(0x1048AF180, 0x552FC101552FC200, 0x552FC100)		 = 0 0
psynch_mutexdrop(0x1048AF130, 0xD7D6EF03, 0xD7D6EE00)		 = 0 0
psynch_mutexwait(0x1048AF130, 0xD7D6EF03, 0xD7D6ED00)		 = -673779965 0
psynch_cvwait(0x1048AF180, 0x552FC201552FC300, 0x552FC200)		 = -1 Err#316
psynch_cvwait(0x1048AF180, 0x552FC301552FC400, 0x552FC200)		 = -1 Err#316
psynch_cvsignal(0x7FA570050410, 0x16B0D40016B0D500, 0x16B0D400)		 = 257 0
psynch_cvwait(0x7FA570050410, 0x16B0D40116B0D500, 0x16B0D400)		 = 0 0
psynch_cvsignal(0x1048AF180, 0x552FC400552FC500, 0x552FC200)		 = 257 0
psynch_cvwait(0x1048AF180, 0x552FC401552FC500, 0x552FC200)		 = 0 0
psynch_cvwait(0x1048AF180, 0x552FC501552FC600, 0x552FC500)		 = -1 Err#316

will continue looking into this and will post updates here. FWIW this issue appears to occur with no pods, no deployments (totally stock kubernetes after enabling in Docker). If it helps anyone's investigation, this also occurs with Kubernetes 1.10 on Minikube via Virtualbox (so my guess is that's not related to hyperkit per say, but rather kubernetes 1.10)

erulabs avatar Oct 31 '18 21:10 erulabs