Skip to content

Commit

Permalink
nonZero max TLH size
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksandar Micic <Aleksandar_Micic@ca.ibm.com>
  • Loading branch information
Aleksandar Micic authored and Aleksandar Micic committed Jul 25, 2024
1 parent 3223d8d commit aef110a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 9 deletions.
8 changes: 7 additions & 1 deletion gc/base/GCExtensionsBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) */
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions gc/base/MemoryPoolAddressOrderedList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions gc/base/MemoryPoolLargeObjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions gc/base/MemoryPoolSplitAddressOrderedListBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion gc/base/MemorySubSpaceSemiSpace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 9 additions & 1 deletion gc/base/TLHAllocationSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit aef110a

Please sign in to comment.