Skip to content

Commit

Permalink
Adjust cardCleaningThreshold for language specific kickoff
Browse files Browse the repository at this point in the history
When transitioning from tracing only state to tracing and card cleaning
state, account that pre-calculated remaining free memory for card
cleaning kickoff threshold should be higher if global kickoff was due to
reasons other than low free memory such a language specific kickoff
(class unloading).

The adjustment for card cleaning kickoff threshold is exactly the same
as the difference between actual free memory at the time of global
kickoff and expected free memory global kickoff threshold.

Without the adjustment, card cleaning and any other states after (most
importantly final STW phase where we reclaim memory) are delayed till
(incorrectly very low) pre-calculated card cleaning threshold is met,
effectively negating any efforts of the early language specific kickoff.

Signed-off-by: Aleksandar Micic <amicic@ca.ibm.com>
  • Loading branch information
amicic committed Mar 17, 2021
1 parent a7e83c7 commit 2394198
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions gc/base/standard/ConcurrentGC.cpp
Expand Up @@ -2297,7 +2297,9 @@ MM_ConcurrentGC::timeToKickoffConcurrent(MM_EnvironmentBase *env, MM_AllocateDes
_stats.setRemainingFree(remainingFree);
/* Set kickoff reason if it is not set yet */
_stats.setKickoffReason(KICKOFF_THRESHOLD_REACHED);
_languageKickoffReason = NO_LANGUAGE_KICKOFF_REASON;
if (LANGUAGE_DEFINED_REASON != _stats.getKickoffReason()) {
_languageKickoffReason = NO_LANGUAGE_KICKOFF_REASON;
}
#if defined(OMR_GC_MODRON_SCAVENGER)
_extensions->setConcurrentGlobalGCInProgress(true);
#endif
Expand Down Expand Up @@ -2528,8 +2530,22 @@ MM_ConcurrentGC::doConcurrentTrace(MM_EnvironmentBase *env,
_markingScheme->getWorkPackets()->reuseDeferredPackets(env);
}

/* Switch state if card cleaning stage 1 threshold reached */
if( (CONCURRENT_TRACE_ONLY == _stats.getExecutionMode()) && (remainingFree < _stats.getCardCleaningThreshold())) {
/* Switch state if card cleaning stage 1 threshold reached
* Typically kickoff would be triggered by remainingFree < kickoffThreshold (low heap/tenure occupancy).
* However, with some other kickoff criteria (for example, language specific, like class unloading) that could be
* much sooner, so that remainingFree is significantly higher than pre-calculated kickoffThreshold.
* Since CardCleaningThreshold was also pre-calculated, irrespective of actual remainingFree at the moment of kickoff
* (during tuneToHeap that occurred at the end of last global GC), it needs to be adjusted by
* the difference between actual remainingFree at the time of global kickoff and global kickoff threshold.
*/
uintptr_t relativeCardCleaningThreshold = _stats.getCardCleaningThreshold();
uintptr_t absoluteCardCleaningThreshold = relativeCardCleaningThreshold;

if (_stats.getRemainingFree() >= _stats.getKickoffThreshold()) {
absoluteCardCleaningThreshold += (_stats.getRemainingFree() - _stats.getKickoffThreshold());
}

if( (CONCURRENT_TRACE_ONLY == _stats.getExecutionMode()) && (remainingFree < absoluteCardCleaningThreshold)) {
kickoffCardCleaning(env, CARD_CLEANING_THRESHOLD_REACHED);
}

Expand Down

0 comments on commit 2394198

Please sign in to comment.