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
Tiberiusmoon
Posts: 147
Joined: 10 Feb 2023, 05:05

Extended understanding of system timers in Windows.

Post by Tiberiusmoon » 14 Jun 2023, 06:05

In this post I want to give more understanding of timers, there is a post made in 2021 which explains a bit about it but there is more the subject matter which I want to cover here.
There are a combination of timer settings you have to consider as some may conflict.

Old post: viewtopic.php?f=10&t=8535

Win32 Priority Separation (WPS)

In short WPS manages your processes with three varying attributes, I will explain how it works then show how you can change this.
1. Interval length (long or short)
2. Processor time (varied or fixed)
3. Priority ratio (foreground and background)

If you wish to read more see the PDF source at the bottom of the post.

Further on we will be talking about Hex numbers and binary, since not everyone can't remember Hex to binary conversions I will post this useful link: https://www.aqua-calc.com/convert/numbe ... -to-binary

A WPS setting is made of 6 binary numbers which have two numbers for each attribute.
Interval being the first two, Processor time the second two and Priority the last two. (AABBCC)
Binary numbers that are less than 6 will equal 0, so 1100 = 110000.

Interval length uses 01 for long intervals and 10, 11 and 00 for short intervals.
Processor time uses 10 for fixed intervals and 01, 11 and 00 for variable intervals.
Priority uses 00 for equal and fixed process priority -Overrides Processor time-, 01 for 2:1 ratio priority of foreground tasks to background tasks and 10 or 11 for a 3:1 ratio.

(Navigation context is Windows 11)
If you navigate to Settings > System > About > Advanced System Settings > Advanced > Performance > Advanced.
Under Processor scheduling is a very basic setting of WPS, if you ever wish to revert WPS changes to default you can just select either of the two settings and apply.
The two default options make the following binary codes:

Background services: Hex 18 = 11000
Short interval, Variable time with equal and fixed priority.
Since priority is 00 it overrides the variable time, so even a Hex Binary code of 1c/11100 and 38/111000 are equal to 18/11000.

Programs: Hex 26 = 100110
Short interval, Variable time with a 3:1 ratio to foreground tasks.
Equivelant Hex Binary codes are 13/10011 and 4c/1001100.

To keep this short I will list all the Hex codes, the old post has duplicate binary numbers and any other Hex code will be a variation that equals the same code for reasons as mentioned above.

Code: Select all

2A Hex = Short, Fixed , 3:1 ratio. (101010)
29 Hex = Short, Fixed , 2:1 ratio. (101001) 
28 Hex = Short, Fixed , Equal & fixed. (101000)
26 Hex = Short, Variable , 3:1 ratio. (100110)
25 Hex = Short, Variable , 2:1 ratio. (100101)
34 Hex = Long, Fixed, 3:1 ratio. (110100)
32 Hex = Long, Fixed, 2:1 ratio. (110010)
38 Hex = Long, Fixed, Equal & fixed. (111000)
16 Hex = Long, Variable, 3:1 ratio. (010110)
15 Hex = Long, Variable, 2:1 ratio. (010101)
How to apply the WPS codes:

Open your Registry editor and navigate here:

Code: Select all

Computer\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\PriorityControl
In the right panel is a registry entry called "Win32PrioritySeparation" right click it and select modify.
Select the Hexadecimal and type in your chosen Hex code like so:
Image
Once done restart your system to apply.

System clocks and system ticks

By default a PC will run on a system clock in order to synchronize processes, at times these clocks will delay/pause in order to maintain a consistent rate which causes stutters.
This is where system ticks can improve performance but these tweaks can be different on a per system basis.
For example HPET can be disabled via driver or in BIOS but not all motherboards have that option in BIOS.

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)

High Precision Event Timer (HPET)
Is a high resolution system timer that uses interrupts in order to maintain a rate of time.

Real Time Clock(RTC) and APCI PMT (PMT)
An outdated timer which can decrease performance.

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:
Combination A
bcdedit /set useplatformclock no
bcdedit /set disabledynamictick Yes
bcdedit /set tscsyncpolicy enhanced
Restart your system.

For anything else it requires testing as I do not have an AMD or older Intel system.
Combination B
bcdedit /set useplatformclock false
bcdedit /set tscsyncpolicy legacy
bcdedit /set disabledynamictick no
Combination C
bcdedit /set useplatformclock true
bcdedit /set tscsyncpolicy enhanced
bcdedit /set disabledynamictick yes
Restart system.

If you have desyncing issues then disable useplatformtick with no instead of yes.
If you get increased latency issues/stutters disable the tscsyncpolicy with: bcdedit /deletevalue tscsyncpolicy.
Mix and match these commands to see if they are right for your setup.

Relationship between timers and WPS compatibility

When using both there are some factors to consider.
The command "bcdedit /set disabledynamictick" is a power saving function which when disabled prevents a variable tick and reduces input latency and improves consistency.
So this means you need to avoid using Variable process time in your WPS Hex Binary codes or it can cause BSOD and game crashes underload. (error code 0x22)

If you use long intervals in your Hex Binary codes while using a higher resolution timer you can potentially bottleneck performance/benefit of that tweak with WPS and vice versa.

If you have a good combination of settings for AMD systems post it in the comments to help others. :D

Sources:
1. https://www.techpowerup.com/forums/atta ... df.163992/ (Win32PrioritySeparation 09/09/2008 PDF)
2. https://sites.google.com/view/melodystw ... et-tsc-pmt (Timer related settings and their relationship with each other 2022)
3. https://en.wikipedia.org/wiki/Time_Stamp_Counter (Time stamp counter Wiki)
4. https://en.wikipedia.org/wiki/High_Prec ... vent_Timer (High Precision Event Timer Wiki)
5. https://en.wikipedia.org/wiki/Real-time_clock (Real Time Clock Wiki)
Last edited by Tiberiusmoon on 24 Feb 2024, 05:53, edited 1 time in total.

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

Re: Extended understanding of system timers in Windows.

Post by Tiberiusmoon » 14 Jun 2023, 09:36

To help people decide on a Hex Binary code the priorty of the code maybe a significant use case factor.

For instance if you have a busy CPU with no process organisation, -no process lasso for example- a 3:1 or 2:1 ratio may show better improvements in games.

However, you may find the equal or 2:1 ratios may benefit games with anticheat such as Valorant which could impact performance if the anticheat does not have similar priority to the game.

If you organise your CPU then a equal ratio while organising all other process priority separately should give you the best control and performance.

bumbeen
Posts: 86
Joined: 25 Apr 2023, 14:35

Re: Extended understanding of system timers in Windows.

Post by bumbeen » 14 Jun 2023, 10:33

thanks for this post. my preference is hex16 long quantum 3x boost. Most CPU bound game do not use 100% of all core while running, but usually 100% of one core and then some 30%-70% of another core, smaller % of a 3rd, 4th core, etc. My thinking is to minimize context switching on the whole and give the fewest opportunity for another thread to run on that busiest core with max quantum time.

It may not make a difference, probably thread scheduler is smart enough to recognize the busy game thread should not be interrupted regardless of quantum size and put other thread on other core anyway.

Related to this, also why I like disable SMT/hyperthreading on CPU. I don't know if thread scheduler is smart enough to keep 2nd busiest thread from executing on same core with the 1st busiest thread only on separate logical core, disable SMT ensures there is no contention for same core between threads

sherifmagdy32
Posts: 121
Joined: 08 Jan 2022, 23:43

Re: Extended understanding of system timers in Windows.

Post by sherifmagdy32 » 14 Jun 2023, 10:34

Tiberiusmoon wrote:
14 Jun 2023, 06:05
In this post I want to give more understanding of timers, there is a post made in 2021 which explains a bit about it but there is more the subject matter which I want to cover here.
There are a combination of timer settings you have to consider as some may conflict.

Old post: viewtopic.php?f=10&t=8535

Win32 Priority Separation (WPS)

In short WPS manages your processes with three varying attributes, I will explain how it works then show how you can change this.
1. Interval length (long or short)
2. Processor time (varied or fixed)
3. Priority ratio (foreground and background)

If you wish to read more see the PDF source at the bottom of the post.

Further on we will be talking about Hex numbers and binary, since not everyone can't remember Hex to binary conversions I will post this useful link: https://www.aqua-calc.com/convert/numbe ... -to-binary

A WPS setting is made of 6 binary numbers which have two numbers for each attribute.
Interval being the first two, Processor time the second two and Priority the last two. (AABBCC)
Binary numbers that are less than 6 will equal 0, so 1100 = 110000.

Interval length uses 01 for long intervals and 10, 11 and 00 for short intervals.
Processor time uses 10 for fixed intervals and 01, 11 and 00 for variable intervals.
Priority uses 00 for equal and fixed process priority -Overrides Processor time-, 01 for 2:1 ratio priority of foreground tasks to background tasks and 10 or 11 for a 3:1 ratio.

(Navigation context is Windows 11)
If you navigate to Settings > System > About > Advanced System Settings > Advanced > Performance > Advanced.
Under Processor scheduling is a very basic setting of WPS, if you ever wish to revert WPS changes to default you can just select either of the two settings and apply.
The two default options make the following binary codes:

