Skip to content

Commit

Permalink
relocate calculating the rates at the end of First PGC After GMP
Browse files Browse the repository at this point in the history
 - recalculating PGCCompactionRate, HeapOccupancyTrend,
  ScannableBytesRatio after PGC and before estimating
  defragmentReclaimableRegions for calculating GMPIntermission 
  and desiredCompactWork accurate.

Signed-off-by: Lin Hu <linhu@ca.ibm.com>
  • Loading branch information
LinHu2016 committed Feb 14, 2018
1 parent a66a2eb commit aaa4b22
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 11 deletions.
11 changes: 5 additions & 6 deletions runtime/gc_vlhgc/IncrementalGenerationalGC.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

/*******************************************************************************
* Copyright (c) 1991, 2017 IBM Corp. and others
* Copyright (c) 1991, 2018 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 @@ -1228,11 +1228,6 @@ MM_IncrementalGenerationalGC::partialGarbageCollect(MM_EnvironmentVLHGC *env, MM

double optimalEmptinessRegionThreshold = _reclaimDelegate.calculateOptimalEmptinessRegionThreshold(env, regionConsumptionRate, avgSurvivorRegions, avgCopyForwardRate, scanTimeCostPerGMP);
_schedulingDelegate.setAutomaticDefragmentEmptinessThreshold(optimalEmptinessRegionThreshold);

/* recalculate ratios due to sweep */
_schedulingDelegate.calculatePGCCompactionRate(env, _schedulingDelegate.getCurrentEdenSizeInRegions(env) * _regionManager->getRegionSize());
_schedulingDelegate.calculateHeapOccupancyTrend(env);
_schedulingDelegate.calculateScannableBytesRatio(env);
}

if (env->_cycleState->_shouldRunCopyForward) {
Expand Down Expand Up @@ -1373,6 +1368,8 @@ MM_IncrementalGenerationalGC::partialGarbageCollectUsingCopyForward(MM_Environme
_reclaimDelegate.performAtomicSweep(env, allocDescription, env->_cycleState->_activeSubSpace, env->_cycleState->_gcCode);
}

_schedulingDelegate.recalculateRatesOnFirstPGCAfterGMP(env);

/* Need to understand how to do the estimates here found within the following two calls */
UDATA defragmentReclaimableRegions = 0;
UDATA reclaimableRegions = 0;
Expand Down Expand Up @@ -1445,6 +1442,8 @@ MM_IncrementalGenerationalGC::partialGarbageCollectUsingMarkCompact(MM_Environme
Trc_MM_ReclaimDelegate_runReclaimComplete_Exit(env->getLanguageVMThread(), 0);
}

_schedulingDelegate.recalculateRatesOnFirstPGCAfterGMP(env);

UDATA defragmentReclaimableRegions = 0;
UDATA reclaimableRegions = 0;
_reclaimDelegate.estimateReclaimableRegions(env, 0.0 /* copy-forward loss */, &reclaimableRegions, &defragmentReclaimableRegions);
Expand Down
19 changes: 15 additions & 4 deletions runtime/gc_vlhgc/SchedulingDelegate.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2017 IBM Corp. and others
* Copyright (c) 1991, 2018 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 @@ -284,10 +284,11 @@ MM_SchedulingDelegate::partialGarbageCollectCompleted(MM_EnvironmentVLHGC *env,
/* measure scan rate in PGC, only if we did M/S/C collect */
measureScanRate(env, measureScanRateHistoricWeightForPGC);
}

measureConsumptionForPartialGC(env, reclaimableRegions, defragmentReclaimableRegions);
calculateAutomaticGMPIntermission(env);
calculateEdenSize(env);

estimateMacroDefragmentationWork(env);

/* Calculate the time spent in the current Partial GC */
Expand Down Expand Up @@ -669,6 +670,18 @@ MM_SchedulingDelegate::calculateScannableBytesRatio(MM_EnvironmentVLHGC *env)
}
}

void
MM_SchedulingDelegate::recalculateRatesOnFirstPGCAfterGMP(MM_EnvironmentVLHGC *env)
{
if (isFirstPGCAfterGMP()) {
calculatePGCCompactionRate(env, getCurrentEdenSizeInRegions(env) * _regionManager->getRegionSize());
calculateHeapOccupancyTrend(env);
calculateScannableBytesRatio(env);

firstPGCAfterGMPCompleted();
}
}

double
MM_SchedulingDelegate::getAverageEmptinessOfCopyForwardedRegions()
{
Expand Down Expand Up @@ -778,7 +791,6 @@ MM_SchedulingDelegate::getDesiredCompactWork()
return desiredCompactWork;
}

/*
bool
MM_SchedulingDelegate::isFirstPGCAfterGMP()
{
Expand All @@ -790,7 +802,6 @@ MM_SchedulingDelegate::firstPGCAfterGMPCompleted()
{
_didGMPCompleteSinceLastReclaim = false;
}
*/

void
MM_SchedulingDelegate::copyForwardCompleted(MM_EnvironmentVLHGC *env)
Expand Down
19 changes: 18 additions & 1 deletion runtime/gc_vlhgc/SchedulingDelegate.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2017 IBM Corp. and others
* Copyright (c) 1991, 2018 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 @@ -331,13 +331,30 @@ class MM_SchedulingDelegate : public MM_BaseNonVirtual
*/
void calculateHeapOccupancyTrend(MM_EnvironmentVLHGC *env);

/**
* recalculate PGCCompactionRate, HeapOccupancyTrend, ScannableBytesRatio at the end of First PGC After GMP
* it should be called before estimating defragmentReclaimableRegions in order to calculate GMPIntermission more accurate.
* TODO: might need to recalculate desiredCompactWork for sliding Compact of PGC (MacroDefragment part, right now it is calculated at the end of TaxationEntryPoint,
* but we need to decide sliding compaction before Copyforward PGC).
*/
void recalculateRatesOnFirstPGCAfterGMP(MM_EnvironmentVLHGC *env);

/**
* Calculate desired amount of work to be compacted this PGC cycle
* @param env[in] the master GC thread
* @return desired bytes to be compacted
*/
UDATA getDesiredCompactWork();

/**
* @return true if it is first PGC after GMP completed (so we can calculate compact-bytes/free-bytes ratio, etc.)
*/
bool isFirstPGCAfterGMP();
/**
* clear the flag that indicate this was the first PGC after GMP completed
*/
void firstPGCAfterGMPCompleted();

/**
* return whether the following PGC is required to do global sweep (typically, first PGC after GMP completed)
*/
Expand Down

0 comments on commit aaa4b22

Please sign in to comment.