Skip to content

Commit

Permalink
Merge pull request #4134 from cedrichansen/soaDeviation
Browse files Browse the repository at this point in the history
Adding Tenure bytes deviation to modify concurrent kickoff
  • Loading branch information
charliegracie committed Jul 25, 2019
2 parents cafb366 + aec40ce commit c4a5982
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 16 deletions.
2 changes: 2 additions & 0 deletions gc/base/GCExtensionsBase.hpp
Original file line number Diff line number Diff line change
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
9 changes: 9 additions & 0 deletions gc/base/Math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@ class MM_Math

return number;
}

/**< return absolute value of a float */
static MMINLINE float abs(float number) {
if (number < 0) {
number = -number;
}
return number;
}

};

#endif /*MATH_HPP_*/
7 changes: 4 additions & 3 deletions gc/base/standard/ConcurrentGC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1828,20 +1828,21 @@ MM_ConcurrentGC::potentialFreeSpace(MM_EnvironmentBase *env, MM_AllocateDescript
if (!scavengerStats->isAvailable(env)) {
return (uintptr_t)-1;
}

nurseryPromotion = scavengerStats->_avgTenureBytes == 0 ? 1: (uintptr_t)(scavengerStats->_avgTenureBytes + (env->getExtensions()->tenureBytesDeviationBoost * scavengerStats->_avgTenureBytesDeviation));

#if defined(OMR_GC_LARGE_OBJECT_AREA)
/* Do we need to tax this allocation ? */
if (LOA == _meteringType) {
nurseryPromotion = scavengerStats->_avgTenureLOABytes == 0 ? 1 : scavengerStats->_avgTenureLOABytes;
currentOldFree = oldSubspace->getApproximateActiveFreeLOAMemorySize();
headRoom = (uintptr_t)(_extensions->concurrentKickoffTenuringHeadroom * _extensions->lastGlobalGCFreeBytesLOA);
} else {
assume0(SOA == _meteringType);
nurseryPromotion = scavengerStats->_avgTenureSOABytes == 0 ? 1 : scavengerStats->_avgTenureSOABytes;
assume0(SOA == _meteringType);
currentOldFree = oldSubspace->getApproximateActiveFreeMemorySize() - oldSubspace->getApproximateActiveFreeLOAMemorySize();
headRoom = (uintptr_t)(_extensions->concurrentKickoffTenuringHeadroom * (_extensions->getLastGlobalGCFreeBytes() - _extensions->lastGlobalGCFreeBytesLOA));
}
#else
nurseryPromotion = scavengerStats->_avgTenureBytes == 0 ? 1: scavengerStats->_avgTenureBytes;
currentOldFree = oldSubspace->getApproximateActiveFreeMemorySize();
headRoom = (uintptr_t)(_extensions->concurrentKickoffTenuringHeadroom * _extensions->getLastGlobalGCFreeBytes());
#endif
Expand Down
38 changes: 27 additions & 11 deletions gc/base/standard/Scavenger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
#include "ut_omrmm.h"

#define INITIAL_FREE_HISTORY_WEIGHT ((float)0.8)
#define TENURE_BYTES_HISTORY_WEIGHT ((float)0.8)
#define TENURE_BYTES_HISTORY_WEIGHT ((float)0.9)

#define FLIP_TENURE_LARGE_SCAN 4
#define FLIP_TENURE_LARGE_SCAN_DEFERRED 5
Expand Down Expand Up @@ -827,28 +827,44 @@ MM_Scavenger::calcGCStats(MM_EnvironmentStandard *env)
MM_ScavengerStats *scavengerGCStats;
scavengerGCStats = &_extensions->scavengerStats;
uintptr_t initialFree = env->_cycleState->_activeSubSpace->getActualActiveFreeMemorySize();
uintptr_t tenureAggregateBytes = 0;
float tenureBytesDeviation = 0;

/* First collection ? */
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);

