Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Tenure bytes deviation to modify concurrent kickoff #4134

Merged
merged 1 commit into from Jul 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
9 changes: 9 additions & 0 deletions gc/base/Math.hpp
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
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
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a comment here, something like (shorten and change it to your liking): Since initial tenureage is >=1, on first scavenge we don't have any tenuring. However, on the second Scavenge, there could be a large amount of tenuring, leading to unreasonable large deviation. Let's assume about half of those flipped now, will be tenured next cycle - this should lead to more realistic averages and deviations in next few cycles.

}
#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
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
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