-
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
Ambiguity in what Environment.ProcessorCount
returns
#13691
Comments
The comment in Mono repo (https://github.com/mono/mono/blob/6dff5fc81321a4fd9dd493e215d4ace543475054/mono/utils/mono-proclib.c#L760-L880) explains the reasons why we use _SC_NPROCESSORS_CONF instead of _SC_NPROCESSORS_ONLN on ARM. However, on contrary to Mono, we still use the process affinity at startup if available and that breaks us on Jetson TK1 unless the power management is set to never take CPUs offline. There is an issue #12510 to track that problem. |
While I believe the number of active processors can change during process runtime on a system that allows hot-pluggin processors, we query that from the system only once at process startup and cache all the topology information. So the value we return from |
Part of the solution should be updating the documentation to explain what Environment.ProcessorCount actually returns. I think it is reasonable to say that:
An environment variable that lets you set the expected level of parallelism (ie the number that ProcessorCount returns) may be more powerful. |
The documentation has been clarified by dotnet/dotnet-api-docs#6668. I think this can be closed now. |
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".SYSTEM_INFO::dwNumberOfProcessors
. This sounds correct. I assume that this number cannot change during the process lifetime.CPUGroupInfo::GetNumActiveProcessors
. Can this number change during the process lifetime?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_SC_NPROCESSORS_CONF
. This sounds correct._SC_NPROCESSORS_ONLN
at the process start. That does not sound right.cc @janvorli @kouvel
Originally posted by @jkotas in dotnet/coreclr#27543 (comment)
The text was updated successfully, but these errors were encountered: