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

Update Environment.ProcessorCount on Windows to take into account the processor affinity mask #45943

Merged
merged 1 commit into from
Jan 25, 2021

Commits on Dec 11, 2020

  1. Update Environment.ProcessorCount on Windows to take into account the…

    … processor affinity mask
    
    - Similarly to cases on Unixes where sched_getaffinity is available
    - If `GCCpuGroup` and `Thread_UseAllCpuGroups` are both enabled, I'm not sure if the `CPUGroupInfo` count of active processors takes affinity into account as the docs are not clear, for now I'm not modifying that path until I can verify it
    - Otherwise, a process that is started with a specific processor affinity mask still shows full CPU count
    - This is one of the differences in the portable managed thread pool implementation, which relies on Environment.ProcessorCount, as opposed to the native thread pool, which uses the affinity mask
    - After this change, in affinitized cases on Windows the behavior is consistent perf-wise with Linux in similar situations:
      - The portable thread pool uses the same worker thread count as the native thread pool
      - `Environment.ProcessorCount` returns the number of processors the the process is affinitized to, which may be less than it would have returned before
    kouvel committed Dec 11, 2020
    Configuration menu
    Copy the full SHA
    442b881 View commit details
    Browse the repository at this point in the history