[Docker Desktop] Investigate Mac CPU performance
Tell us about your request CPU performance on Mac is a long standing issue, we have investigated this in the past but want to dedicate time to re-invetsigate this and try and find a fix
Which service(s) is this request for? Desktop
Tell us about the problem you're trying to solve. What are you trying to do, and why is it hard? We keep spiking to 100% CPU and this isn't good, no one likes their laptop taking off
Are you currently working around this issue? N/A Additional context N/A Attachments https://github.com/docker/for-mac/issues/1759 https://github.com/docker/for-mac/issues/3499 https://github.com/docker/for-mac/issues/2601
Ben, for purposes of documentation of pain points with Docker on Mac, I wanted to make sure there was a reference back to these complaints.
https://github.com/docker/for-mac/issues/3499
Thanks -Alan
Please add docker/for-mac#4392 to this list.
Thanks @aguedeney and @cculianu - when we move this into in progress I will link back the tickets we are using in for-mac to highlight where we will be discussing with everyone and also where we will be seeking fresh logs for issues :) please feel free to add other cases here as you think appropriate!
Please add docker/for-mac#4064.
The primary issue with CPU that I have seen relates to volume mounts, transfused, and heavy IO workloads. I have observed this a lot of times and inside the VM it is usually transfused using the CPU.
See this on why mounts use lots of CPU. Namely:
A Linux system call such as open or read that accesses bind-mounted files in a container must be. - turned into a FUSE message in the Linux VFS - proxied over a virtio socket by transfused - forwarded onto a UNIX domain socket by HyperKit - deserialized, dispatched and executed as a macOS system call by osxfs The entire process then takes place in reverse to return the result of the macOS system call to the container.
See this on why mounts use lots of CPU.
This definitely makes sense for bind mounts because it's having to go in and out of the VM to interface with the host filesystem, but I'm still seeing high CPU usage after we switched to using named volumes and that should all be inside of the VM, but I'm still seeing high CPU usage when things are sitting idle, so is there any similar :cached/:delegated tags for named volumes to help with performance issues there?
This issue is too broad. Some people may suffer from mounts CPU performance, but other have 100% cpu after prune command in this issue: https://github.com/docker/for-mac/issues/4064
Thanks to all the responses! We will start our investigation on this in the next ~2 weeks! Watch out for incoming questions on some of the for-mac issues. We won't respond to posts in here with logs etc but will use this to share updates as we make progress :)
Hope this helps in some way.
I was running into CPU issues as well and noticed something weird happening with volumes. I created three volumes in my compose file, one for the project directory, one to ignore node_modules, and another to mount a specific node_module.
It works as expected, a file from the specific node_module that I modified locally was copied to the container. Likewise I modified a file in another node_module and the change was not copied to the container. Everything works fine.
The issue came when I did a docker-compose restart, the other node_module that should have been ignore was copied into the container, and my laptop fans were taking off. Every file in node_modules after that point was copied over to the container even though I specified it not to.
I did investigating a few months ago so the reproduction steps might be off, but there was definitely an issue with volumes copying files that it was not supposed to.
- volumes
- ./:/src
- /src/node_modules
- ./node_modules/express:/src/node_modules/express
I would like to highlight that https://github.com/docker/for-mac/issues/3499#issuecomment-623960890 has a concrete suspicion of potentially bugged code that might be easy to investigate (with OCAML knowledge).
The primary issue with CPU that I have seen relates to volume mounts, transfused, and heavy IO workloads. I have observed this a lot of times and inside the VM it is usually transfused using the CPU.
I would also like to add that this is not the only cause. I do sometimes see docker spike to at remain at 100% without any containers running. Definitely no high IO workload in that case, pure "home" usage.
I've also had times where the Docker process was using 100% CPU indefinitely when no containers were running.
@schellj , can you do a diagnose when it happens? (if the whale menu is responding of course).
I you cannot use the UI, you can still do it with cli command:
/Applications/Docker.app/Contents/MacOS/com.docker.diagnose gather -upload
@ebriney I haven't had any issues with Docker for Mac using a lot of CPU unexpectedly since early May - see https://github.com/docker/for-mac/issues/4064#issuecomment-625293060, but I did a couple of diagnostics when I was - see https://github.com/docker/for-mac/issues/4064#issuecomment-574391283 and https://github.com/docker/for-mac/issues/4064#issuecomment-574431375 (I made some other relevant comments in that issue as well).
I installed the edge build (with spindump) and uploaded this diagnostic: 0D3FCEE0-663F-4A5E-8DA2-1B79B6746B54/20200626175354
The Kubernetes containers were running (with nothing to manage), nothing from my side, and Docker used 50% CPU.
My Diag Id with spindump 80E081FA-7763-4245-BB3F-15814B31E0BB/20200627174556
Another diag ID F2F1BBBF-4BF7-4158-BCFA-0C29469D1E33/20200630084358
Here's another one with only 5-10% but it still seems like a lot with no containers running on a decent MBP: A913E1F9-1085-4C2B-A79D-4B6862C0EA1E/20200630095026
Another diag C39B37CE-DA64-46FE-B4ED-3A714CE9CC62/20200701075247 with spindump version.
Using Big Sur but I feel no differences from Catalina…
Another diag: 93B23EAA-7413-4ACB-8278-F008093AD412/20200701154406 I don't think I'm using spindump version, still reading up on this ticket, but my mac is about to take off and I've had a number of crashes lately. I suspect that they're related to docker, but that's just a guess on my part.
Thanks for those reports, will compute them and see what we can get from them