Skip to content

Commit

Permalink
Revert "Cleanup softmx check and apply softmx to nursery expansion"
Browse files Browse the repository at this point in the history
  • Loading branch information
pshipton committed Aug 4, 2021
1 parent 8196bd8 commit 73d89ab
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 160 deletions.
17 changes: 5 additions & 12 deletions gc/base/Heap.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2021 IBM Corp. and others
* Copyright (c) 1991, 2016 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -531,7 +531,7 @@ MM_Heap::initializeCommonGCData(MM_EnvironmentBase* env, struct MM_CommonGCData*
* @return Size of the adjustable heap memory
*/
uintptr_t
MM_Heap::getActualSoftMxSize(MM_EnvironmentBase* env, uintptr_t memoryType)
MM_Heap::getActualSoftMxSize(MM_EnvironmentBase* env)
{
uintptr_t actualSoftMX = 0;
MM_GCExtensionsBase* extensions = env->getExtensions();
Expand All @@ -544,18 +544,11 @@ MM_Heap::getActualSoftMxSize(MM_EnvironmentBase* env, uintptr_t memoryType)

uintptr_t nurserySize = totalHeapSize - tenureSize;

if (MEMORY_TYPE_NEW == memoryType) {
actualSoftMX = (uintptr_t)(extensions->softMx * ((double)extensions->maxNewSpaceSize / extensions->memoryMax));
} else if (MEMORY_TYPE_OLD == memoryType) {
if (nurserySize <= extensions->softMx) {
actualSoftMX = extensions->softMx - nurserySize;
} else {
actualSoftMX = 0;
}
if (nurserySize <= extensions->softMx) {
actualSoftMX = extensions->softMx - nurserySize;
} else {
Assert_MM_unreachable();
actualSoftMX = 0;
}

} else {
actualSoftMX = extensions->softMx;
}
Expand Down
4 changes: 2 additions & 2 deletions gc/base/Heap.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2021 IBM Corp. and others
* Copyright (c) 1991, 2020 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -165,7 +165,7 @@ class MM_Heap : public MM_BaseVirtual
void initializeCommonGCStartData(MM_EnvironmentBase *env, struct MM_CommonGCStartData *data);
void initializeCommonGCEndData(MM_EnvironmentBase *env, struct MM_CommonGCEndData *data);

uintptr_t getActualSoftMxSize(MM_EnvironmentBase *env, uintptr_t memoryType = MEMORY_TYPE_OLD);
uintptr_t getActualSoftMxSize(MM_EnvironmentBase *env);

/**
* Create a Heap object.
Expand Down
32 changes: 0 additions & 32 deletions gc/base/MemorySubSpace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1143,38 +1143,6 @@ MM_MemorySubSpace::canExpand(MM_EnvironmentBase* env, uintptr_t expandSize)
return false;
}

/**
* Compare the specified expand amount with -XsoftMX value
* @return Updated expand size
*/
uintptr_t
MM_MemorySubSpace::adjustExpansionWithinSoftMax(MM_EnvironmentBase *env, uintptr_t expandSize, uintptr_t minimumBytesRequired, uintptr_t memoryType)
{
MM_Heap *heap = env->getExtensions()->getHeap();

uintptr_t actualSoftMx = heap->getActualSoftMxSize(env, memoryType);
uintptr_t activeMemorySize = getActiveMemorySize(memoryType);
OMRPORT_ACCESS_FROM_OMRPORT(env->getPortLibrary());

if (0 != actualSoftMx) {
if ((0 != minimumBytesRequired) && ((activeMemorySize + minimumBytesRequired) > actualSoftMx)) {
if (J9_EVENT_IS_HOOKED(env->getExtensions()->omrHookInterface, J9HOOK_MM_OMR_OOM_DUE_TO_SOFTMX)) {
ALWAYS_TRIGGER_J9HOOK_MM_OMR_OOM_DUE_TO_SOFTMX(env->getExtensions()->omrHookInterface, env->getOmrVMThread(), omrtime_hires_clock(),
heap->getMaximumMemorySize(), heap->getActiveMemorySize(memoryType), actualSoftMx, minimumBytesRequired);
actualSoftMx = heap->getActualSoftMxSize(env, memoryType);
}
}
if (actualSoftMx < activeMemorySize) {
/* if our softmx is smaller than our currentsize, we should be contracting not expanding */
expandSize = 0;
} else if ((activeMemorySize + expandSize) > actualSoftMx) {
/* we would go past our -XsoftMx so just expand up to it instead */
expandSize = actualSoftMx - activeMemorySize;
}
}
return expandSize;
}

/**
* Adjust the specified expansion amount by the specified user increment amount (i.e. -Xmoi)
* @return the updated expand size
Expand Down
1 change: 0 additions & 1 deletion gc/base/MemorySubSpace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ friend class GC_MemorySubSpaceRegionIterator;
bool setResizable(bool resizable);

bool canExpand(MM_EnvironmentBase *env, uintptr_t expandSize);
virtual uintptr_t adjustExpansionWithinSoftMax(MM_EnvironmentBase *env, uintptr_t expandSize, uintptr_t minimumBytesRequired, uintptr_t memoryType = MEMORY_TYPE_OLD);
virtual uintptr_t adjustExpansionWithinUserIncrement(MM_EnvironmentBase *env, uintptr_t expandSize);
uintptr_t maxExpansion(MM_EnvironmentBase *env);
virtual uintptr_t maxExpansionInSpace(MM_EnvironmentBase *env);
Expand Down
Loading

0 comments on commit 73d89ab

Please sign in to comment.