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

Get rid of dependency on deprecated WMIC on Windows #2771

Open
janbuchar opened this issue Dec 9, 2024 · 4 comments · May be fixed by #2834
Open

Get rid of dependency on deprecated WMIC on Windows #2771

janbuchar opened this issue Dec 9, 2024 · 4 comments · May be fixed by #2834
Labels
debt Code quality improvement or decrease of technical debt. t-tooling Issues with this label are in the ownership of the tooling team.

Comments

@janbuchar
Copy link
Contributor

@janbuchar janbuchar added debt Code quality improvement or decrease of technical debt. t-tooling Issues with this label are in the ownership of the tooling team. labels Dec 9, 2024
@xiaobailong007

This comment was marked as spam.

@NathanSavageKaimai
Copy link

It appears the current implementation is broken anyway. If you call getMemoryInfo on windows, the returned object returns a default value for the mainProcessBytes

{
  totalBytes: 25438089216,
  freeBytes: 7435272192,
  usedBytes: 18002817024,
  mainProcessBytes: -1,
  childProcessesBytes: 14073856
}

Im not quite sure how this has gone unoticed, the test suite for it fails because of this. Is the test suite not regularly run on windows?

@janbuchar
Copy link
Contributor Author

@NathanSavageKaimai thanks for bringing this up, we really should run the unit tests on Windows as well.

@NathanSavageKaimai
Copy link

@janbuchar ive been playing around with this and I have a solution that works but ive hit a bit of a snag. The modern alternative to WMIC that Microsoft reccomends is the powershell command Get-CimInstance. This can be executed as follows:

            processLister = spawn('powershell', [
                '-NoProfile',
                '-Command',
                'Get-CimInstance Win32_Process | Format-Table ProcessId,ParentProcessId,WorkingSetSize,Name',
            ]);

unfortunately this takes about 66% longer to execute than WMIC did. ~500+ms vs ~300+ms. Is this a trade off you can accept or should I keep looking?

Theres a module i found called ps-list by sindresorhus that has a custom binary that would likley be faster but obviously it would add a third party dependancy.

If the powershell solution is acceptable, a slight test modification is needed in the test suite as the Snapshotter ".get[.*]Sample limits amount of samples" test doesnt run long enough for the function to run twice and thus throws a false positive.

Let me know what you think. : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debt Code quality improvement or decrease of technical debt. t-tooling Issues with this label are in the ownership of the tooling team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants