-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Threading] Always round up when converting std::chrono::durations. #61352
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
Conversation
We were inadvertently rounding down, which was fine almost 100% of the time, but on Windows where the timer resolution is only 1ms, it made the test _very slightly_ flaky because we were asking to wait for 9ms rather than 10ms, then checking we'd waited at least 10ms. We should explicitly round up, for that reason. rdar://100236038
@swift-ci Please test |
Hmmm. Seems this wasn't the only problem on Windows making the test flaky. I wonder if the server applied a time adjustment during the |
No, I don't think the time adjustment explanation is the right one. That shouldn't really be happening because we're using Let's try increasing the system tick rate during the test. I'll run the tests a few times to make sure it works. |
@swift-ci Please test Windows platform |
c008d75
to
a9f0758
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, once it works.
@swift-ci Please test Windows platform |
a9f0758
to
fe639b5
Compare
@swift-ci Please test Windows platform |
Windows' behaviour wrt `Sleep` family functions can be odd. Apparently, if you specify a time lower than a system tick, they can return early. This makes the test flaky when it shouldn't be. To fix it, we use the Multimedia functions to adjust the system tick count as low as we can get it. rdar://100236038
fe639b5
to
10ab608
Compare
rdar://100236038
@swift-ci Please test Windows platform |
Rather than bodging the test to make it more robust, fix the functions in the Threading layer to behave the same as they do on other platforms, i.e. to guarantee that they always wait *at least* the amount of time you asked for. rdar://100236038
@swift-ci Please test Windows platform |
Woo! That seems to have worked. |
@swift-ci please smoke test |
We were inadvertently rounding down, which was fine almost 100% of the time, but on Windows where the timer resolution is only 1ms, it made the test very slightly flaky because we were asking to wait for 9ms rather than 10ms, then checking we'd waited at least 10ms.
We should explicitly round up, for that reason.
rdar://100236038