136 points · by CppPro · 3y ago · 116 comments
> 2 years ago
> It [sic] tested it on Windows 10 LTSB (1607)
If you want to reduce input lag for exclusive fullscreen, turn off “fullscreen optimizations”. But that specific bug, introduced in build 1903, was fixed a few years ago. (But if you still somehow get it — you can just turn this off per-game instead of this wide hack!)
Modern DXGI flip presentation model doesn’t add input lag anymore and properly detects when the exclusive fullscreen app is the only one showing, and gives it direct render control. (E.g. you can frame tear again!)
I think some UIs will also just not work nowadays if you kill DWM, even more likely in Windows 11 since more UI got moved to WinUI.
This is only true in certain situations. For non-fullscreen windows it requires that your GPU driver support a feature called "Multiplane Overlay" which is not supported on Nvidia cards before RTX 20 series (probably not older AMD cards either though I'm not sure). A lot of people have disabled it because they've experienced bugs like flickering or stability issues. And a lot of random features will also disable it without notice, like monitor rotation or 10-bit color.
There's also this weirdness that DXGI always adds 3 frames of latency, because that's the default value unless explicitly changed by the application (https://learn.microsoft.com/en-us/windows/win32/api/dxgi/nf-...) - don't be confused by the "maximum" in the name, it's just consistently adding 3 frames of latency (at least on my Win10 machine).
Don't know if this has changed in more recent DXGI versions, but if you want to be backward compatible as much as possible, those are not an option.
The DXGI APIs are such a completely random collection of functionality that I really wonder if there's any forward thinking at all. If anything, at least the defaults are all wrong.
I didn't permanently kill it like in the article, though. Just killed the process and let it restart.
I don't know for sure that dwm.exe itself was the cause. It could have been an issue with some of the endpoint management crap my employer forces on users, somehow, or maybe MS PowerToys (though I think I eventually ruled that out at some point). But killing dwm.exe fixes it.
I gotta say coming back to Windows for a while was a real shock for me. I can't believe how much basic stuff was more or less broken.
Maybe DWM restarting also kills and reinitializes the window messages mechanism?
>> 2 years ago
How often do you expect a single purpose program that's less than 200 LoC needs to be updated?
Never had any issue like this until I had to replace a monitor, and the newer one doesn’t keep HDMI/DP signals alive at all when the display sleeps, causing Windows to think it disconnects.
It’s such a stupid and common thing that the “PersistentWindows” tool exists to put the windows back in position after W10 fucks up everything from the monitor disconnect. So it’s not a stretch to think dwm.exe has issues with it as well.
As an extra note, Windows 11 ships with a feature to force the DXGI flip presentation model in older games.
"Gamers" can be like audiophiles in the way the spread half-truths and even outright misinformation. The number of people I still see thinking you should turn G-Sync off is downright silly.
I have a Freesync display and a compatible GPU and i can feel the difference between no vsync and freesync. There is a slight lag there, if you cannot feel it do not assume that others cannot too (some people even seem to not be able to feel a difference between having vsync on and off or having a compositor or not enable - nowadays really only possible on Linux but in the past you could also do it with WinVista/Win7 and in Win8 with hacks like the one linked - which is mind boggling to me).
Of course the input lag depends on the game and how you play it. First person games with raw input, 1:1 mapping of the input (i.e. no filtering whatsoever) and little to no frame queuing (some engines run 1-2 frames "behind" the game state and if you add things like triple buffering you end up with extra lag) are the best to notice this whereas third person games played with a gamepad (where you have only indirect control of the camera - you control the camera's rotation speed, not the camera directly) are way harder to notice, as are games where you mainly use the mouse to click where to go (especially if the game uses a hardware cursor instead of rendering the cursor itself as part of the game UI).
Also high refresh rate monitors make it slightly easier to overlook the lag (though it still is possible to tell - mine is a 165Hz monitor after all and i can still notice, it just doesn't annoy me as much as on a 60Hz monitor).
For most modern gaming monitors, this isn't a huge deal. Cap your game at 140 FPS on a 144hz display and it will feel as snappy as it probably would have uncapped. Though if you have a lower end (or ultra high resolution) display that caps out at something much lower, like 60, then I can definitely see how leaving it uncapped with VRR disabled would feel a lot snappier.
Early Freesync-branded displays could also be a bit of a crapshoot for a variety of reasons, but this has gotten much better in the last 5-6 years.
For everyone else, you'd really want to prove it with a high-speed camera or something.
Going on sort of a tangent, but since it was mentioned: I hate variable refresh rate.
I suppose my eyes are just sensitive to changes in rendering speed, because I tried it and I couldn't stand the variable ghosting. For me it's worse than screen tearing, which for me is perfectly resolved with vertical syncing or just capping the frame rate to something less than my monitor's refresh rate.
You could probably fix it by capping your game's framerate to whatever it can maintain consistently within your monitor's VRR window. This would give you a smooth consistent experience, without screen tearing or vsync-induced lag. Since it's not working in a fixed refresh rate container, you can do more unconventional numbers too. I like to run a lot of games at 90 FPS.
It can be a bit of a curse. LED headlights and taillights give me headaches. A lot of LED street lighting and business lighting hurts me. Etc.
I used to be basically unable to stand a CRT under ~85hz. :(
If I had a dime for every time people were being told to manually manage their Windows page file "for performance"...
A page file is, as it says, a file that's located in the root of whichever partitions that they are configured on. By default it's only configured on the C: partition and the size of the page file is variable, managed by Windows according to system demands. The page file is equivalent to a swap partition, for the Linux and BSD users out there.
Manually configuring the page file has a number of benefits, if you know what you're after (and you're using HDDs):
* You can specify a size, fixed or variable, for your page files. By default Windows allocates a fairly small page file, and if your page file use exceeds that allocation Windows has to allocate more space on the fly. This takes time, especially if the page file resides on a HDD. If you configure a fixed size, or a variable size with a large minimum size, you don't need to worry about that dynamic allocation which translates to more performance. Another benefit to a fixed page file is that you can have the page file occupy one continuous area on a HDD platter, for better access times and thus better performance; a dynamic allocation more often than not leads to a fragmented page file and thus worse performance.
* You can specify which partitions you want to use for your swap space. It wasn't unusual to just dedicate a partition to a page file, effectively the same thing as a swap partition, especially if your C: partition wasn't that big. This is important for the next bullet point.
* Back when we still ran our programs off of HDDs, making a partition earlier in the drive meant locating that partition on the outer areas of the platter. The outer areas of the platter travel faster than the inner areas, because physics, and faster platter speed means faster access times. By placing the page file on such a partition, the page file has better access times and thus you get better performance.
A lot of these benefits have gone away thanks to RAM becoming both cheaper and more plentiful, and the storage medium where the page file resides changing from HDDs to SSDs in general. So most people usually don't need to mess with their page files anymore.
But for people with specific needs or just a desire to really fine tune their systems, tweaking the page file by hand is still a worthwhile endeavour if you understand what you can get out of it.
It's about ethics in game journalism!
(sorry, dwm (X11) having served me well for years, I had to make that joke).
The source was simple enough: get debug privileges, kill and suspend some processes, resume and if still missing restart, but I was puzzled at this function:
DWORD64 GetLPSTRHash(LPSTR s){
//more efficient string comparison
DWORD64 h=0;
BYTE c;
while((c=*s++)) h=(h<<5)+h+c;
return h;
}
This is used while iterating the list of running processes for string comparison. I wonder if others on HN can share any light, please?a) Why is an optimized string compare needed here? Even iterating a few hundred processes I would not have thought a simple (and likely already optimized) strcmp would be a hotspot
b) Why does this work as a good hashing function? It seems very simple: to the existing value, add a bitshift of the existing value plus the character. Googling shows some people referring to it as the Wang hash, in the context of pseudorandom numbers on GPUs. The actual content I can find on Wang’s hashing shows much larger (and to me more expected) algorithms, eg http://burtleburtle.net/bob/hash/integer.html
It's pretty poor, and slow on modern systems. It's known as the djb2 hash. (h << 5) + h is a way of writing 33*h without needing multipliers.
It fails pretty much every modern statistical test you can throw at it: https://gitlab.com/fwojcik/smhasher3/-/blob/main/results/per...
It's redeeming quality is that the code size is absolutely tiny, and that 33*h mod 2^64 is a reversible map, so if your input data is randomly distributed at least your output will be as well.
Random distribution of outputs does seem to minimise collisions on as a small an input set as a list of processes so I suppose the risk of killing the wrong process is minimal. I do think if I used the app I’d replace it though.
Unless, you didn't install the correct driver and used standard vga driver, or like in a vm which doesn't provide gpu acceleration.
https://learn.microsoft.com/en-us/windows/win32/direct2d/com...
"GDI is hardware accelerated on Windows XP, and accelerated on Windows 7 when the Desktop Window Manager is running and a WDDM 1.1 driver is in use. Direct2D is hardware accelerated on almost any WDDM driver and whether or not DWM is in use. On Vista, GDI will always render on the CPU."
I was surprised, because I thought using 3D acceleration and compositing would be faster.
Also, I run the VM at half res and used DPI workaround (.manifest file) to let Windows scale the VM instead of VirtualBox (VirtualBox scaling is very slow for some reason).
You lost me there. There needs to be real numbers measured, or the effect never existed.
Sometimes you get sluggish performance context switching app windows.
Task Manager and Resource Monitor shows that everything looks okay
- CPU - Memory - Disk - Network All running at less than 20% - yet computer feels sluggish switching apps.
What is interesting is that two computers with seemingly similar hardware - same corporate issue manufacturer can have different performance.
Surely there is something in SysInternals to help track down this issue.
Killing explorer.exe makes alt-tab instant.