Skip to content
Prev Previous commit
Use GetTotalProcessorCount for windows
  • Loading branch information
kunalspathak committed Jun 22, 2022
commit aaab0bf88921cdfd71b0e95128c38e73cd0e893e
7 changes: 2 additions & 5 deletions src/coreclr/gc/windows/gcenv.windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ size_t GetLogicalProcessorCacheSizeFromOS()
{
size_t cache_size = 0;
size_t cache_level = 0;
uint32_t totalCPUCount = 0;

DWORD nEntries = 0;

Expand Down Expand Up @@ -433,10 +432,6 @@ size_t GetLogicalProcessorCacheSizeFromOS()
cache_level = pslpi[i].Cache.Level;
}
}
else if (pslpi[i].Relationship == RelationProcessorCore)
{
totalCPUCount++;
}
}
cache_size = last_cache_size;
}
Expand All @@ -448,6 +443,8 @@ size_t GetLogicalProcessorCacheSizeFromOS()
#if defined(TARGET_ARM64)
if (cache_level != 3)
{
uint32_t totalCPUCount = GCToOSInterface::GetTotalProcessorCount();

// We expect to get the L3 cache size for Arm64 but currently expected to be missing that info
// from most of the machines.
// Hence, just use the following heuristics at best depending on the CPU count
Expand Down
7 changes: 2 additions & 5 deletions src/coreclr/vm/gcenv.os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,6 @@ size_t GetLogicalProcessorCacheSizeFromOS()
{
size_t cache_size = 0;
size_t cache_level = 0;
uint32_t totalCPUCount = 0;
DWORD nEntries = 0;

// Try to use GetLogicalProcessorInformation API and get a valid pointer to the SLPI array if successful. Returns NULL
Expand Down Expand Up @@ -618,10 +617,6 @@ size_t GetLogicalProcessorCacheSizeFromOS()
cache_level = pslpi[i].Cache.Level;
}
}
else if (pslpi[i].Relationship == RelationProcessorCore)
{
totalCPUCount++;
}
}
cache_size = last_cache_size;
}
Expand All @@ -633,6 +628,8 @@ size_t GetLogicalProcessorCacheSizeFromOS()
#if defined(TARGET_ARM64)
if (cache_level != 3)
{
uint32_t totalCPUCount = GCToOSInterface::GetTotalProcessorCount();

// We expect to get the L3 cache size for Arm64 but currently expected to be missing that info
// from most of the machines.
// Hence, just use the following heuristics at best depending on the CPU count
Expand Down