Skip to content

Commit

Permalink
Adding Tenure bytes deviation to modify concurrent kickoff
Browse files Browse the repository at this point in the history
- Added heuristics to keep track of bytes moving from nursery to tenure, along with the deviation of this value.
- `_avgTenureBytes` keeps track of average bytes that are being tenured, while `_avgTenureBytesDeviation` keeps track of the average amount of deviation in bytes being tenured.
- Adding this deviation into the calculation for concurrent kickoff
- The default boost for the deviation on top of the existing kickoff logic is 2x. This field is called `tenureBytesDeviationBoost`
- This change results in far less aborts/percolates, but at the expense of more global GC cycles
- Will be accompanied by a change on the j9 side for explicitly setting `tenureBytesDeviationBoost`. Setting this to 0 will effectively disable it's effects
- This calculation is done for both SOA bytes (if OMR_GC_LARGE_OBJECT_AREA flag is set), and tenured bytes in general if not set

Signed-off-by: Cedric Hansen <cedric.hansen@ibm.com>
  • Loading branch information
cedrichansen committed Jul 18, 2019
1 parent 3e5cac1 commit 364483f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
2 changes: 2 additions & 0 deletions gc/base/GCExtensionsBase.hpp
Expand Up @@ -267,6 +267,7 @@ class MM_GCExtensionsBase : public MM_BaseVirtual {
uintptr_t oldHeapSizeOnLastGlobalGC;
uintptr_t freeOldHeapSizeOnLastGlobalGC;
float concurrentKickoffTenuringHeadroom; /**< percentage of free memory remaining in tenure heap. Used in conjunction with free memory to determine concurrent mark kickoff */
float tenureBytesDeviationBoost; /**< boost factor for tenuring deviation used for concurrent mark kickoff math */
#endif /* OMR_GC_MODRON_SCAVENGER */
#if defined(OMR_GC_REALTIME)
MM_RememberedSetSATB* sATBBarrierRememberedSet; /**< The snapshot at the beginning barrier remembered set used for the write barrier */
Expand Down Expand Up @@ -1348,6 +1349,7 @@ class MM_GCExtensionsBase : public MM_BaseVirtual {
, oldHeapSizeOnLastGlobalGC(UDATA_MAX)
, freeOldHeapSizeOnLastGlobalGC(UDATA_MAX)
, concurrentKickoffTenuringHeadroom((float)0.02)
, tenureBytesDeviationBoost((float)2)
#endif /* OMR_GC_MODRON_SCAVENGER */
#if defined(OMR_GC_REALTIME)
, sATBBarrierRememberedSet(NULL)
Expand Down
5 changes: 3 additions & 2 deletions gc/base/standard/ConcurrentGC.cpp
Expand Up @@ -1836,12 +1836,13 @@ MM_ConcurrentGC::potentialFreeSpace(MM_EnvironmentBase *env, MM_AllocateDescript
headRoom = (uintptr_t)(_extensions->concurrentKickoffTenuringHeadroom * _extensions->lastGlobalGCFreeBytesLOA);
} else {
assume0(SOA == _meteringType);
nurseryPromotion = scavengerStats->_avgTenureSOABytes == 0 ? 1 : scavengerStats->_avgTenureSOABytes;
nurseryPromotion = scavengerStats->_avgTenureSOABytes == 0 ? 1 : (uintptr_t)(scavengerStats->_avgTenureSOABytes + (env->getExtensions()->tenureBytesDeviationBoost * scavengerStats->_avgTenureBytesDeviation));

currentOldFree = oldSubspace->getApproximateActiveFreeMemorySize() - oldSubspace->getApproximateActiveFreeLOAMemorySize();
headRoom = (uintptr_t)(_extensions->concurrentKickoffTenuringHeadroom * (_extensions->getLastGlobalGCFreeBytes() - _extensions->lastGlobalGCFreeBytesLOA));
}
#else
nurseryPromotion = scavengerStats->_avgTenureBytes == 0 ? 1: scavengerStats->_avgTenureBytes;
nurseryPromotion = scavengerStats->_avgTenureBytes == 0 ? 1: (uintptr_t)(scavengerStats->_avgTenureBytes + (env->getExtensions()->tenureBytesDeviationBoost * scavengerStats->_avgTenureBytesDeviation));
currentOldFree = oldSubspace->getApproximateActiveFreeMemorySize();
headRoom = (uintptr_t)(_extensions->concurrentKickoffTenuringHeadroom * _extensions->getLastGlobalGCFreeBytes());
#endif
Expand Down
19 changes: 18 additions & 1 deletion gc/base/standard/Scavenger.cpp
Expand Up @@ -832,10 +832,27 @@ MM_Scavenger::calcGCStats(MM_EnvironmentStandard *env)
if (scavengerGCStats->_gcCount > 1 ) {
scavengerGCStats->_avgInitialFree = (uintptr_t)MM_Math::weightedAverage((float)scavengerGCStats->_avgInitialFree, (float)initialFree, INITIAL_FREE_HISTORY_WEIGHT);
scavengerGCStats->_avgTenureBytes = (uintptr_t)MM_Math::weightedAverage((float)scavengerGCStats->_avgTenureBytes, (float)scavengerGCStats->_tenureAggregateBytes, TENURE_BYTES_HISTORY_WEIGHT);
scavengerGCStats->_tenureBytesDeviation = (float)(scavengerGCStats->_tenureAggregateBytes) - (scavengerGCStats->_avgTenureBytes);
scavengerGCStats->_avgTenureBytesDeviation = (uintptr_t)sqrtf(MM_Math::weightedAverage((float)(scavengerGCStats->_avgTenureBytesDeviation * scavengerGCStats->_avgTenureBytesDeviation),
(float)(scavengerGCStats->_tenureBytesDeviation * scavengerGCStats->_tenureBytesDeviation), TENURE_BYTES_HISTORY_WEIGHT));

if (_extensions->debugConcurrentMark) {
OMRPORT_ACCESS_FROM_OMRPORT(env->getPortLibrary());
omrtty_printf("Tenure bytes: %d\n_avgTenureBytes: %zu\n_tenureBytesDeviation: %f\n_avgTenureBytesDeviation: %zu\n",scavengerGCStats->_tenureAggregateBytes, scavengerGCStats->_avgTenureBytes, scavengerGCStats->_tenureBytesDeviation, scavengerGCStats->_avgTenureBytesDeviation);
}

#if defined(OMR_GC_LARGE_OBJECT_AREA)
scavengerGCStats->_avgTenureSOABytes = (uintptr_t)MM_Math::weightedAverage((float)scavengerGCStats->_avgTenureSOABytes,
(float)(scavengerGCStats->_tenureAggregateBytes - scavengerGCStats->_tenureLOABytes),
TENURE_BYTES_HISTORY_WEIGHT);
TENURE_BYTES_HISTORY_WEIGHT);

scavengerGCStats->_tenureBytesDeviation = (float)(scavengerGCStats->_tenureAggregateBytes - scavengerGCStats->_tenureLOABytes) - (scavengerGCStats->_avgTenureBytes);
scavengerGCStats->_avgTenureBytesDeviation = (uintptr_t)sqrtf(MM_Math::weightedAverage((float)(scavengerGCStats->_avgTenureBytesDeviation * scavengerGCStats->_avgTenureBytesDeviation),
(float)(scavengerGCStats->_tenureBytesDeviation * scavengerGCStats->_tenureBytesDeviation), TENURE_BYTES_HISTORY_WEIGHT));
if (_extensions->debugConcurrentMark) {
OMRPORT_ACCESS_FROM_OMRPORT(env->getPortLibrary());
omrtty_printf("SOA bytes: %d\n_avgTenureBytes: %zu\n_tenureBytesDeviation: %f\n_avgTenureBytesDeviation: %zu\n",(scavengerGCStats->_tenureAggregateBytes - scavengerGCStats->_tenureLOABytes), scavengerGCStats->_avgTenureBytes,scavengerGCStats->_tenureBytesDeviation, scavengerGCStats->_avgTenureBytesDeviation);
}
scavengerGCStats->_avgTenureLOABytes = (uintptr_t)MM_Math::weightedAverage((float)scavengerGCStats->_avgTenureLOABytes,
(float)scavengerGCStats->_tenureLOABytes,
TENURE_BYTES_HISTORY_WEIGHT);
Expand Down
4 changes: 4 additions & 0 deletions gc/stats/ScavengerStats.cpp
Expand Up @@ -67,11 +67,15 @@ MM_ScavengerStats::MM_ScavengerStats()
#endif /* J9MODRON_TGC_PARALLEL_STATISTICS */
,_avgInitialFree(0)
,_avgTenureBytes(0)
,_avgTenureBytesDeviation(0)
,_tenureBytesDeviation((float)0)
,_tiltRatio(0)
,_nextScavengeWillPercolate(false)
#if defined(OMR_GC_LARGE_OBJECT_AREA)
,_avgTenureLOABytes(0)
,_avgTenureSOABytes(0)
,_avgTenureSOABytesDeviation(0)
,_tenureSOABytesDeviation((float)0)
#endif /* OMR_GC_LARGE_OBJECT_AREA */
,_flipDiscardBytes(0)
,_tenureDiscardBytes(0)
Expand Down
2 changes: 2 additions & 0 deletions gc/stats/ScavengerStats.hpp
Expand Up @@ -103,6 +103,8 @@ class MM_ScavengerStats
*/
uintptr_t _avgInitialFree;
uintptr_t _avgTenureBytes;
uintptr_t _avgTenureBytesDeviation; /**< The average, weighted deviation of the tenureBytes*/
float _tenureBytesDeviation; /**< The amount by which the previous tenureBytes deviated from _avgTenureBytes */

uintptr_t _tiltRatio; /**< use to pass tiltRatio to verbose */

Expand Down

0 comments on commit 364483f

Please sign in to comment.