#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);
tenureAggregateBytes = scavengerGCStats->_tenureAggregateBytes - scavengerGCStats->_tenureLOABytes;
scavengerGCStats->_avgTenureLOABytes = (uintptr_t)MM_Math::weightedAverage((float)scavengerGCStats->_avgTenureLOABytes,
(float)scavengerGCStats->_tenureLOABytes,
TENURE_BYTES_HISTORY_WEIGHT);

#else /* OMR_GC_LARGE_OBJECT_AREA */
tenureAggregateBytes = scavengerGCStats->_tenureAggregateBytes;
#endif /* OMR_GC_LARGE_OBJECT_AREA */
scavengerGCStats->_avgTenureBytes = (uintptr_t)MM_Math::weightedAverage((float)scavengerGCStats->_avgTenureBytes,
(float)tenureAggregateBytes,
TENURE_BYTES_HISTORY_WEIGHT);
tenureBytesDeviation = (float)tenureAggregateBytes - scavengerGCStats->_avgTenureBytes;
scavengerGCStats->_avgTenureBytesDeviation = (uintptr_t)MM_Math::weightedAverage((float)scavengerGCStats->_avgTenureBytesDeviation,
MM_Math::abs(tenureBytesDeviation),
TENURE_BYTES_HISTORY_WEIGHT);
} else {
scavengerGCStats->_avgInitialFree = initialFree;
scavengerGCStats->_avgTenureBytes = scavengerGCStats->_tenureAggregateBytes;
#if defined(OMR_GC_LARGE_OBJECT_AREA)
scavengerGCStats->_avgTenureSOABytes = scavengerGCStats->_tenureAggregateBytes - scavengerGCStats->_tenureLOABytes;
scavengerGCStats->_avgTenureLOABytes = scavengerGCStats->_tenureLOABytes;
#endif /* OMR_GC_LARGE_OBJECT_AREA */

/* We can assume that in the first GC, about half of the objects are long lived objects, so we use this heuristic to give a rough estimate for the starting point */
scavengerGCStats->_avgTenureBytes = (uintptr_t)(scavengerGCStats->_flipBytes / 2);
}
#if defined(OMR_GC_MODRON_CONCURRENT_MARK)
if (_extensions->debugConcurrentMark) {
OMRPORT_ACCESS_FROM_OMRPORT(env->getPortLibrary());
omrtty_printf("Tenured bytes: %zu\navgTenureBytes: %zu\ntenureBytesDeviation: %f\navgTenureBytesDeviation: %zu\n",
tenureAggregateBytes,
scavengerGCStats->_avgTenureBytes,
tenureBytesDeviation,
scavengerGCStats->_avgTenureBytesDeviation);
}
#endif /* OMR_GC_MODRON_CONCURRENT_MARK */
}
}

Expand Down
2 changes: 1 addition & 1 deletion gc/stats/ScavengerStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ MM_ScavengerStats::MM_ScavengerStats()
#endif /* J9MODRON_TGC_PARALLEL_STATISTICS */
,_avgInitialFree(0)
,_avgTenureBytes(0)
,_avgTenureBytesDeviation(0)
,_tiltRatio(0)
,_nextScavengeWillPercolate(false)
#if defined(OMR_GC_LARGE_OBJECT_AREA)
,_avgTenureLOABytes(0)
,_avgTenureSOABytes(0)
#endif /* OMR_GC_LARGE_OBJECT_AREA */
,_flipDiscardBytes(0)
,_tenureDiscardBytes(0)
Expand Down
2 changes: 1 addition & 1 deletion gc/stats/ScavengerStats.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ class MM_ScavengerStats
*/
uintptr_t _avgInitialFree;
uintptr_t _avgTenureBytes;
uintptr_t _avgTenureBytesDeviation; /**< The average, weighted deviation of the tenureBytes*/

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

bool _nextScavengeWillPercolate;

#if defined(OMR_GC_LARGE_OBJECT_AREA)
uintptr_t _avgTenureLOABytes;
uintptr_t _avgTenureSOABytes;
#endif /* OMR_GC_LARGE_OBJECT_AREA */

uintptr_t _flipDiscardBytes; /**< Bytes of survivor discarded by copy scan cache */
Expand Down

0 comments on commit c4a5982

Please sign in to comment.