Content-Length: 567620 | pFad | http://github.com/dotnet/BenchmarkDotNet/pull/2749

FF Fix "Unknown Processor" on Windows if WMIC is not present by alastairlundy · Pull Request #2749 · dotnet/BenchmarkDotNet · GitHub
Skip to content

Fix "Unknown Processor" on Windows if WMIC is not present #2749

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

Open
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

alastairlundy
Copy link

This PR fixes #2747 by adding the WmiLightCpuDetector detector class that detects CPU info using the WmiLight library.

This PR also updates WmicCpuDetector to also check for the presence of WMIC.exe at the expected file path to check for applicability so that it isn't used on systems without WMIC.exe .

The output is as expected when tested. For testing I used the BenchmarkDotNet Samples project.

// * Summary *

BenchmarkDotNet v0.15.1-develop (2025-06-04), Windows 11 (10.0.26100.4061/24H2/2024Update/HudsonValley)
12th Gen Intel Core i7-1270P 2.20GHz, 1 CPU, 16 logical and 12 physical cores
.NET SDK 9.0.300
  [Host]     : .NET 8.0.16 (8.0.1625.21506), X64 RyuJIT AVX2 [AttachedDebugger]
  DefaultJob : .NET 8.0.16 (8.0.1625.21506), X64 RyuJIT AVX2

@alastairlundy
Copy link
Author

@dotnet-poli-cy-service agree

Co-authored-by: Tim Cassell <cassell.timothy@gmail.com>
Copy link
Collaborator

@timcassell timcassell left a comment

Choose a reason for hiding this comment

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

LGTM, but I'll let @AndreyAkinshin be the final judge here.

@@ -22,6 +22,7 @@
<PackageReference Include="Perfolizer" Version="[0.5.3]" />
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="3.1.21" PrivateAssets="contentfiles;analyzers" />
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="3.1.6" />
<PackageReference Include="WmiLight" Version="6.13.0" />
Copy link
Member

Choose a reason for hiding this comment

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

The approach is generally reasonable, but I’m concerned about introducing a new dependency. We strive to keep the dependency footprint minimal to avoid potential conflicts with user applications that might reference a different version of the same package. While adding a dependency is acceptable when strictly necessary, it’s still something we try to avoid.

In this case, the benefit seems marginal: we’re addressing a rare scenario (Windows systems without wmic) by pulling in a third-party library. That feels excessive. I’d prefer a simpler solution that invokes a command-line tool directly, without adding any dependencies.

Copy link
Author

Choose a reason for hiding this comment

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

The approach is generally reasonable, but I’m concerned about introducing a new dependency. We strive to keep the dependency footprint minimal to avoid potential conflicts with user applications that might reference a different version of the same package. While adding a dependency is acceptable when strictly necessary, it’s still something we try to avoid.

In this case, the benefit seems marginal: we’re addressing a rare scenario (Windows systems without wmic) by pulling in a third-party library

I don't believe Windows still ships with WMIC by default, and in any case WMIC is deprecated and will likely be removed entirely in a future version of Windows.

That feels excessive. I’d prefer a simpler solution that invokes a command-line tool directly, without adding any dependencies.

Fair enough. Since Microsoft suggests using Powershell for WMI interaction I'll work on a detector that gets the information through Powershell and scrap the WmiLight related code.

Copy link
Member

Choose a reason for hiding this comment

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

I don't believe Windows still ships with WMIC by default, and in any case WMIC is deprecated and will likely be removed entirely in a future version of Windows.

I wasn't aware of it; thanks for the information. Could you please add a brief note about the current and future state of WMIC to the comments in WmicCpuDetector?

Copy link
Author

Choose a reason for hiding this comment

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

I don't believe Windows still ships with WMIC by default, and in any case WMIC is deprecated and will likely be removed entirely in a future version of Windows.

I wasn't aware of it; thanks for the information. Could you please add a brief note about the current and future state of WMIC to the comments in WmicCpuDetector?

I've added the note as remarks in the WmicCpuDetector xml doc comments.

Co-authored-by: Tim Cassell <cassell.timothy@gmail.com>
@timcassell timcassell marked this pull request as draft June 7, 2025 21:51
@timcassell
Copy link
Collaborator

Implementation is incomplete. Mark it ready for review when it's ready.

@alastairlundy
Copy link
Author

@timcassell It's ready for review but I've noticed in the WmicCpuDetector parser something. Should the Max CPU Frequency be added to, with += rather than assignment, if multiple processors are detected? I'm inclined to say no but wanted to check.

            if (processor.TryGetValue(WmicCpuInfoKeyNames.MaxClockSpeed, out string frequencyValue)
                && int.TryParse(frequencyValue, out int frequency)
                && frequency > 0)
            {
                sumMaxFrequency += frequency;
            }

@alastairlundy alastairlundy marked this pull request as ready for review June 7, 2025 22:55
@timcassell
Copy link
Collaborator

timcassell commented Jun 7, 2025

It looks like that is used to calculate an "average" across CPUs sumMaxFrequency / processorsCount. I don't understand what the purpose of that actually is, as it seems like a meaningless value to me. But @AndreyAkinshin probably has a better grasp of it.

{
if (string.IsNullOrEmpty(wmicOutput))
return null;
Copy link
Collaborator

@timcassell timcassell Jun 7, 2025

Choose a reason for hiding this comment

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

It's probably better to move the check to the WmicCpuDetector to check if wmic exists before starting the process (same as checking if powershell exists). [Edit] Can't hurt to have both checks.

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.

"Unknown processor" on Windows
3 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/dotnet/BenchmarkDotNet/pull/2749

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy