Skip to content

Removed WMI due to performance#13610

Open
MichalPavlik wants to merge 1 commit intomainfrom
dev/mipavlik/remove-wmi-2
Open

Removed WMI due to performance#13610
MichalPavlik wants to merge 1 commit intomainfrom
dev/mipavlik/remove-wmi-2

Conversation

@MichalPavlik
Copy link
Copy Markdown
Member

Fixes #13550

Context

WMI is causing issues, so we need to remove it now and find a better solution.

Changes Made

WMI code was removed and Windows is treated as unsupported OS.

Testing

Manual testing with running MSBuild worker nodes.

Notes

Copilot AI review requested due to automatic review settings April 27, 2026 12:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the Windows WMI-based implementation used to retrieve a process command line (to address significant performance regressions during node reuse scanning), and updates unit tests to reflect that command-line retrieval is not supported on Windows.

Changes:

  • Removed the Windows WMI/COM-based command-line retrieval path from ProcessExtensions.TryGetCommandLine.
  • Treated Windows as unsupported for command-line retrieval (returns null command line) and updated unit tests accordingly.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/Framework/Utilities/ProcessExtensions.cs Removes WMI-based Windows command-line retrieval to avoid the perf hit.
src/Utilities.UnitTests/ProcessExtensions_Tests.cs Updates expectations on Windows to assert commandLine is null.

Comment on lines 63 to 69
try
{
#if NET
if (NativeMethods.IsWindows)
{
commandLine = Windows.GetCommandLine(process.Id);
return true;
}
else if (NativeMethods.IsOSX || NativeMethods.IsBSD)
if (NativeMethods.IsOSX || NativeMethods.IsBSD)
{
commandLine = BSD.GetCommandLine(process.Id);
return true;
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

TryGetCommandLine now treats Windows/other platforms as unsupported (returns true with commandLine == null). However, the method's XML doc says it returns false when the platform doesn't support command-line retrieval, and the unsupported-OS branch comment says "return false" even though it returns true. Please align the docs/comments with the actual contract (or adjust the return value/contract consistently across callers).

Copilot uses AI. Check for mistakes.
Comment on lines +66 to +67
// Windows is treated as an unsupported OS for command-line retrieval; commandLine is null.
commandLine.ShouldBeNull();
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

PR description says "Windows is treated as unsupported OS", but the actual code change only makes Windows unsupported for command-line retrieval (TryGetCommandLine returns null). Please clarify the PR description (or comments) to avoid implying MSBuild no longer supports Windows overall.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Correctness & Edge Cases — one issue found

Comment/code mismatch (line 78): The comment says "return false" but the code returns true. This is not a runtime bug — the true + null return is correct for the callers — but the comment directly contradicts the code it describes.

Everything else checks out:

  • Callers handle (true, null) correctly. Both call sites in NodeProviderOutOfProcBase.cs explicitly guard if (commandLine is null) and include the process, which is the right fallback when command-line retrieval is unsupported.
  • ExtractFromCommandLine is null-safe. It checks string.IsNullOrWhiteSpace up front, so even if a BSD/Linux helper returned null, callers would not crash (though they'd get NodeMode? == null and exclude the process — the null guard in callers fires first anyway).
  • XML doc <returns> is slightly misleading (says "true if successfully retrieved" but true also means "unsupported platform"), however this is a pre-existing issue — the .NET Framework path already returned (true, null) before this PR.

Generated by Expert Code Review (on open) for issue #13610 · ● 11.7M

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.

Node reuse scans dotnet.exe processes and spends seconds per command-line query on Windows

2 participants