-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Arm64: Environment.ProcessorCount returns wrong value on higher core machine #67180
Comments
Tagging subscribers to this area: @mangod9 Issue DetailsIn #45943, we did a breaking change to have Although #47427, calls out that the code that relies on runtime/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.IO.Windows.cs Lines 41 to 43 in 32320b1
On higher core Arm64 machine, had
|
this looks to be hardware specific -- I couldnt repro on an arm64 VM with 32 cores. |
When I set |
I am helping @kunalspathak to debug this. |
I can confirm the issue. The program reports the incorrect value of |
hmm, interesting. Is this every other run of the process or subsequent calls in the same process? I dont seem to be able to repro it on a 32 core VM fyi. |
The machine in question has two processor groups of different sizes. Unless you set environment variables to use all CPU groups, |
ok that makes sense. Need to determine why there is an asymmetric config on that hardware. |
According to documentation, in Windows 11 processes are no longer constrained to a single processor group by default. I guess that means we should consider |
@AntonLapounov - any further update on this? |
I have started discussion #67308 and an internal email thread with OS folks regarding this. I assume you can set the environment variables as a workaround until we have a fix. |
@AntonLapounov can you please set the milestone of this issue to remove the untriaged label? |
@AntonLapounov @kunalspathak guess we dont plan on fixing for 7 right? |
Yes, apps will have to opt-in to make all processor groups available to the runtime. |
Do we plan to include the documentation of the environment variable to use all processor groups for Windows 11/Windows server 2022? |
Those configuration settings were introduced a long time ago and are already documented. If you think the documentation should be improved, you may submit a documentation PR. |
They need to be certainly improved because of change in behavior on Win11 and with many-core machines are getting more common. Under what API/category should the documentation go to? |
Affected APIs should get a note:
I suspect that we may still end up doing more product changes here given the feedback in #72441. I would wait for that issue to get resolved before starting on documentation edits. (If you have access to a Win2022 machine with large number of cores, it would be useful to get answer to #72441 (comment) .) |
In #45943, we did a breaking change to have
Environment.ProcessorCount
take processor affinity into account on Windows. It works well on x64 machines, but on arm64 machines with higher CPU count, it returns wrong value.Although #47427, calls out that the code that relies on
Environment.ProcessorCount
for parallelism, should update it to scale better because of reduced return value. However, there is performance sensitive code in IOThreadPool that relies onEnvironment.Processor
to decide on the number of "IO completion poller threads" to use in the application.runtime/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.IO.Windows.cs
Lines 41 to 43 in 32320b1
On higher core Arm64 machine, had
ProcessorCount
returned correct value, I could see that we would create more IO completion threads to handle more concurrent requests. In an internal application, I can see it boosts performance by2.25X
on higher core Arm64 machines.The text was updated successfully, but these errors were encountered: