-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bad performance of PHP(+xdebug) after sleep and waking up because of clock changing from TSC to HPET #3455
Comments
I started working on a way to easily reproduce this issue outside of my project. My first call was to try to run some C compilation so I created
And run it like that
Where |
More info on this problem. Ran a test php script through
|
So after a lot of |
Nice catch - I have similar issues with big Symfony (+ES) project. Until sleep - everything seems to be OK, after wakeup - 10x degraded performance. I Use docker-sync to eliminate bind mount issues (thinking about mutagen tho), but this thing will happen even without any mounts. Hope, that someone from dev team will take a closer look at it. Now, Docker Desktop is really problematic software to work it - requires workarounds, constant restarts, has timedrifts ... |
I'm having this issue also, on fedora since a while actually (almost 6 months). |
We are having exactly the same issue and it's blocking us from migrating local development to a docker setup. We are on the latest stable version: 2.0.0.3 (31259), Mac 10.14.3. For testing purposes: I have created a small container that runs the following https://blog.packagecloud.io/eng/2017/03/08/system-calls-are-much-slower-on-ec2/ example c script:
After closing the Mac and waiting a minute or 2 the script starts outputting trace information indicating the calls are now system calls. The source of the issue seems to also be that unstable TSC Clocksource.
When I restart docker desktop the problem is gone again. |
Was going to create a new support ticket until I saw this one. I exactly have the same issue, and also with a php project with a lot of mounted files. Only a docker for mac restart fixes the issue! Knowing that most mac user put their mac in sleep mode this will be very annoying. Hope you can find a solution to this. |
Same here. Hoping for a quick fix! |
@m00t: kudos to you. We are experiencing the same problem with The only solution we have now is to restart the docker daemon. |
I've noticed this exact behavior, although I've only just had time to investigate. Typically we run a stack of PHP, MySQL and Apache proxied through Nginx and in my test (which is based off a profiler read-out), I'm using CraftCMS with PHP 7.2. This is a screenshot of the profiler with Docker daemon restarted AND the container stack freshly recreated: ~1.5s to load the page (I am using Mutagen for keeping files in sync). After putting my computer to sleep and waking it up again, the same page reload yielded the following results: ~6 seconds!?! Finally, after restarting Docker I was getting the following output: ~3 seconds... Still not at the original 1.5 seconds. It wasn't until I restarted the docker daemon and re-created my containers that the page load time came back down to 1.5 seconds (Mutagen was left running the entire time). |
I have updated to the latest docker ( edge ) version and the problem still persists in exactly the same manner as described above. 2.0.4.0
|
Tested on the latest docker Edge version, it still falls back to hpet. 2.0.5.0 docker-desktop: |
Until this issue is resolved in stable version, it is impossible to use docker on Mac. |
We’ve been able to use docker on macs as long as we don’t let the Mac sleep. If it sleeps we have to restart docker. |
Yea, I know, but that is not much of a solution, especially on Mac which sleeps a lot and has limited charges. I don't even use Mac, but we have a team that does and I really can't even understand why. It is so limited and weak. |
Indeed. It’s been a real source of frustration for most of us because we use docker alot on laptops. Sleep is very common even when running long jobs. It has to be fixed soon. |
Slightly different problem but I think it might be a problem with OSX itself... Running VBox for a linux VM (so similar situation to Docker) - on OSX sleep and then resume, the whole computer is unusable, requiring a restart... This is some shoddy OSX resume/restart logic I think. Anyway to downgrade OSX to a version which worked? |
@smaudet Never had that issue with vbox. I used for a very long time docker toolbox with nfs enabled and I never had the issue described here. So I doubt it's related. |
If I had to guess, it's an interaction between the three systems, and not something that is exclusively the fault of any one system. It works fine on VMware Linux on OSX, but it doesn't work on Docker Linux on OSX, where Linux and OSX are the same versions for both cases. Perhaps when OSX wakes from a sleep, Linux isn't being told what happened and it doesn't reset the clock stability check properly on Docker, whereas on VMware it is. Since VMware can do it but Docker can't, that suggests OSX isn't to blame alone for this problem. |
@dchassin the curious thing is there isn't an issue on the windows or linux host side of things... perhaps it is partly related to the software? I.e. VMWare catches the sleep event while Docker and VBox don't... Could be hardware too, I've not ruled that out yet (would try to BootCamp windows or linux host and see if the problem persists). |
I have created an issue in the Xdebug repo asking for a way to disable this call to getTimeOfDay as this is just used to timestamp stack entries and I think that 99% of the applications that use Xdebug don't need this info |
Thanks @carlos-granados for your initiative. This could decrease the symptoms of the slow clocksource problem. Since getTimeOfDay is used in many other cases than debugging: It would be great, if this issue on Macs could be solved at the core - so inside docker. (Also there are other low level calls wich are slow in debugging. E.g. getPid.) |
Is there a different clock source that can be used that does not have this problem? |
There are three clock sources available most of the time. I'll try to get around to running some benchmarks with As a side note, here's a couple of helpful bash scripts that we've been using internally lately to at least increase visibility of the issue, which may or may not be useful to some others experiencing this issue. Verifying if this is currently effecting your containers: YELLOW="\033[0;33m"
RED="\033[31m"
RESET="\033[0m"
DOCKER_CLOCK_SOURCE=$(docker exec -ti {my_docker_container} /bin/bash -c 'cat /sys/devices/system/clocksource/clocksource0/current_clocksource | tr -d "[:space:]"')
if [[ ${DOCKER_CLOCK_SOURCE} != "tsc" ]]; then
echo -e "${RED}WARNING!${RESET} - ${YELLOW}Clock drift detected. Please restart Docker Desktop to avoid severe performance issues${RESET}"
fi Automatically killing and restarting Docker for Desktop via CLI: echo "Killing Docker"
osascript -e 'quit app "Docker"';
echo "Restarting Docker"
open -a Docker
echo "Waiting for Docker to start"
while ! docker system info > /dev/null 2>&1; do printf "."; sleep 1; done; printf "\n"; |
I'm currently running into the same issue. Test suite which should run for 2 mins max, runs 11 minutes after sleep. After restarting, it's back to 2 minutes.. 🤔 |
Sometime during the last week Centos:7 slowed down significantly when running gridlabd validation tests, which uses time calls a lot. I wonder if it has anything to do with the change to the clock calls. |
The issue has been open for a few years, but I just wanted to pile on a few more stats since I can tell this will still be a significant source of latency even without Xdebug installed at all. Anecdotally, we noticed a performance hit of anywhere from at least 34% to 61% slower on initial load before OPcache takes over in our tests (see table below). This is still pretty significant, albeit not as grotesque as how badly it affects Xdebug. More details: We're running a complex PHP application with a large number of files. We started investigating this when our Mac developers were reporting significant slowdowns after their MacBooks went to sleep. We found that even after removing the Xdebug extension from PHP, the developers still had a significant decrease in performance after sleeping (about 34% in latency on initial load, suggesting Stats for nerds: Where
|
As nobody has mentioned it yet, this doesn't seem to be an issue on M1, presumably because |
Is there some way to force It looks like the kernel accepts |
I think I figured out a solution! Add Now my containers continue to use the tsc clocksource even after waking from sleep. |
@jfirebaugh I take it you're on MacOS running an older x86 CPU, right? Unfortunately I'm having a hard time reproducing this bug on my current corp-issued machine since it doesn't sleep anymore (only hibernates). |
Wow - that actually worked for me. I put my Intel MBP to sleep overnight and woke up to my app working just as speedy as I left it whereas it's usually incredibly slow until I restart Docker. Thank you so much for sharing!! |
@stephen-turner Should by nice to have it as an option in Docker GUI for Mac :-) |
Confirmed this morning after an overnight sleep that this fix absolutely remedies the problem. Even Thank you, thank you, thank you! |
This completely solves the issue on my 2019 Intel i7 MBP. Can't believe the fix was just a few keystrokes away all these years 🥲. THANK YOU @jfirebaugh! ❤️ |
Adding to the choir of flabbergasted xdebug users. This is awesome. Anyone at docker reading this? Some way of setting that option as a checkbox in the GUI (or even something more obscure, an experimental flag, anything) would be more than welcome. |
Thank you @jfirebaugh, this is a life-saving fix! |
On 14 March 2022 16:54:22 GMT, Stefano Giraldo ***@***.***> wrote:
Thank you @jfirebaugh, this is a life-saving fix!
It works like a charm!
I'll probably write a blog entry, and see if (and where) I can mention this on the Xdebug documention site.
|
@derickr credit @jfirebaugh for his discovery 😄 |
@jfirebaugh and everyone -- thanks for all the investigation work! I think setting tsc=reliable when using hyperkit makes a lot of sense. I've made an experimental build with this change, if you'd like to try it: https://desktop-stage.docker.com/mac/main/amd64/75926/Docker.dmg |
Yes, it works good, but doesn't solve the issue in this topic. You still have to manually add |
@jfirebaugh Big thanks! Your solution saved a lot of time for our team! The main question whether when will Docker fix this 3 years old issue? |
BTW - i noticed a significant performance degradation after upgrading docker-for-mac to 4.6.1. Turns out that it overwrote the change to Clearly we need an official setting for this. |
Good news, this is fixed in Docker Desktop 4.7 (released yesterday). Many thanks to @jfirebaugh for figuring out the solution. |
Is it really fixed? I used to have a lot of Mac OS crashes when putting my macbook into sleep while Docker for Mac was still running. It would always end up in me opening up my laptop and seeing it had rebooted with the alert "Your computer was restarted because of a problem". Not sure if it is related to this issue, but I do know that once I added |
Closed issues are locked after 30 days of inactivity. If you have found a problem that seems similar to this, please open a new issue. Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. |
Expected behavior
Test scenario should always take 30s to complete
Actual behavior
Test scenario takes 30s to complete after Docker for Mac restart, and takes 1m30s-2m to complete after sleep and wakeup.
Information
I have some PHP test scenario for my application I can run to check how good or bad performance is. I also have a linux laptop to compare with. This test in docker on linux completes in 30s. When I restart Docker for Mac, it runs 30s on Docker for Mac as well, but after I put MacBook to sleep and wake it up, the very same test takes 1m30s-2m. And it would take this long until I restart Docker for Mac. After restart, this test takes 30s again. I can reproduce it very reliably every time I try. The very same issue was reported a year ago here: EugenMayer/docker-sync#524
Diagnostic logs
Steps to reproduce the behavior
The text was updated successfully, but these errors were encountered: