How to decrease input lag ( DPC latecy ) tips

User's Guides & Help forum.
User avatar
Lisa_Ann
User lv4
User lv4
Posts: 137
Joined: Sun Nov 28, 2021 17:08
in-game nick: LisaTheAnn
Location: Budapest

How to decrease input lag ( DPC latecy ) tips

Post by Lisa_Ann »

Hello!

I recently bought a new mouse, keyboard and monitor, but I felt that something was not quite right. My ping is fine (I use a CAT 6 S/FTP patch cable from the router to the laptop.

I didn't understand what the problem could be, the mouse button works at 1000 Hz and the monitor at 240 Hz. Then I wondered if there was a program that I could use to see the delays and that's when the whole concept of DPC latency came to my mind, I haven't come across it yet, although I'm not a hardcore gamer.

I decided to share my experience with them because it was useful for me and improved the gaming experience.

I am also using an old Lenovo P50 laptop ( ThinkPad P50 i7-6820HQ/16DDR4/256SSD/Nvidia quadro M2000M/15.6 ) with Windows 10 operating system.

I use quake3 on hardcore with 250 fps based on the tar description. quake-3-config.php

Also, I use the game with ioquake3.x86_64.exe.

So, when I searched for such software, the search engine threw me a program called LAatencyMon.
Check DPC Latency with LatencyMon: http://www.resplendence.com/latencymon
I downloaded the free version, it was enough for me for now. It showed latency times between 600-700 us, which are quite terrible.

I. BIOS: First step configure your bios right: https://www.overclock.net/threads/gamin ... e.1433882/ if you click on the link, you will get more information about bios tweaking.



UEFI vs Legacy boot Legacy with CSM enabled tends to give me a more traditional mouse movement feel, while the times I've tested UEFI with CSM off, it gave me a more floaty mouse cursor type movement. This setting will probably be very subjective to a lot of people depending on what mouse, mouse settings, and surface you use, but my experience so far is that legacy tends to be better with a more classic mouse movement.

1) BCLK: you want this to be 100.00, not 100 point random number. The closest you can get this to 100.00, the better. Many board makers have BCLK overclocking features built into their BIOS to try and cheat at benchmarks for hardware review sites. The Gigabyte z77 UD5H is one example of this. Leaving BCLK at AUTO, or manually setting it to 100.00 gets you an unwanted number like 100.1 on the UD5H. Manually setting it to 100.01 gets me 100.03. This is the closest to a flat 100 I can get on this board due to spread spectrum being a hidden setting. Disable spread spectrum to try and fix the last part if you can.

2) Memory Strap / Memory Multiplier: Since this is an overclocking website, many people love to crank this number as high as it can go. The only problem is, high bandwidth and the resulting high latency is not conducive to a positive game play experience. The ram I have installed can do 2133mhz @ 11-11-11-28, but 1600mhz @ 7-8-7-24 provides a much better feeling mouse response. Some people will claim the difference is impossible to feel, but I assure you that it is, at least once you have eliminated all other sources of high latency in your system. This is also due to 133 vs 100 memory ratios. 100:100 with 1600mhz should obviously provide better results since it matches BCLK. If you cannot tell the difference between changing settings like this in mouse response, you most likely have other latency bottlenecks.

3) Turbo Boost/C-States/EIST/Thermal Monitor/Etc: You want to disable as many of these as possible because they bring a lot of lag. On the Asus Z77 board, using a Steelseries firmware updater for a mouse seems to fail on Win8 if you disable "C3 State Report" and "C6 State Report". I didn't have this issue on the Gigabyte board, so it seems to vary by motherboard.

4) PWM Phase Control - Set this to max phases. There's a noticeable difference between auto with power saving modes turned on and maximum phases on most motherboards.

5) Hyper Threading - If you disable HPET, you most likely do not want to run any virtual cores.

6) Vcore - Usually best to manually set Vcore since it seems to disable dynamic power features on some motherboards. Large difference between manual setting Vcore and auto on my Asus z77, but not as big on Gigabyte z77.

7) PEG Gen3 Slot Configuration: I get better results by manually setting this instead of leaving it on auto. Set it to Gen3 if you have an Ivy Bridge or higher CPU + a PCI-E 3.0 GPU, otherwise, use Gen2.

8) Execute Disable Bit I disable it just because the odds of any negative effects outweigh the security benefit. Traditionally a setting disabled by overclockers anyway.

9) Intel Virtualization Technology - disabled for any gaming PC obviously. Virtualization and it's services tend to be resource heavy and no reason to have it on for a gaming PC.

10) 1394 controller - disable in order to reduce DPC latency unless you actually use it for some reason, probably 99% of people don't.

11) xHCI pre-boot driver / xHCI mode / xHCI hand-off - Long story short, you want as few USB controllers active at once as possible, and I would say mice perform objectively worse on USB 3 controllers. Raising bandwidth on the same architecture tends to require more buffering and latency, so it's not hard to see why USB 3 would be worse for mice.

12) eHCI hand-off - No reason to have this turned on for Win7 or higher. Win7 should natively support USB 2.0, so disable it.

13) On-board audio - Disable. Enormous input lag.

14) On-board video - Disable unless you actually use it.

15) HPET (High Precision Event Timer) - disable to dramatically lower mouse lag and DPC latency

Explanation from software engineer for why TSC is superior and HPET should never be forced as the default clock except in a server environment:



16) Secondary ATA controllers (Marvell, etc) - disable to lower DPC latency

17) Secondary LAN - disable to lower DPC latency

18) Legacy USB support - usually have to leave this enabled in order to get back into the BIOS but sometimes will have better mouse response with it off. Varies highly by motherboard. Some boards will have out of control cursor movement with it off for some reason.

19) LLC and PLL Overvoltage - I've tested these a lot, and although people overclocking like to utilize them, I've found they do strange things to mouse movement. Generally anything involved with ramping up voltage response on the motherboard tends to make it feel like you have less a dead zone on the mouse where it's easier to overshoot with the cursor. I prefer to have both of these options off and seemed to dislike the effect of PLL overvoltage more than high LLC. You need to set PLL overvoltage to off instead of auto, because auto usually means turned on.

In the BIOS, it is worth turning off all unused devices on my laptop: sound card (I have an external sound card), microphone, display fingerprint reader, etc. It is also worth turning off all energysave functions and setting everything to a fixed value.

II. Disable HPET: use "bcdedit /deletevalue useplatformclock" command https://community.amd.com/t5/general-di ... m-p/560530

How To Improve Gaming Performance By Disabling HPET Settings
If you face FPS drops and stuttering, you can try changing the HPET settings to increase the performance of your PC and get smoother gameplay.

HPET stands for High Precision Event Timer (formerly Multimedia Timer) and has been used in PCs for a long time. It is used to produce periodic interrupts, which can be used to synchronize multimedia streams, in turn, providing smoother playback. It also reduces the need for other timestamp calculations. Performance of PC can also be increase by enabling Win32 Priority Separation which you can read here.

You can use the device manager to disable the High Precision Event Timer. I’ll show you how to use device manager settings to disable HPET.

From search, type Device Manager and press Enter to open settings.

Locate System devices.
Right click on High Precision Event Timer and select Disable to stop the HPET service.

III. Windows configure

In the device manager, disable all devices that you do not use (COM1, LPT port) in the case of multiple monitors or in the case of a laptop display, their driver.

IV. Removes non-present devices from the Windows device management:


Device Cleanup Tool V1.2.1 https://www.uwe-sieber.de/misc_tools_e.html

Each once attached device leaves an entry in the Windows device management. By means of the Windows device manager you can delete one by one only. With this tool you can delete multiple or all non-present devices.
The 'last used' time comes from the write time of the device's registry key under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum, on some Windows this seems to be set on boot or any other time.

V. Update your video card driver

First Remove old Display Drivers with DDU https://www.wagnardsoft.com/

Next step install the lastes driver from nvidia or ati side. If you installing the driver choose the only driver instalion. ( Not instal experience, shadows software ).

VI. Update possibly faulty drivers with SDIO http://snappy-driver-installer.org/

Snappy Driver Installer Origin is a portable Windows tool to install and update device drivers. It can be used offline to install drivers where Internet isn't available. No more searching for drivers after a clean install, just let Snappy Driver Installer Origin do it's thing and your job will be done in no time. The perfect technician's tool.

State of the art driver matching algorithm. Fully portable so you can run it from a USB flash drive. Built in application and driver pack updates. Can be fully automated using the built in scripting engine. Multilingual interface. Built-in and custom themes. Supports Windows XP, Vista, 7, 8, 8.1, 10, 11.

Since 2016. Snappy Driver Installer Origin remains a free, open source project. Free means it costs you nothing to download and use. Free means it is free of adware, malware, back doors, unwanted third party software and other dodgy stuff.

VII. Conclusion:
On my system, the value of 600-700 us ranges between 20-40 us now. And I play on an old system where, for example, there is not much room for adjustment in the BIOS. (Thinkpad is not designed for gaming).

The writing is partly written by myself and partly by other authors, I hope there will be someone besides me who can find it useful.

Anyway, I'm curious what this value can be under Linux.

Thank you for reading!
User avatar
adminless
Site Admin
Site Admin
Posts: 5331
Joined: Thu Nov 03, 2016 19:05
in-game nick: not available
Location: Spain

Re: How to decrease input lag ( DPC latecy ) tips

Post by adminless »

good in-depth guide, add it now as a announcement in this sub-forum along with the rest of the guides here.
fau
User lv4
User lv4
Posts: 218
Joined: Sun Aug 02, 2020 18:46

Re: How to decrease input lag ( DPC latecy ) tips

Post by fau »

3) Turbo Boost/C-States/EIST/Thermal Monitor/Etc: You want to disable as many of these as possible because they bring a lot of lag.
- won't it make cpu use a lot more power when idle and cripple its max performance? (c-states/turbo boost)

5) Hyper Threading
- disabling it will cripple cpu performance in multithreaded workloads

9) Intel Virtualization Technology
- sure, until you install some software that uses virtualization and a typical pc user won't be able to troubleshoot why it doesn't work and waste a ton of time

I don't really know much about the rest, but I bet they are enabled for a reason. I've learned my lesson long time ago to not fiddle with default settings too much because you're gonna forget what you did in half a year and nobody will be able to help you when something doesn't work.

Do you have any sources how these things and DPC latency actually affect input lag or anything related to gaming?
User avatar
Lisa_Ann
User lv4
User lv4
Posts: 137
Joined: Sun Nov 28, 2021 17:08
in-game nick: LisaTheAnn
Location: Budapest

Re: How to decrease input lag ( DPC latecy ) tips

Post by Lisa_Ann »

fau wrote: Tue Nov 21, 2023 19:54
3) Turbo Boost/C-States/EIST/Thermal Monitor/Etc: You want to disable as many of these as possible because they bring a lot of lag.
- won't it make cpu use a lot more power when idle and cripple its max performance? (c-states/turbo boost)
I think that consumption is not an issue for those who want to play seriously. Also, in my case, the consumption of the VGA is 45W since it is a laptop.

5) Hyper Threading
- disabling it will cripple cpu performance in multithreaded workloads

9) Intel Virtualization Technology
- sure, until you install some software that uses virtualization and a typical pc user won't be able to troubleshoot why it doesn't work and waste a ton of time
Yes, but it's also like turning hyper threading off and on in the bios together. Of course it's not mandatory.

I don't really know much about the rest, but I bet they are enabled for a reason. I've learned my lesson long time ago to not fiddle with default settings too much because you're gonna forget what you did in half a year and nobody will be able to help you when something doesn't work.
You don't have to fiddle with anything, like the quake3 cfg file, but many of us get away with it. :-)

Obviously, in my case, this is an old laptop that is approx. I use it for this.

What I have noticed the most is if I disable really unused devices / wifi, sd card reader, fingerprint reader, trackpad, integrated soundbar, camera, etc. in the bios and in the device manager. This frees up a lot of resources in my case and the game runs smoothly.

No, I don't know the hardware reason for everything, as I wrote in the description, I also now know that this concept exists at all. I had microlags that were annoying, so I looked for related forums.

When I have time, I will expand / test it one by one, and I will also try to understand it at the architectural level. But this was not the goal, only if someone suffers from a similar problem, then they know that this concept exists.

Many people buy an expensive mouse that communicates at 1000 Hz, meanwhile
he can't use it normally because of another USB crap gadget.

5) Hyper Threading

9) Intel Virtualization Technology

I also have minimal deviation turned on. On the other hand, disabling unnecessary tools, as I wrote, helped me a lot.

Obviously, the one who is not good at the moment is teasing him, and he knows a lot about it.

Do you have any sources how these things and DPC latency actually affect input lag or anything related to gaming?
https://www.sweetwater.com/sweetcare/ar ... cy-issues/

For me, as I wrote, the micro lag is gone and the game runs much smoother.

"A Deferred Procedure Call (DPC) is a Microsoft Windows operating system mechanism which allows high-priority tasks (e.g. an interrupt handler) to defer required but lower-priority tasks for later execution. This permits device drivers and other low-level event consumers to perform the high-priority part of their processing quickly, and schedule non-critical additional processing for execution at a lower priority.

DPCs are implemented by DPC objects which are created and initialized by the kernel when a device driver or some other kernel mode program issues DPC requests. DPC requests are added to the end of a DPC queue. Each processor has a separate DPC queue. DPCs have three priority levels: low, medium, and high. By default, all DPCs are set to medium priority. When Windows drops to an IRQL of Dispatch/DPC level, it checks the DPC queue for any pending DPCs and executes them until the queue is empty or some other interrupt with a higher IRQL occurs.

For example, when the clock interrupt is generated, the clock interrupt handler generally increments the counter of the current thread to calculate the total execution time of that thread, and decrements its quantum time remaining by 1. When the counter drops to zero, the thread scheduler has to be invoked to choose the next thread to be executed on that processor and dispatcher to perform a context switch. Since the clock interrupt occurs at a much higher IRQL, it will be desirable to perform this thread dispatching which is a less critical task at a later time when the processor's IRQL drops. So the clock interrupt handler requests a DPC object and adds it to the end of the DPC queue which will process the dispatching when the processor's IRQL drops to DPC/Dispatch level.

When working with streaming audio or video that uses interrupts, DPCs are used to process the audio in each buffer as they stream in. If another DPC (from a poorly written driver) takes too long and another interrupt generates a new buffer of data, before the first one can be processed, a drop-out results.[1]"
User avatar
adminless
Site Admin
Site Admin
Posts: 5331
Joined: Thu Nov 03, 2016 19:05
in-game nick: not available
Location: Spain

Re: How to decrease input lag ( DPC latecy ) tips

Post by adminless »

in my opinion the commented disable hyper threading/smt and vt-x/svm suggestions for the context of a computer exclusively for gaming (and nothing else) seems legit to me. keep in mind that most games are either completely single threaded or single threaded heavy so in that case you're not gonna benefit from having so many extra threads if not probably the contrary as it gonna eat away power from the total tdp chip limit. disabling the virtualization probably won't make any real difference in the silicon other than turning off some bios structures and flags that would "prevent" the software from then effectively using the hardware. in that sense disabling the motherboard vt-d/iommu (chipset/peripheral) virtualization on those available I think that can be more relevant as I believe that adds a extra level of direction or at least overhead when accessing the hardware. disabling the cpu c/p states just like that is probably a bit more arguable as that's the mechanic that moderm cpu uses to maximize single thread performance and that's something cpu vendors are known to play with to market their products for gaming. it's not unusual to have ~2.5 GHz rated chips for general purpose multi thread use but that can instead perfectly do 3.5+ GHz for gaming (or other heavy cpu bound computing tasks) that makes a difference but only over a few cores however for those few cores to perform at that speed it requires the rest to be on lower power states otherwise you just cap the whole chip at the base power which is probably not the best idea for gaming with the actual hardware. in my experience is probably best just to leave that in auto and then simply let the operative system scheduler take good care of that as it sees fit depending on the workload and power plan at hand (that's why the scheduler is there for) rather than fixing that in the bios without taking anything else in consideration. in any case, I'm not a hardware specialist to such extend so I'm just saying, that's my opinion about that.
fau
User lv4
User lv4
Posts: 218
Joined: Sun Aug 02, 2020 18:46

Re: How to decrease input lag ( DPC latecy ) tips

Post by fau »

well, that links talks only about audio. I know realtime audio processing is a big challenge.
Games though? I have a laptop that can run q3 at 125/250 fps and the total latency and consistency indeed feels worse than on a desktop pc. But I'm still not convinced that this dpc is relevant for games. Are you sure it's not some snake oil? From my experience until you get into (multiple) milliseconds area, a person can't tell the difference.

Do you get perfectly stable fps without any drops (cg_drawfps twitching for a single frame) when you changed these settings, for example? Or what are these micro stutters you are talking about?
User avatar
Lisa_Ann
User lv4
User lv4
Posts: 137
Joined: Sun Nov 28, 2021 17:08
in-game nick: LisaTheAnn
Location: Budapest

Re: How to decrease input lag ( DPC latecy ) tips

Post by Lisa_Ann »

Maybe I got off to a bad start and I didn't want to deal with it that much, and only DPC is mentioned, but the Latencymoon program also monitors ISR interrupt service routines (ISRs), and these settings also improve these interrupt routines. Of course, the ideal would be if quak had a target hardware written (everything that can be implemented in software can also be implemented in hardware). The more interrupts and other things there are in front of the CPU, the more data it works with, the longer a cycle takes.

It is not for nothing that we adjust and buy RAM, taking into account delay values. AND the size of the L1 L2 L3 cache memory is also limited, if I remember correctly, they are implemented with D flip-flops, which are expensive, but fast in return. I think that if we don't fill them with "unnecessary things" as a priority, then the rest of the program will be able to share it better.

Audio is one of the most significant problems, I have external studio soundbars (old USB 2.0 ones) and they were able to cause lag on the operating system level as well. Fortunately, a firmware upgrade usually helps. In a similar way, I bought the ducky one III keyboard ( usb -c ) and in addition to the sound card, there were incorrect character strokes and it did not work at 1000 Hz. Mouse is similar.

There aren't many bad things about micro lag, I don't really know what to compare it to. Maybe when I switch back to 60Hz on the monitor, it's similar to that for me.

It also obviously depends on the machine, the difference may be more significant on an older machine. I do not know. I did the steps that were clear and reasonable to me, and the game got better for me.

Anyway, I started a long time ago in 2560p, 130 FOV, etc. hardware is the same, heaven and earth are my playing style. and all settings went to increase the speed, I went back to 1080p, I'm on FOV 90.. and I'm still fluffing with these settings now. But I live this as a hobby and I just described it in an interesting way. This won't make me much better or worse, it could also be a placebo.

Obviously, these times are in US territory anyway, while better mice, keyboards, and monitors usually have a delay of 1 ms.

I hope there is someone here who has studied computer architecture and can comment meaningfully or perhaps has an understanding of programming in a lower language.
User avatar
Lisa_Ann
User lv4
User lv4
Posts: 137
Joined: Sun Nov 28, 2021 17:08
in-game nick: LisaTheAnn
Location: Budapest

Re: How to decrease input lag ( DPC latecy ) tips

Post by Lisa_Ann »

fau wrote: Wed Nov 22, 2023 15:00 well, that links talks only about audio. I know realtime audio processing is a big challenge.
Games though? I have a laptop that can run q3 at 125/250 fps and the total latency and consistency indeed feels worse than on a desktop pc. But I'm still not convinced that this dpc is relevant for games. Are you sure it's not some snake oil? From my experience until you get into (multiple) milliseconds area, a person can't tell the difference.

Do you get perfectly stable fps without any drops (cg_drawfps twitching for a single frame) when you changed these settings, for example? Or what are these micro stutters you are talking about?
Here's Nvidia offcial site : https://www.nvidia.com/en-us/geforce/gu ... ion-guide/

Image
"Advanced PC Latency Optimization

There are other small tweaks that can be done to help reduce latency such as MSI mode, GPU cache write combining, process scheduling quantum modes, interrupt CPU affinity, processor idle states, and IRQ sharing. However, these optimizations are situational and can actually make latency worse in some cases. We recommend testing on your own system and experimenting to find which modes help your particular configuration!

Each setting is not mutually exclusive or additive. In a future article, we will dive deeper into each of these tweaks and help guide you through the experimentation process."


"About DPCs and ISRs

The Windows thread dispatcher (also known as scheduler) which is part of the kernel executes threads based on a priority scheme. Threads with higher priority will be given a longer execution time (also known as quantum or time slice) than threads with a lower priority. However the kernel also knows other types of units of execution known as interrupt service routines (ISRs). Devices connected to the system may interrupt on a connected CPU and cause their interrupt service routines to execute. An interrupt can occur on the same processor that an audio program is running on. Any thread that was running on the processor on which an interrupt occurred will be temporarily halted regardless of its priority. The interrupt service routine (ISR) is executed and may schedule a DPC (Deferred Procedure Call) to offload an amount of work. The DPC will most likely run immediately on the same processor which means the audio application will halt until both the ISR and the DPC routines have finished execution. That is because ISRs and DPCs run at elevated IRQL which means they cannot become preempted by the thread dispatcher (scheduler). Therefore to guarantee responsiveness of the system, ISR and DPC routines should execute as fast as possible. Guidelines say that they should not spend more than 100 µs of execution time however this is often not reached due to hardware factors beyond the control of the driver developer. If execution time gets too high, the audio program may be unable to deliver audio buffers to the hardware in a timely manner."
User avatar
Lisa_Ann
User lv4
User lv4
Posts: 137
Joined: Sun Nov 28, 2021 17:08
in-game nick: LisaTheAnn
Location: Budapest

Re: How to decrease input lag ( DPC latecy ) tips

Post by Lisa_Ann »

I found a program that seems useful, you can set CPU cores and turn them on and off, as well as hyper threading. The name Process Lasso can be downloaded from here: https://bitsum.com/

Image

In practice, in addition to memory I/O and other priorities within the CPU, we can also adjust them for running programs.