summaryrefslogtreecommitdiff
path: root/src/vm/util.cpp
diff options
context:
space:
mode:
authorTom Deseyn <tom.deseyn@gmail.com>2018-01-29 21:11:10 +0100
committerMaoni Stephens <Maoni0@users.noreply.github.com>2018-01-29 12:11:10 -0800
commitcb73944d6d159bd02adc29f0588b97f0f76da1a1 (patch)
tree9c4f406b9d5bf886c64fceb19213c25176e988cd /src/vm/util.cpp
parent850a5bea5b8c317250f7f7ef85152d92468382b0 (diff)
downloadcoreclr-cb73944d6d159bd02adc29f0588b97f0f76da1a1.tar.gz
coreclr-cb73944d6d159bd02adc29f0588b97f0f76da1a1.tar.bz2
coreclr-cb73944d6d159bd02adc29f0588b97f0f76da1a1.zip
Perform PhysicalMemoryLimit check for workstation GC, refactor GetLargestOnDieCacheSize into GetCacheSizePerLogicalCpu (#15975)
* refactor: combine GetLargestOnDieCacheSize and GetLogicalCpuCount in GetCacheSizePerLogicalCpu * Perform PhysicalMemoryLimit check also for workstation GC
Diffstat (limited to 'src/vm/util.cpp')
-rw-r--r--src/vm/util.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/vm/util.cpp b/src/vm/util.cpp
index 692b72fc39..b9448dadbe 100644
--- a/src/vm/util.cpp
+++ b/src/vm/util.cpp
@@ -1854,9 +1854,10 @@ fDone:
#endif // _TARGET_X86_ || _TARGET_AMD64_
-size_t GetLargestOnDieCacheSize(BOOL bTrueSize)
+// fix this if/when AMD does multicore or SMT
+size_t GetCacheSizePerLogicalCpu(BOOL bTrueSize)
{
- // No CONTRACT possible because GetLargestOnDieCacheSize uses SEH
+ // No CONTRACT possible because GetCacheSizePerLogicalCpu uses SEH
STATIC_CONTRACT_NOTHROW;
STATIC_CONTRACT_GC_NOTRIGGER;
@@ -1911,6 +1912,31 @@ size_t GetLargestOnDieCacheSize(BOOL bTrueSize)
}
}
+ // TODO: Currently GetLogicalCpuCountFromOS() and GetLogicalCpuCountFallback() are broken on
+ // multi-core processor, but we never call into those two functions since we don't halve the
+ // gen0size when it's prescott and above processor. We keep the old version here for earlier
+ // generation system(Northwood based), perf data suggests on those systems, halve gen0 size
+ // still boost the performance(ex:Biztalk boosts about 17%). So on earlier systems(Northwood)
+ // based, we still go ahead and halve gen0 size. The logic in GetLogicalCpuCountFromOS()
+ // and GetLogicalCpuCountFallback() works fine for those earlier generation systems.
+ // If it's a Prescott and above processor or Multi-core, perf data suggests not to halve gen0
+ // size at all gives us overall better performance.
+ // This is going to be fixed with a new version in orcas time frame.
+ if (maxCpuId >= 2 && !((maxCpuId > 3) && (maxCpuId < 0x80000000)))
+ {
+ DWORD logicalProcessorCount = GetLogicalCpuCountFromOS(); //try to obtain HT enumeration from OS API
+
+ if (!logicalProcessorCount)
+ {
+ logicalProcessorCount = GetLogicalCpuCountFallback(); // OS API failed, Fallback to HT enumeration using CPUID
+ }
+
+ if (logicalProcessorCount)
+ {
+ tempSize = tempSize / logicalProcessorCount;
+ }
+ }
+
// update maxSize once with final value
maxTrueSize = tempSize;
@@ -2009,7 +2035,7 @@ size_t GetLargestOnDieCacheSize(BOOL bTrueSize)
maxSize = maxTrueSize * 3;
#endif
- // printf("GetLargestOnDieCacheSize returns %d, adjusted size %d\n", maxSize, maxTrueSize);
+ // printf("GetCacheSizePerLogicalCpu returns %d, adjusted size %d\n", maxSize, maxTrueSize);
if (bTrueSize)
return maxTrueSize;
else