-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Speed Up info_gpu #155
base: master
Are you sure you want to change the base?
Speed Up info_gpu #155
Conversation
- Instead of using Get-CimInstance to get GPU information, which can be very slow, gets the registry entry at HKLM:\SOFTWARE\Microsoft\DirectX\ which contains a list of installed video adapters - 1690 ms -> 40.16 ms - 42x faster (nice)
- Whenever someone doesn't have the LastSeen key, falls back on a method which is incompatible with users with multiple of the same GPU - If for some reason the entire registry entry doesn't exist, fall back to the previous slow implementation.
@jcwillox Created a fallback implementation if the LastSeen key doesn't exist, can you try it? The only issue with the fallback is that theoretically, it won't work properly if someone has two of the same GPU installed. But I think this is a very small minority of users that would be both lacking the LastSeen key and have two of the same GPU for some reason. I also added back the old implementation in case the entire DirectX key doesn't exist, which I think would also be very unlikely. But since the implementation was already created, I saw no harm in adding it. |
I tried the new function and it is now returning the GPU which is not connected to my system again.
Besides returning GPUs that aren't connected anymore, this would still be a deal breaker, we should never sacrifice reliability for performance, otherwise, it kinda defeats one of the main purposes of winfetch. Instead, we need a better solution. My recommendation is to drop the alternative method and if the Out of interest what version of windows are you running? |
Windows 11 Also, I kinda forgot about the bug with returning no longer connected gpus, I'll fix it probably tomorrow sometime. I found a new thing I could try implementing as a backup. I found where the entries for device manager are stored in the registry, and I could go through the PCI category and look for devices that match keywords like NVIDIA GeForce and AMD Radeon. |
Thought that might be the case, I'm still running Windows 10 so that may be the reason for the missing
That could be a much better option, it may even work for older versions that don't have DirectX. |
Can confirm that my Windows 10 21H1 VM lacks the key so maybe it is Windows 11 exclusive |
- Gets the subkeys of HKLM:\SYSTEM\CurrentControlSet\Enum\PCI\ and pulls the value of DeviceDesc of those subkey's subkeys, then pulls the device name from the value, then it takes those values and compares those values to a list of GPU titles.
The most recent commit implements the new method which is run if LastSeen is not detected on the user's system. The list I created is probably missing some more obscure GPUs but they can be easily added if found. |
@jcwillox can you confirm if the new backup implementation works? The script should automatically fall back to the backup for you so you shouldn't have to worry about changing anything to enable it. |
For me, most CIM accesses take at least 1.2 seconds, including this one. But the device manager method takes around 50 ms. |
Also, to get the correct speed for a scriptblock, it's best to run each measure-command in a new instance by running When testing on my PC with a Ryzen 5 3600, without bottlenecking PowerShell, and using the CIM method, I got 46 ms when opening a new instance every time and around 11 ms when running it on the same instance multiple times |
TODO:
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Hardware Profiles\0001\System\CurrentControlSet\Enum\PCI
contains currently connected GPU's hardware IDsHKEY_CURRENT_CONFIG\System\CurrentControlSet\Enum\PCI
has same keysHKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}\
could be easier and faster than current methodHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinSAT
has the primary GPUHKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Video\