Skip to content
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

Data retrieved from powershell can be huge (and time consuming) #650

Closed
xavier-deryckere opened this issue Feb 2, 2022 · 4 comments
Closed

Comments

@xavier-deryckere
Copy link

Hello

On Windows since wmic has been replaced with powershell some calls take a lot of time.
Selecting only the actually used data seems to reduce that time a lot.

calling:
si.processes()

with wmi:
0.5 second
0.5 MB of data

with powershell:
5 seconds
1 MB of data

Can be checked by just running both commands in a prompt
wmic process get /value > wmic.txt
=> quick
powershell "Get-WmiObject Win32_Process | fl *" > ps.txt
=> takes ages

instead of getting everything:
util.powerShell('Get-WmiObject Win32_Process | fl *').then((stdout, error) => {

I tested with
const fields = [ 'ProcessId', 'ParentProcessId', 'ExecutionState', 'Caption', 'CommandLine', 'ExecutablePath', 'UserModeTime', 'KernelModeTime', 'WorkingSetSize', 'Priority', 'PageFileUsage', 'CreationDate' ];
util.powerShell('Get-WmiObject Win32_Process | select ' + fields.join(',')).then((stdout, error) => {

=>
1.6 seconds
0.2 MB of data
Still not as good as before, but still :-)

I guess the same applies to some extent to other powershell calls as well.

@sebhildebrandt
Copy link
Owner

@xavier-deryckere thats a good finding. Will think of reducing the needed columns!

The second problem is, that spinnig up powershell is quite intense ... so there is (currently undocumented - still in progress of improving it) another option to start up powershell only once. To enable this you need to run su.powehShellStart() before running your commands and then at the end si.powerShellRelease() ... see also #616

But maybe you already have seen that ;-)

@xavier-deryckere
Copy link
Author

Yes I have seen that but did not try.
I just did try powerShellStart/powerShellRelease, and the results are only slightly better (5+ seconds -> 4.6/4.7 seconds).
I guess the amount of data has more impact than process spawning.

@sebhildebrandt
Copy link
Owner

@xavier-deryckere ... only when having multiple calls, than I experienced much better numbers but you are right, the amount of data is something I will have a look on! Thank you so much.

@sebhildebrandt
Copy link
Owner

@xavier-deryckere ... thank you once again. I now reduces all data retrieved from powerShell commands to the minimum and I see on my windows machines good improvements in the speed of

  • processes()
  • processLoad()
  • printer()
  • services()
  • versions()
  • users()

Version 5.11.2 just released. Thank you once again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants