From aef110aa3d030dc4873f2e5714ffdc05a24fc61b Mon Sep 17 00:00:00 2001 From: Aleksandar Micic Date: Tue, 23 Jul 2024 10:31:13 -0400 Subject: [PATCH] nonZero max TLH size Signed-off-by: Aleksandar Micic --- gc/base/GCExtensionsBase.hpp | 8 +++++++- gc/base/MemoryPoolAddressOrderedList.cpp | 4 ++-- gc/base/MemoryPoolLargeObjects.cpp | 4 ++-- gc/base/MemoryPoolSplitAddressOrderedListBase.hpp | 4 ++-- gc/base/MemorySubSpaceSemiSpace.cpp | 2 +- gc/base/TLHAllocationSupport.cpp | 10 +++++++++- 6 files changed, 23 insertions(+), 9 deletions(-) diff --git a/gc/base/GCExtensionsBase.hpp b/gc/base/GCExtensionsBase.hpp index 2bce06cfc68..137de8ec5bd 100644 --- a/gc/base/GCExtensionsBase.hpp +++ b/gc/base/GCExtensionsBase.hpp @@ -346,7 +346,9 @@ class MM_GCExtensionsBase : public MM_BaseVirtual { #endif /* defined(OMR_GC_COMBINATION_SPEC) */ uintptr_t tlhMinimumSize; - uintptr_t tlhMaximumSize; + uintptr_t tlhMaximumSize; // to be removed + uintptr_t tlhMaximumSizeBatchCleared; + uintptr_t tlhMaximumSizeNonBatchCleared; uintptr_t tlhInitialSize; uintptr_t tlhIncrementSize; uintptr_t tlhSurvivorDiscardThreshold; /**< below this size GC (Scavenger) will discard survivor copy cache TLH, if alloc not succeeded (otherwise we reuse memory for next TLH) */ @@ -1108,6 +1110,8 @@ class MM_GCExtensionsBase : public MM_BaseVirtual { MMINLINE uintptr_t getMinimumFreeEntrySize() { return tlhMinimumSize; } + MMINLINE uintptr_t getTlhMaximumSize() { return OMR_MAX(tlhMaximumSizeBatchCleared, tlhMaximumSizeNonBatchCleared); } + MMINLINE MM_Heap* getHeap() { return heap; } MMINLINE void @@ -1564,6 +1568,8 @@ class MM_GCExtensionsBase : public MM_BaseVirtual { #endif /* defined(OMR_GC_COMBINATION_SPEC) */ , tlhMinimumSize(MINIMUM_TLH_SIZE) , tlhMaximumSize(131072) + , tlhMaximumSizeBatchCleared(128 * 1024) + , tlhMaximumSizeNonBatchCleared(1024 * 1024) , tlhInitialSize(2048) , tlhIncrementSize(4096) , tlhSurvivorDiscardThreshold(tlhMinimumSize) diff --git a/gc/base/MemoryPoolAddressOrderedList.cpp b/gc/base/MemoryPoolAddressOrderedList.cpp index 02d7d93c3ec..d28a7517de1 100644 --- a/gc/base/MemoryPoolAddressOrderedList.cpp +++ b/gc/base/MemoryPoolAddressOrderedList.cpp @@ -114,9 +114,9 @@ MM_MemoryPoolAddressOrderedList::initialize(MM_EnvironmentBase *env) #if defined(OMR_GC_THREAD_LOCAL_HEAP) /* this memoryPool can be used by scavenger, maximum tlh size should be max(_extensions->tlhMaximumSize, _extensions->scavengerScanCacheMaximumSize) */ #if defined(OMR_GC_MODRON_SCAVENGER) - uintptr_t tlhMaximumSize = OMR_MAX(_extensions->tlhMaximumSize, _extensions->scavengerScanCacheMaximumSize); + uintptr_t tlhMaximumSize = OMR_MAX(_extensions->getTlhMaximumSize(), _extensions->scavengerScanCacheMaximumSize); #else /* OMR_GC_MODRON_SCAVENGER */ - uintptr_t tlhMaximumSize = _extensions->tlhMaximumSize; + uintptr_t tlhMaximumSize = _extensions->getTlhMaximumSize(); #endif /* OMR_GC_MODRON_SCAVENGER */ _largeObjectAllocateStats = MM_LargeObjectAllocateStats::newInstance(env, (uint16_t)ext->largeObjectAllocationProfilingTopK, ext->largeObjectAllocationProfilingThreshold, ext->largeObjectAllocationProfilingVeryLargeObjectThreshold, (float)ext->largeObjectAllocationProfilingSizeClassRatio / (float)100.0, _extensions->heap->getMaximumMemorySize(), tlhMaximumSize + _minimumFreeEntrySize, _extensions->tlhMinimumSize); diff --git a/gc/base/MemoryPoolLargeObjects.cpp b/gc/base/MemoryPoolLargeObjects.cpp index 9048808fa8e..eefa31ebddf 100644 --- a/gc/base/MemoryPoolLargeObjects.cpp +++ b/gc/base/MemoryPoolLargeObjects.cpp @@ -102,9 +102,9 @@ MM_MemoryPoolLargeObjects::initialize(MM_EnvironmentBase* env) uintptr_t minimumFreeEntrySize = OMR_MAX(_memoryPoolLargeObjects->getMinimumFreeEntrySize(), _memoryPoolSmallObjects->getMinimumFreeEntrySize()); /* this memoryPool can be used by scavenger, maximum tlh size should be max(_extensions->tlhMaximumSize, _extensions->scavengerScanCacheMaximumSize) */ #if defined(OMR_GC_MODRON_SCAVENGER) - uintptr_t tlhMaximumSize = OMR_MAX(_extensions->tlhMaximumSize, _extensions->scavengerScanCacheMaximumSize); + uintptr_t tlhMaximumSize = OMR_MAX(_extensions->getTlhMaximumSize(), _extensions->scavengerScanCacheMaximumSize); #else /* OMR_GC_MODRON_SCAVENGER */ - uintptr_t tlhMaximumSize = _extensions->tlhMaximumSize; + uintptr_t tlhMaximumSize = _extensions->getTlhMaximumSize(); #endif /* OMR_GC_MODRON_SCAVENGER */ _largeObjectAllocateStats = MM_LargeObjectAllocateStats::newInstance(env, (uint16_t)_extensions->largeObjectAllocationProfilingTopK, _extensions->largeObjectAllocationProfilingThreshold, _extensions->largeObjectAllocationProfilingVeryLargeObjectThreshold, (float)_extensions->largeObjectAllocationProfilingSizeClassRatio / (float)100.0, _extensions->heap->getMaximumMemorySize(), tlhMaximumSize + minimumFreeEntrySize, _extensions->tlhMinimumSize); diff --git a/gc/base/MemoryPoolSplitAddressOrderedListBase.hpp b/gc/base/MemoryPoolSplitAddressOrderedListBase.hpp index 90b4575503a..d8fbd1197cb 100644 --- a/gc/base/MemoryPoolSplitAddressOrderedListBase.hpp +++ b/gc/base/MemoryPoolSplitAddressOrderedListBase.hpp @@ -381,9 +381,9 @@ class MM_MemoryPoolSplitAddressOrderedListBase : public MM_MemoryPoolAddressOrde /* this memoryPool can be used by scavenger, maximum tlh size * should be max(_extensions->tlhMaximumSize, _extensions->scavengerScanCacheMaximumSize) */ - uintptr_t tlhMaximumSize = OMR_MAX(_extensions->tlhMaximumSize, _extensions->scavengerScanCacheMaximumSize); + uintptr_t tlhMaximumSize = OMR_MAX(_extensions->getTlhMaximumSize(), _extensions->scavengerScanCacheMaximumSize); #else /* OMR_GC_MODRON_SCAVENGER */ - uintptr_t tlhMaximumSize = _extensions->tlhMaximumSize; + uintptr_t tlhMaximumSize = _extensions->getTlhMaximumSize(); #endif /* OMR_GC_MODRON_SCAVENGER */ return tlhMaximumSize; } diff --git a/gc/base/MemorySubSpaceSemiSpace.cpp b/gc/base/MemorySubSpaceSemiSpace.cpp index 3bdca939f3a..c63ce0e4be2 100644 --- a/gc/base/MemorySubSpaceSemiSpace.cpp +++ b/gc/base/MemorySubSpaceSemiSpace.cpp @@ -436,7 +436,7 @@ MM_MemorySubSpaceSemiSpace::initialize(MM_EnvironmentBase *env) _memorySubSpaceSurvivor->isAllocatable(false); /* this memoryPool can be used by scavenger, maximum tlh size should be max(_extensions->tlhMaximumSize, _extensions->scavengerScanCacheMaximumSize) */ - uintptr_t tlhMaximumSize = OMR_MAX(_extensions->tlhMaximumSize, _extensions->scavengerScanCacheMaximumSize); + uintptr_t tlhMaximumSize = OMR_MAX(_extensions->getTlhMaximumSize(), _extensions->scavengerScanCacheMaximumSize); _largeObjectAllocateStats = MM_LargeObjectAllocateStats::newInstance(env, (uint16_t)_extensions->largeObjectAllocationProfilingTopK, _extensions->largeObjectAllocationProfilingThreshold, _extensions->largeObjectAllocationProfilingVeryLargeObjectThreshold, (float)_extensions->largeObjectAllocationProfilingSizeClassRatio / (float)100.0, _extensions->heap->getMaximumMemorySize(), tlhMaximumSize + _extensions->minimumFreeEntrySize, _extensions->tlhMinimumSize); if (NULL == _largeObjectAllocateStats) { diff --git a/gc/base/TLHAllocationSupport.cpp b/gc/base/TLHAllocationSupport.cpp index bdddac8beed..2d48050db11 100644 --- a/gc/base/TLHAllocationSupport.cpp +++ b/gc/base/TLHAllocationSupport.cpp @@ -124,9 +124,17 @@ MM_TLHAllocationSupport::refresh(MM_EnvironmentBase *env, MM_AllocateDescription */ uintptr_t sizeInBytesRequired = allocDescription->getContiguousBytes(); uintptr_t tlhMinimumSize = extensions->tlhMinimumSize; - uintptr_t tlhMaximumSize = extensions->tlhMaximumSize; + uintptr_t tlhMaximumSize = extensions->tlhMaximumSizeNonBatchCleared; + +#if defined(OMR_GC_BATCH_CLEAR_TLH) + if (0 != extensions->batchClearTLH) { + tlhMaximumSize = extensions->tlhMaximumSizeBatchCleared; + } +#endif /* defined(OMR_GC_BATCH_CLEAR_TLH) */ + uintptr_t halfRefreshSize = getRefreshSize() >> 1; uintptr_t abandonSize = (tlhMinimumSize > halfRefreshSize ? tlhMinimumSize : halfRefreshSize); + if (sizeInBytesRequired > abandonSize) { /* increase thread hungriness if we did not refresh */ if (getRefreshSize() < tlhMaximumSize && sizeInBytesRequired < tlhMaximumSize) {