Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKoundinya Veluri <kouvel@users.noreply.github.com>2021-01-25 23:21:48 +0300
committerGitHub <noreply@github.com>2021-01-25 23:21:48 +0300
commite42de0e2decb1df9e8dae6a063054ead2510a3f0 (patch)
tree962a64de7973c67eea7cb9474e1312e2356db901 /src/coreclr/utilcode
parent6959d9850526ec5a17fdd107bb15b37663456d9e (diff)
Update Environment.ProcessorCount on Windows to take into account the processor affinity mask (#45943)
- 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
Diffstat (limited to 'src/coreclr/utilcode')
-rw-r--r--src/coreclr/utilcode/util.cpp13
1 files changed, 0 insertions, 13 deletions
diff --git a/src/coreclr/utilcode/util.cpp b/src/coreclr/utilcode/util.cpp
index c034ae19318..cabe535e03c 100644
--- a/src/coreclr/utilcode/util.cpp
+++ b/src/coreclr/utilcode/util.cpp
@@ -856,7 +856,6 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr,
/*static*/ WORD CPUGroupInfo::m_initialGroup = 0;
/*static*/ CPU_Group_Info *CPUGroupInfo::m_CPUGroupInfoArray = NULL;
/*static*/ LONG CPUGroupInfo::m_initialization = 0;
-/*static*/ bool CPUGroupInfo::s_hadSingleProcessorAtStartup = false;
#if !defined(FEATURE_REDHAWK) && (defined(TARGET_AMD64) || defined(TARGET_ARM64))
// Calculate greatest common divisor
@@ -1014,18 +1013,6 @@ DWORD LCM(DWORD u, DWORD v)
m_threadUseAllCpuGroups = threadUseAllCpuGroups && hasMultipleGroups;
m_threadAssignCpuGroups = threadAssignCpuGroups && hasMultipleGroups;
#endif // TARGET_AMD64 || TARGET_ARM64
-
- // Determine if the process is affinitized to a single processor (or if the system has a single processor)
- DWORD_PTR processAffinityMask, systemAffinityMask;
- if (GetProcessAffinityMask(GetCurrentProcess(), &processAffinityMask, &systemAffinityMask))
- {
- processAffinityMask &= systemAffinityMask;
- if (processAffinityMask != 0 && // only one CPU group is involved
- (processAffinityMask & (processAffinityMask - 1)) == 0) // only one bit is set
- {
- s_hadSingleProcessorAtStartup = true;
- }
- }
}
/*static*/ BOOL CPUGroupInfo::IsInitialized()