FAForever / fa

Lua code for FAF
227 stars 233 forks source link

Missing register key spam when audio is running #3350

Open Crotalus opened 3 years ago

Crotalus commented 3 years ago

If you run Process Monitor and filter out ForgedAlliance.exe there's a noticable spam of register key not found while audio is playing in the game (~10 per second)

image

There was an earlier discussion in the old forum about this: https://forums.faforever.com/viewtopic.php?f=2&t=9451

Especially the last message this was interesting:

With the help of SeraphimLeftNut and mr_ped I've created a fix for the APL key spam. It's in the form of a dll and a dll injector application. The dll installs a detour on the RegQueryValueExA function imported from Advapi32.dll and blocks all calls where lpSubKey == _T("SOFTWARE\Microsoft\APL") by returning 0x2. This completely stops the spam.

What effect this has on performance is unknown.

Could be worth investigating when someone is bored enough.

KionX commented 3 years ago

Against the background of how it reads Music.xwb and textures.scd APL is absolutely insignificant. Now spam requests everywhere has become the norm.

Garanas commented 3 years ago

Interesting, I'm not too much into this matter but what is the implications of this, if not performance? Why would the game look for this key?

Crotalus commented 3 years ago

In 2014 I remember using procmon to find tons of unnecessary reads by GetDiskFileInfo() which read file metadata from disk and parts of the UI used that function.

In combination with FA constantly writing replay + reading music on the same disk resulted in actual stutter in game if people were using HDD. It was enough if one player in game has a slow disk with horrible random access to actually impact everyone, even when it was UI side that did the disk reading.

Much of the "startup" lag people notice after game start are due to this, reading textures of units etc from disk.

It was solved by caching the output of that function. The less disk access the better even if many people today have SSDs.

KionX commented 3 years ago

DirectSound searches for the "Safe Mode" key there.