https://PR43703 - std::steady_clock::now() frequently overflows on Windows
I'm putting this up for review because I'm not seeing an easy way to test this - and because I don't have a windows box handy.
Differential D69314
Bug fix for PR#43703 rprichard on Oct 22 2019, 11:06 AM. Authored by
Details
https://PR43703 - std::steady_clock::now() frequently overflows on Windows I'm putting this up for review because I'm not seeing an easy way to test this - and because I don't have a windows box handy.
Diff Detail Event TimelineComment Actions I tested this patch, and it appears to fix the overflow problem. (FWIW, I tested using https://gist.github.com/rprichard/bcff3b3fb0451207dc9f31ccbab938df on Wine and on Windows 10. For both targets, the performance counter frequency was 10MHz, so counter.QuadPart * nano::den had previously wrapped around about every 1845 seconds.) Comment Actions @rprichard Thanks for testing this on Windows. Do you think it's possible to make that test program run for a shorter amount of time so that it can be added to our test suite (i.e. do you think the test would still be relevant if we made it run for a shorter amount of time)? Comment Actions I suppose a test would only need to sleep for a second or two total to exercise the new part1-vs-part2 logic. I'm not sure how much of the existing test would still be relevant. Can the computation be split out from the Query calls, though? If we had an internal (Freq, Counter) -> time_point function, we could test that quickly. I think this function assumes that the performance counter frequency is less than about 2**63 / 10**9, about 9.22GHz. It was 10MHz on the two targets I saw, but comments on the Internet suggest that it's sometimes 3MHz. I think this assumption is OK. |