Extended understanding of system timers in Windows.

Everything about latency. Tips, testing methods, mouse lag, display lag, game engine lag, network lag, whole input lag chain, VSYNC OFF vs VSYNC ON, and more! Input Lag Articles on Blur Busters.
User avatar
Chief Blur Buster
Site Admin
Posts: 11653
Joined: 05 Dec 2013, 15:44
Location: Toronto / Hamilton, Ontario, Canada
Contact:

Re: Extended understanding of system timers in Windows.

Post by Chief Blur Buster » 14 Jun 2023, 23:27

Tiberiusmoon wrote:
14 Jun 2023, 10:46
This is just a broad guide to latency, this post is about timers and the otential conflicts of incorrect settings.
BTW:
I was asked if timers and lag are separate or same topics.

My take: It's an overlapping venn diagram. It's a big rabbit hole -- often clocks/timers are intractably linked to certain elements of latency.

Where better/worse timers can create better lagfeel effects.

The way the game clock (gametime) renders into graphics and then displays on the screen for hitting eyeballs (photontime), is a refresh rate race bottleneck. Variances in this timing (including from timer inaccuracies) creates jitter and lagfeel issues. gametime:photontime relative accuracy is essentially the the god of jitter & latency variances -- and must stay relatively sub-millisecond exact to prevent human visible effects in the refresh rate race. So the universes can overlap. Lag variances from timing jitter. And timing jitter = lag variances. Even a 1ms inaccuracy = 8 pixel jitter at 8000 pixels/sec mouse flick turn. On clearer-motion & higher-resolution displays, those sub-millisecond divergences between gametime versus photontime create jitterfeel/lagfeel issues.

From what I see, the topic title talks about timers, and timers are allowed topics in the latency forum because of how better/worse timers can create lagfeel-effect changes.

It's tough to exercise best judgement when talking about timers vs talking about latency. Not all timer related things affect lagfeel, but there are instances where it does enroach into visible/feelable latency effects.
Head of Blur Busters - BlurBusters.com | TestUFO.com | Follow @BlurBusters on Twitter

Image
Forum Rules wrote:  1. Rule #1: Be Nice. This is published forum rule #1. Even To Newbies & People You Disagree With!
  2. Please report rule violations If you see a post that violates forum rules, then report the post.
  3. ALWAYS respect indie testers here. See how indies are bootstrapping Blur Busters research!

thizito
Posts: 13
Joined: 14 Mar 2014, 09:46

Re: Extended understanding of system timers in Windows.

Post by thizito » 15 Jun 2023, 01:14

disabling hpet in 2023, and im the brazilian here

blurryboba
Posts: 5
Joined: 09 Mar 2023, 04:43

Re: Extended understanding of system timers in Windows.

Post by blurryboba » 17 Jun 2023, 05:38

what if i disable hpet in windows and in bios?

I LOVE TIN FOIL
Posts: 19
Joined: 13 May 2023, 09:07

Re: Extended understanding of system timers in Windows.

Post by I LOVE TIN FOIL » 17 Jun 2023, 14:41

Cannot achieve .500us with the high precision timer off, no matter timer combo.

User avatar
kyube
Posts: 132
Joined: 29 Jan 2018, 12:03

Re: Extended understanding of system timers in Windows.

Post by kyube » 17 Jun 2023, 18:41

https://github.com/amitxv/PC-Tuning/blo ... ule-change
Timer res changes don't work on newer windows releases except Server 2022 and W11

https://github.com/djdallmann/GamingPCS ... /README.md

Don't mess with bcdedit, it's not worth it considering the sheer amount of hardware combinations.

User avatar
Tiberiusmoon
Posts: 147
Joined: 10 Feb 2023, 05:05

Re: Extended understanding of system timers in Windows.

Post by Tiberiusmoon » 18 Jun 2023, 01:52

blurryboba wrote:
17 Jun 2023, 05:38
what if i disable hpet in windows and in bios?
The system will start using the TSC timer if you have a modern Intel CPU, anything else may cause desync issues.


laginput
Posts: 1
Joined: 18 Jun 2023, 10:51

