Verify the monotonic nature of Environment.TickCount under various conditions in OSX
Environment.TickCount uses 'mach_absolute_time' to get the system up time in terms of milliseconds. But 'mach_absolute_time' uses RDTSC to get the current time stamp and the value can drift overtime back and forth (ie strictly not monotonic).
But in the code we are rounding off nanosecond measurement from 'mach_absolute_time' into milliseconds. This makes the TickCount value to be non-decreasing ie. any jump back and forth by mach_absolute_time is offset by this rounding off.
As an experiment, I ran both mach_absolute_time and monotonic function clock_get_time in a loop for 10 million times and rounding off both values to milliseconds. The value returned by mach_absolute_time was always non-decreasing and same as the value returned by clock_get_time.
But there are a number of frequency-changing techniques still possible
- CPU frequency scaling
- S3 power switching
- Current thread migrating to a different core
Try and find if Environment.TickCount is still monotonic under these conditions. dotnet/coreclr#1269
Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.
This process is part of the experimental issue cleanup initiative we are currently trialing. Please share any feedback you might have in the linked issue.
This issue will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.