Background services: Hex 18 = 11000
Short interval, Variable time with equal and fixed priority.
Since priority is 00 it overrides the variable time, so even a Hex Binary code of 1c/11100 and 38/111000 are equal to 18/11000.

Programs: Hex 26 = 100110
Short interval, Variable time with a 3:1 ratio to foreground tasks.
Equivelant Hex Binary codes are 13/10011 and 4c/1001100.

To keep this short I will list all the Hex codes, the old post has duplicate binary numbers and any other Hex code will be a variation that equals the same code for reasons as mentioned above.

Code: Select all

2A Hex = Short, Fixed , 3:1 ratio. (101010)
29 Hex = Short, Fixed , 2:1 ratio. (101001) 
28 Hex = Short, Fixed , Equal & fixed. (101000)
26 Hex = Short, Variable , 3:1 ratio. (100110)
25 Hex = Short, Variable , 2:1 ratio. (100101)
34 Hex = Long, Fixed, 3:1 ratio. (110100)
32 Hex = Long, Fixed, 2:1 ratio. (110010)
38 Hex = Long, Fixed, Equal & fixed. (111000)
16 Hex = Long, Variable, 3:1 ratio. (010110)
15 Hex = Long, Variable, 2:1 ratio. (010101)
How to apply the WPS codes:

Open your Registry editor and navigate here:

Code: Select all

Computer\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\PriorityControl
In the right panel is a registry entry called "Win32PrioritySeparation" right click it and select modify.
Select the Hexadecimal and type in your chosen Hex code like so:
Image
Once done restart your system to apply.

System clocks and system ticks

By default a PC will run on a system clock in order to synchronize processes, at times these clocks will delay/pause in order to maintain a consistent rate which causes stutters.
This is where system ticks can improve performance but these tweaks can be different on a per system basis.
For example HPET can be disabled via driver or in BIOS but not all motherboards have that option in BIOS.

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)

High Precision Event Timer (HPET)
Is a high resolution system timer that uses interrupts in order to maintain a rate of time.

Real Time Clock(RTC) and APCI PMT (PMT)
An outdated timer which can decrease performance.

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.

For anything else it requires testing as I do not have an AMD or older Intel system.
Disable HPET Driver and in the BIOS.
bcdedit /set useplatformclock no
bcdedit /set disabledynamictick Yes
bcdedit /set tscsyncpolicy enhanced
bcdedit /set useplatformtick yes
Restart system.
If you have desyncing issues then disable useplatformtick with no instead of yes.
If you get increased latency issues/stutters disable the tscsyncpolicy with: bcdedit /deletevalue tscsyncpolicy.
Mix and match these commands to see if they are right for your setup.

Relationship between timers and WPS compatibility

When using both there are some factors to consider.
The command "bcdedit /set disabledynamictick" is a power saving function which when disabled prevents a variable tick and reduces input latency and improves consistency.
So this means you need to avoid using Variable process time in your WPS Hex Binary codes or it can cause BSOD and game crashes underload. (error code 0x22)

If you use long intervals in your Hex Binary codes while using a higher resolution timer you can potentially bottleneck performance/benefit of that tweak with WPS and vice versa.

If you have a good combination of settings for AMD systems post it in the comments to help others. :D

Sources:
1. https://www.techpowerup.com/forums/atta ... df.163992/ (Win32PrioritySeparation 09/09/2008 PDF)
2. https://sites.google.com/view/melodystw ... et-tsc-pmt (Timer related settings and their relationship with each other 2022)
3. https://en.wikipedia.org/wiki/Time_Stamp_Counter (Time stamp counter Wiki)
4. https://en.wikipedia.org/wiki/High_Prec ... vent_Timer (High Precision Event Timer Wiki)
5. https://en.wikipedia.org/wiki/Real-time_clock (Real Time Clock Wiki)
Thanks for taking the time to explain this really appreciate the effort behind it
but i think this explanation for Win32 Priority Separation is much simpler and much easier to understand
Source Calypto's Latency Guide: https://docs.google.com/document/d/1c2- ... mrau4/edit
Attachments
Untitled.png
Untitled.png (51.88 KiB) Viewed 11797 times

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

Re: Extended understanding of system timers in Windows.

Post by Tiberiusmoon » 14 Jun 2023, 10:46

sherifmagdy32 wrote:
14 Jun 2023, 10:34

SNIP
This is just a broad guide to latency, this post is about timers and the potential conflicts of incorrect settings.

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

Re: Extended understanding of system timers in Windows.

