none
QueryPerformanceFrequency/QPC in Windows 10 1809 onward RRS feed

  • Question

  • Hi. On Windows 10 1809 is there any way to revert back to QPC using only the value for Invariant TSC instead of the (virtualized? software? hypervisor?) timer value currently showing as 10.000MHz?

    thank you.
    Tuesday, March 26, 2019 11:21 AM

All replies

  • Any details on your machine? Is it real or virtual?

    -- pa

    Tuesday, March 26, 2019 11:01 PM
  • It's real, not a virtual machine. The timer is like this for all other people I've asked using 1809 as well (but they all have intel processors).

    I have an 8700k and a z370 MSI board.

    Wednesday, March 27, 2019 1:17 PM
  • Hello,

    The Time Stamp Counter was once an excellent high-resolution, low-overhead way for a program to get CPU timing information. With the advent of multi-core/hyper-threaded CPUs, systems with multiple CPUs, and hibernating operating systems, the TSC cannot be relied upon to provide accurate results — unless great care is taken to correct the possible flaws: rate of tick and whether all cores (processors) have identical values in their time-keeping registers. There is no promise that the timestamp counters of multiple CPUs on a single motherboard will be synchronized. Therefore, a program can get reliable results only by limiting itself to run on one specific CPU. Even then, the CPU speed may change because of power-saving measures taken by the OS or BIOS, or the system may be hibernated and later resumed, resetting the TSC. In those latter cases, to stay relevant, the program must re-calibrate the counter periodically. 

    Refer to MSDN, the majority of Windows 7 and Windows Server 2008 R2 computers have processors with constant-rate TSCs and use these counters as the basis for QPC. TSCs are high-resolution per-processor hardware counters that can be accessed with very low latency and overhead (in the order of 10s or 100s of machine cycles, depending on the processor type). Windows 7 and Windows Server 2008 R2 use TSCs as the basis of QPC on single-clock domain systems where the operating system (or the hypervisor) is able to tightly synchronize the individual TSCs across all processors during system initialization. On such systems, the cost of reading the performance counter is significantly lower compared to systems that use a platform counter. Furthermore, there is no added overhead for concurrent calls and user-mode queries often bypass system calls, which further reduces overhead. On systems where the TSC is not suitable for timekeeping, Windows automatically selects a platform counter (either the HPET timer or the ACPI PM timer) as the basis for QPC.

    Windows 8, Windows 8.1, Windows Server 2012, and Windows Server 2012 R2 use TSCs as the basis for the performance counter. The TSC synchronization algorithm was significantly improved to better accommodate large systems with many processors. In addition, support for the new precise time-of-day API was added, which enables acquiring precise wall clock time stamps from the operating system.

    >>On Windows 10 1809 is there any way to revert back to QPC using only the value for Invariant TSC instead of the (virtualized? software? hypervisor?) timer value currently showing as 10.000MHz?

    MS doesn't provide any way for us to do this, AFAIK, You could determine whether your processor has an invariant TSC by using one of these:
    Open Command Prompt as Administrator, input Coreinfo.exe. if you get like this:

    'Coreinfo.exe' is not recognized as an internal or external command, operable program or batch file.

    Download 'Coreinfo.exe' from here
    The TSC-INVARIANT info is provided by the Windows Sysinternals Coreinfo.exe utility (www.sysinternals.com). An asterisk means "True".

    You could also use rdtsc or rdtscp processor instruction to directly query the TSC, but MS strongly discourage doing this, because you won't get reliable results on some versions of Windows, across live migrations of virtual machines, and on hardware systems without invariant or tightly synchronized TSCs.

    Best Wishes,

    Jack Zhang


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, May 8, 2019 7:06 AM