On Tue Sep 9 13:19:22 2025 +0000, Rémi Bernon wrote:
Is this really how we want monotonic_counter to work? AFAIK native RtlQueryPerformanceCounter is mostly just a rdtscp, and although its behavior is hardware-dependent, I'm not sure it should account for suspend time but rather just start counting again from where it was resumed.
It does include suspend time at least in my own testing and according to [MSDN](https://learn.microsoft.com/en-us/windows/win32/sysinfo/acquiring-high-resol...):
QueryPerformanceCounter reads the performance counter and returns the total number of ticks that have occurred since the Windows operating system was started, including the time when the machine was in a sleep state such as standby, hibernate, or connected standby.
It can also be a more abstract and does not need represent a hardware value
Often QueryPerformanceFrequency doesn't return the actual frequency of the hardware tick generator. For example, in some older versions of Windows, QueryPerformanceFrequency returns the TSC frequency divided by 1024; and when running under a hypervisor that implements the hypervisor version 1.0 interface (or always in some newer versions of Windows), the performance counter frequency is fixed to 10 MHz. As a result, don't assume that QueryPerformanceFrequency will return a value derived from the hardware frequency.
`GetTickCount`, etc. similarly include suspend time. The most interesting thing I found though in regards to suspend time counting behavior was that `WaitForSingleObjectEx` and friends *stopped* including suspend time in newer versions (which is a different problem to the one here though):
Windows XP, Windows Server 2003, Windows Vista, Windows 7, Windows Server 2008, and Windows Server 2008 R2: The dwMilliseconds value does include time spent in low-power states. For example, the timeout does keep counting down while the computer is asleep.
Windows 8 and newer, Windows Server 2012 and newer: The dwMilliseconds value does not include time spent in low-power states. For example, the timeout does not keep counting down while the computer is asleep.