Post by Tiberiusmoon » 14 Jun 2023, 10:53

bumbeen wrote:
14 Jun 2023, 10:33
thanks for this post. my preference is hex16 long quantum 3x boost. Most CPU bound game do not use 100% of all core while running, but usually 100% of one core and then some 30%-70% of another core, smaller % of a 3rd, 4th core, etc. My thinking is to minimize context switching on the whole and give the fewest opportunity for another thread to run on that busiest core with max quantum time.

It may not make a difference, probably thread scheduler is smart enough to recognize the busy game thread should not be interrupted regardless of quantum size and put other thread on other core anyway.

Related to this, also why I like disable SMT/hyperthreading on CPU. I don't know if thread scheduler is smart enough to keep 2nd busiest thread from executing on same core with the 1st busiest thread only on separate logical core, disable SMT ensures there is no contention for same core between threads
Nice, I had a rather specific issue with Intel CPUs and process management, the efficency core and Performance cores do not share a process.
I had left my browser running in the background while playing games and the browser was assigned one P core and all other E cores.
Since it didnt share the workload it pegged Core 0 causing massive stutters. lol

sherifmagdy32
Posts: 121
Joined: 08 Jan 2022, 23:43

Re: Extended understanding of system timers in Windows.

Post by sherifmagdy32 » 14 Jun 2023, 10:55

Tiberiusmoon wrote:
14 Jun 2023, 10:46
sherifmagdy32 wrote:
14 Jun 2023, 10:34

SNIP
This is just a broad guide to latency, this post is about timers and the potential conflicts of incorrect settings.
Yes i know as i mentioned it is only for the w32 separation explanation section i feel this one is just simpler and easier to understand
but you did an awesome work on the rest of the guide

"When using both there are some factors to consider.
The command "bcdedit /set disabledynamictick" is a power saving function which when disabled prevents a variable tick and reduces input latency and improves consistency.
So this means you need to avoid using Variable process time in your WPS Hex Binary codes or it can cause BSOD and game crashes underload. (error code 0x22)"

This made my game stutter when i tested variable values and unfortunately i didn't see anyone talking about it before.

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

Re: Extended understanding of system timers in Windows.

Post by Tiberiusmoon » 14 Jun 2023, 11:36

"Yes i know as i mentioned it is only for the w32 separation explanation section i feel this one is just simpler and easier to understand
but you did an awesome work on the rest of the guide"

Eh can't say I agree on it being easier to understand tbh, but each to their own I guess.
I made this post to update and expand on what was posted on these forums, there are probably thousands of guides like Calypto outside of Blurbusters you could refrence that do it differently.

"When using both there are some factors to consider.
The command "bcdedit /set disabledynamictick" is a power saving function which when disabled prevents a variable tick and reduces input latency and improves consistency.
So this means you need to avoid using Variable process time in your WPS Hex Binary codes or it can cause BSOD and game crashes underload. (error code 0x22)"

"This made my game stutter when i tested variable values and unfortunately i didn't see anyone talking about it before."

A lot of people are following tweaking guides without much knowledge on what they actually do and when they do they just assume it doesn't work for their PC without knowing why.
The disableddynamictick conflict with variable WPS can be one of them.
Understanding how games react certain setting configurations are what help expand our knowledge of these tweaks, otherwise they becomes shots in the dark.

User avatar
axaro1
Posts: 627
Joined: 23 Apr 2020, 12:00
Location: Milan, Italy

Re: Extended understanding of system timers in Windows.

Post by axaro1 » 14 Jun 2023, 13:39

Is it possible to force 0.5ms timer resolution without ISLC?
XL2566K* | XV252QF* | LG C1* | HP OMEN X 25 | XL2546K | VG259QM | XG2402 | LS24F350[RIP]
*= currently owned



MONITOR: XL2566K custom VT: https://i.imgur.com/ylYkuLf.png
CPU: 5800x3d 102mhz BCLK
GPU: 3080FE undervolted
RAM: https://i.imgur.com/iwmraZB.png
MOUSE: Endgame Gear OP1 8k
KEYBOARD: Wooting 60he

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

Re: Extended understanding of system timers in Windows.

Post by Tiberiusmoon » 14 Jun 2023, 14:56

axaro1 wrote:
14 Jun 2023, 13:39
Is it possible to force 0.5ms timer resolution without ISLC?
Yes, I know an app that installs a timer resolution service that runs each time you start up.
Download this and select install timer resolution service: https://github.com/SanGraphic/QuickBoost/releases

In terms of memory cleaning functionality, memreduct does a better job.

If you wish to stop the service you just go to windows services and you will find it there to disable.

Post Reply