Skip to content
Prev Previous commit
Next Next commit
Address feedback
  • Loading branch information
EgorBo committed Feb 2, 2022
commit 7d54099ac5a40ea734a3b7f877902e61d3998576
4 changes: 2 additions & 2 deletions src/coreclr/gc/unix/gcenv.unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -938,9 +938,9 @@ static size_t GetLogicalProcessorCacheSizeFromOS()
// reports L2 cache size and says nothing about L3 even if it exists. In this case we don't want
// to stuck with L2 (e.g. 256Kb on our test machine whether the real L3 is 32Mb)
// More details: https://github.com/dotnet/runtime/issues/60166
DWORD logicalCPUs = g_totalCpuCount;
DWORD logicalCPUs = GCToOSInterface::GetTotalProcessorCount();

size_t predictedSize = logicalCPUs*std::min(1536, std::max(256, (int)logicalCPUs*128))*1024;
size_t predictedSize = std::min(4096, std::max(256, (int)logicalCPUs*128))*1024;
cacheSize = std::max(predictedSize, cacheSize);
#endif

Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/gc/windows/gcenv.windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,12 +464,12 @@ size_t GetLogicalProcessorCacheSizeFromOS()
// likely represent L2 instead). We're going to use a processor-count based heuristic to predict its size and pick
// whatever is bigger. The same heuristic is used for Linux-arm64.
// More info: https://github.com/dotnet/runtime/issues/60166
uint32_t logicalCPUs = GetTotalProcessorCount();
uint32_t logicalCPUs = GCToOSInterface::GetTotalProcessorCount();

// Estimate cache size based on CPU count
// Assume lower core count are lighter weight parts which are likely to have smaller caches
// Assume L3$/CPU grows linearly from 256K to 1.5M/CPU as logicalCPUs grows from 2 to 12 CPUs
size_t predictedSize = logicalCPUs * std::min(1536, std::max(256, (int)logicalCPUs * 128)) * 1024;
size_t predictedSize = std::min(4096, std::max(256, (int)logicalCPUs * 128)) * 1024;
cache_size = std::max(predictedSize, cache_size);
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/pal/src/misc/sysinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ PAL_GetLogicalProcessorCacheSizeFromOS()
// More details: https://github.com/dotnet/runtime/issues/60166
DWORD logicalCPUs = PAL_GetLogicalCpuCountFromOS();

size_t predictedSize = logicalCPUs*std::min(1536, std::max(256, (int)logicalCPUs*128))*1024;
size_t predictedSize = std::min(4096, std::max(256, (int)logicalCPUs*128))*1024;
cacheSize = std::max(predictedSize, cacheSize);
#endif

Expand Down