Re: Extended understanding of system timers in Windows.

Post by laginput » 18 Jun 2023, 10:58

I LOVE TIN FOIL wrote:
17 Jun 2023, 14:41
Cannot achieve .500us with the high precision timer off, no matter timer combo.
Bcdedit /set hypervisorlaunchtype auto.

Why it rounds up a timer to .1 or 0.5 I have no idea, just something I stumbled upon reinstalling windows with factory reset bios settings.

Bloedboer
Posts: 26
Joined: 14 Nov 2021, 07:43

Re: Extended understanding of system timers in Windows.

Post by Bloedboer » 21 Jun 2023, 01:57

Timer combinations:

For a modern Intel CPU using a TSC timer should be the best option.
In Device manager, look for the High Precision Event timer and disable the driver.
If you have the option to disable HPET in the BIOS then do so.
Open Terminal (Admin) then input the following commands:
bcdedit /set useplatformclock no
bcdedit /set disabledynamictick Yes
bcdedit /set tscsyncpolicy enhanced
Restart your system.

Where can I find this combination on the melody google page? I’ve been trying to figure these timer settings out.

noskill
Posts: 4
Joined: 21 Jun 2023, 09:40

Re: Extended understanding of system timers in Windows.

Post by noskill » 21 Jun 2023, 10:11

Tiberiusmoon wrote:
14 Jun 2023, 06:05

Timers:

Time stamp counter (TSC):
Is a high resolution, low overhead tick timer with a few flaws which can be caused by powersaving, frequency.
However, recent intel CPUs include a constant rate TSC which counts the passage of time rather that the number of CPU clocks. (this removes the need for UsePlatformTick and wont be shown in the bootloader or terminal)
Modern TSC has no flaws. Earlier implementations of it would not count at the same rate on SMP (multiprocessor boxes) which led to timing issues. It's very fast, since it's easy to read with a simple assembly instruction.

QueryPerformanceCounter and QueryPerformanceFrequency will use whatever HAL reports to use, ie: RDTSC, RDTC, RDTSCI, 8254/LAPIC/HPET, etc.
High Precision Event Timer (HPET)
Is a high resolution system timer that uses interrupts in order to maintain a rate of time.
HPET devices can support two interrupt routing modes. In one mode, the comparators are additional interrupt sources with no particular system role. Many vendors ship BIOSes that don't route HPET interrupts at all, which prevents use of that mode. They support the other legacy replacement mode where the first two comparators block interrupts from 8254 timers and from the RTC.

HPET has some uses, but it's mostly in userland apps. Unless you have a seriously broken TSC (ie: drift), HPET would be the way to go. TSC is fast, and it works.

If TSC is completely broken, then HPET will be used to drive clocks.
Real Time Clock(RTC) and APCI PMT (PMT)
An outdated timer which can decrease performance.
ACPI is not really outdated (It's still apart of the ACPI specification). On HAL (Windows 7+), if it detects TSC errata (unable to properly sync, etc), it will drive timekeeping with ACPI (or even LAPIC). It has a 24‐bit counter that increments at 3.579545MHz. Not as bad as the RTC / PIT, though.

Timer combinations:
For a modern Intel CPU using a TSC timer should be the best option.
The defaults are the best option.
In Device manager, look for the High Precision Event timer and disable the driver.
That is a stub for applications to use it for their own purposes, not system wide.
If you have the option to disable HPET in the BIOS then do so.
Disabling it for everything is not a good idea.
bcdedit /set tscsyncpolicy enhanced
This is not a good idea to force tscsyncpolicy. The defaults will determine if the the CPU offers;

Constant TSC. This means means that the TSC does not change with CPU frequency changes, however it does change on C state transitions.
Invariant. As described in the Intel manual: “The invariant TSC will run at a constant rate in all ACPI P-, C- and T-states”
Non-stop. The Non-stop TSC has the properties of both Constant and Invariant TSC.
None of the above. The TSC changes with the C, P and S state transitions.

Forcing a sync policy if the hardware can't do TSC synchronizing will lead to very odd system behavior.

Post Reply