Closed
Description
We seem to also have ambiguity about what Environment.ProcessorCount
returns. According to the docs, it should return "the number of processors on the current machine".
- On Windows without NUMA, it returns
SYSTEM_INFO::dwNumberOfProcessors
. This sounds correct. I assume that this number cannot change during the process lifetime. - On Windows with NUMA, it returns
CPUGroupInfo::GetNumActiveProcessors
. Can this number change during the process lifetime? - On Unix, with
HAVE_SCHED_GETAFFINITY
, it returns the process affinity at the process start: https://github.com/dotnet/coreclr/blob/6ce179a17061abbbe9f904f878943a28c8041a62/src/pal/src/misc/sysinfo.cpp#L161 - On Unix ARM and ARM64, it returns
_SC_NPROCESSORS_CONF
. This sounds correct. - On Unix on other platforms, it returns
_SC_NPROCESSORS_ONLN
at the process start. That does not sound right.
Originally posted by @jkotas in dotnet/coreclr#27543 (comment)