Skip to content

Conversation

@Carterpersall
Copy link
Contributor

@Carterpersall Carterpersall commented Sep 9, 2022

The intent of this pull request is to speed up winfetch wherever I can

Done:

  • Optimized GPU fetching
    • Instead of using Get-CimInstance to get GPU information, which can be very slow, gets the registry entries at 'HKLM:\SOFTWARE\Microsoft\DirectX', which contains a list of video adapters
    • 1690 ms -> 40.16 ms
      • 42x faster (nice)
  • Made info_locale speedy
    • Takes the registy entries at HKCU:Control Panel\International to get region code and language code, and passes them into two very large hash tables to get the accompanying region and language values.
    • 3251 ms -> 12.43 ms
      • 262x Faster

TODO:

  • Attempt to optimize expensive functions
    • info_ps_pkgs
      • 6630 ms
    • info_pkgs
      • 2400 ms
    • info_gpu
      • 1640 ms -> 40.16 ms
        • 42x faster (nice)
      • Maybe: Fix edge case for users with multiple of the same GPU
    • info_cpu_usage
      • 1100 ms
    • info_locale
      • 3251 ms -> 12.43 ms
        • 262x Faster
      • Make work when user has more than one language
      • Maybe: Find a way to circumvent the very large table
    • info_weather
      • 433 ms
    • info_local_ip
      • 1960 ms

- 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)
@rashil2000
Copy link
Member

@HO-COOH does this work as before with your setup (multiple GPUs)?

@jcwillox
Copy link
Member

This PR currently returns GPUs which are no longer connected to the system, perhaps you could use the LastSeen registry key to identify old GPUs, but that might not be super reliable.

image

@rashil2000 rashil2000 changed the title A few Optimizations Optimize GPU fetching Sep 12, 2022
@Carterpersall
Copy link
Contributor Author

This PR currently returns GPUs which are no longer connected to the system, perhaps you could use the LastSeen registry key to identify old GPUs, but that might not be super reliable.

image

I was worried that could happen, I'll see what I can figure out.

- Added a check where the LastSeen value of HKLM:\SOFTWARE\Microsoft\DirectX\ is compared to the LastSeen value of each subkey
@Carterpersall
Copy link
Contributor Author

@jcwillox might be fixed in the most recent commit, can you check?

The LastSeen implementation should be reliable as the base DirectX key has a LastSeen value which can be compared with it's subkeys to see which were detected in its most recent run-through. This might also allow me to fix an edge case where if someone has two of the same GPU, it would be detected as a duplicate entry and not be shown.

@Carterpersall Carterpersall changed the title Optimize GPU fetching Optimizations Sep 12, 2022
@Carterpersall
Copy link
Contributor Author

@HO-COOH does this work as before with your setup (multiple GPUs)?

Works on my laptop with its integrated and dedicated graphics:

image

@Carterpersall Carterpersall changed the title Optimizations Optimize GPU fetching Sep 12, 2022
- Made info_locale speedy
  - Takes the registy entries at HKCU:Control Panel\International to get region code and language code, and passes them into two very large hash tables to get the accompanying region and language values.
  - TODO: Make work when user has more than one language
  - Maybe: Find a way to circumvent the very large table
  - 3251 ms -> 12.43 ms
    - 262x Faster
@Carterpersall Carterpersall changed the title Optimize GPU fetching Optimizations Sep 12, 2022
@jcwillox
Copy link
Member

@jcwillox might be fixed in the most recent commit, can you check?

The LastSeen implementation should be reliable as the base DirectX key has a LastSeen value which can be compared with it's subkeys to see which were detected in its most recent run-through. This might also allow me to fix an edge case where if someone has two of the same GPU, it would be detected as a duplicate entry and not be shown.

I tested it and it, unfortunately, returns no GPUs as the HKLM:\SOFTWARE\Microsoft\DirectX\LastSeen key doesn't seem to exist on my system.

image

"161832257" = "Latin America and the Caribbean"
"161832258" = "Bonaire, Sint Eustatius and Saba"
}
$languageLookup = @{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not cover all languages (English (India) in my case)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that the languageLookup array wasn't complete. I'll fix that in my next commit.

@rashil2000
Copy link
Member

Also, it would be better to split out optimizations for different functions in different PRs.

@Carterpersall
Copy link
Contributor Author

Pull request moved to #153 ,#154, and #155

@Carterpersall Carterpersall deleted the Optimizations branch September 13, 2022 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants