-
Notifications
You must be signed in to change notification settings - Fork 799
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
Clock sources are slow to read and imprecise #77
Comments
Amazing bug. Thanks for the details. I am taking this back to the team. Will update here when I have more info. |
What tool did you use to derive those numbers? |
Hi @HenkPoley. I sent the source to Microsoft through other channels. But since people are asking, I've published the source code under the ISC license here: https://github.com/tycho/clockperf |
No obvious improvement on 14393.10:
|
Still a great bug, but unfortunately we did not have enough time to dive into this as much as I would have liked to in this release. As of not it remains on the backlog. |
@russalex Understood. Just wanted to post an update with the latest build. Not trying to force a change ahead of schedule. 😄 |
It's been a while since I did an update on this issue, so let's see how things are in a very recent build of Windows (built April 20th, according to the version stamp). It looks like clock sources have gotten much more expensive (2-3x?), though I'm not sure what system I originally measured on now so these results aren't exactly fair. But then again, I'd expect this more modern system to have unfairly better results, not worse. This system is an Intel Core i7-7820X host, running build 17655:
As an aside... Also, none of the On the plus side, it looks like |
Time for a pseudo-yearly update. Same host hardware as before, but now running on insider preview build number 18348.1 (19h1_release.190226-1407).
Observations:
|
I think that's a separate problem. I'm not particularly concerned with the real time clock as I am with the high resolution clock sources that drat near everything uses. If a monotonic clock costs a lot to read, it'll artificially hurt performance of some benchmarks (e.g. running a workload like In some further testing in the past few days I noticed that |
This has nothing to do with timezones or the realtime clock. |
Yeah, silly Darthie. |
Been following this for a while. Curious @tycho what hardware were you testing on because I find some systems are abysmal wrt clock performance regardless of what is tried. That is in Linux too. |
Just a sec. ago downloaded the code, built and tested. Looks fine for me. A laptop Dell Inspiron 5370 here, Archlinux, kernel 5.6.6, libc 2.31 |
That is what I suspect in some cases - the hardware and or drivers. CPU affinity, CPU speed changes, system clocksource, etc all appear to cause instability that shouldn't be happening. |
This is much better under WSL2, since it doesn't need to rely on Win32 clock sources under the hood:
I'm going to call this resolved since WSL2 seems to be the way forward. |
WSL2 is a lightweight VM. So like other VMs, it gets it's clock source from the host. So what you said is completely wrong. There is an issue however with the clock drifting and is corrected by using So what we can say is "WSL2 uses the Hyper-V clock sync in the backend to the Win32 clock sources, which is much faster and more precise than the clock fetching performed by WSL1." |
You misinterpreted what I said. With WSL1, it had to map all the Linux clock APIs like The clock drift/sync issues you're referring to sounds more like issues with the RTC drifting, which is a different story. And that is orthogonal to the high resolution clock sources. I'm also surprised to hear the RTC is drifting at all with WSL2, as I would have expected that to be handled by some Hyper-V enlightenment. The next time you see it drift, does |
On a normal bare metal Linux system:
On "Bash on Windows", the clock behavior isn't as nice:
To explain the columns a bit:
The Cost(ns) column is the time cost to read that clock in nanoseconds, as measured by the TSC (except when measuring the cost of reading the TSC itself, which is measured by looking at gettimeofday).
Resol is the observable tick rate of the clock.
Mono indicates whether the clock source is monotonic, with an additional restriction. Not only must the clock only move forward, it must never return the same value (i.e. high frequency).
Fail indicates the number of times the clock source failed to advance in >= 200 reads.
Warp indicates the number of times the clock jumped forward by an unexpectedly large span (threshold for this is currently 1ms).
Stal indicates the number of times the clock source failed to advance in more than 1, but less than 200 reads.
Regr indicates the number of times the clock moved backwards. This can happen due to hypervisor behavior, NTP adjustments, and other clock changes. It's extremely bad behavior if you use the clock source for timespan measurement (e.g. profiling, benchmarks, etc).
The text was updated successfully, but these errors were encountered: