Skip to content

Commit 8de6c46

Browse files
authored
Merge pull request #22211 from adpopescu/jfr-gc-pauses
Add GC pause info for use in JFR
2 parents 06bd7c7 + ee9ed66 commit 8de6c46

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

runtime/gc_realtime/RealtimeGC.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ MM_RealtimeGC::internalPreCollect(MM_EnvironmentBase *env, MM_MemorySubSpace *su
361361
env->_cycleState->_gcCode = MM_GCCode(gcCode);
362362
env->_cycleState->_type = _cycleType;
363363
env->_cycleState->_activeSubSpace = subSpace;
364+
env->_cycleState->_collectionStatistics = &_collectionStatistics;
364365

365366
/* If we are in an excessiveGC level beyond normal then an aggressive GC is
366367
* conducted to free up as much space as possible
@@ -387,6 +388,7 @@ MM_RealtimeGC::internalPreCollect(MM_EnvironmentBase *env, MM_MemorySubSpace *su
387388
}
388389
/* we are about to collect so generate the appropriate cycle start and increment start events */
389390
reportGCCycleStart(rtEnv);
391+
reportGCIncrementStart(rtEnv);
390392
_sched->reportStartGCIncrement(rtEnv);
391393
}
392394

@@ -447,6 +449,7 @@ MM_RealtimeGC::internalPostCollect(MM_EnvironmentBase *env, MM_MemorySubSpace *s
447449
* the METRONOME_INCREMENT_START/END events become out of order and verbose GC will fail.
448450
*/
449451
reportGCCycleFinalIncrementEnding(env);
452+
reportGCIncrementEnd(env);
450453

451454
MM_EnvironmentRealtime *rtEnv = MM_EnvironmentRealtime::getEnvironment(env);
452455
_sched->reportStopGCIncrement(rtEnv, true);
@@ -613,6 +616,24 @@ MM_RealtimeGC::reportGCCycleEnd(MM_EnvironmentBase *env)
613616
omrthread_monitor_exit(env->getOmrVM()->_gcCycleOnMonitor);
614617
}
615618

619+
void
620+
MM_RealtimeGC::reportGCIncrementStart(MM_EnvironmentBase *env)
621+
{
622+
PORT_ACCESS_FROM_ENVIRONMENT(env);
623+
MM_CollectionStatistics *stats = (MM_CollectionStatistics *)env->_cycleState->_collectionStatistics;
624+
stats->_startTime = j9time_hires_clock();
625+
}
626+
627+
void
628+
MM_RealtimeGC::reportGCIncrementEnd(MM_EnvironmentBase *env)
629+
{
630+
PORT_ACCESS_FROM_ENVIRONMENT(env);
631+
MM_CollectionStatistics *stats = (MM_CollectionStatistics *)env->_cycleState->_collectionStatistics;
632+
633+
stats->_endTime = j9time_hires_clock();
634+
stats->processPauseDuration();
635+
}
636+
616637
/**
617638
* @todo Provide method documentation
618639
* @ingroup GC_Metronome methodGroup

runtime/gc_realtime/RealtimeGC.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "OMRVMInterface.hpp"
4141
#include "Scheduler.hpp"
4242
#include "WorkPacketsRealtime.hpp"
43+
#include "CollectionStatistics.hpp"
4344

4445
class MM_ParallelDispatcher;
4546
class MM_EnvironmentBase;
@@ -69,6 +70,7 @@ class MM_RealtimeGC : public MM_GlobalCollector
6970
uintptr_t _gcPhase; /**< What gc phase are we currently in? */
7071

7172
MM_CycleState _cycleState; /**< Embedded cycle state to be used as the main cycle state for GC activity */
73+
MM_CollectionStatistics _collectionStatistics; /** Common collect stats (memory, time etc.) */
7274

7375
bool _moreTracingRequired; /**< Is used to decide if there needs to be another pass of the tracing loop. */
7476

@@ -105,6 +107,8 @@ class MM_RealtimeGC : public MM_GlobalCollector
105107
void reportSweepEnd(MM_EnvironmentBase *env);
106108
void reportGCStart(MM_EnvironmentBase *env);
107109
void reportGCEnd(MM_EnvironmentBase *env);
110+
void reportGCIncrementStart(MM_EnvironmentBase *env);
111+
void reportGCIncrementEnd(MM_EnvironmentBase *env);
108112

109113
public:
110114
void mainSetupForGC(MM_EnvironmentBase *env);

runtime/gc_vlhgc/IncrementalGenerationalGC.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,6 +2140,8 @@ void
21402140
MM_IncrementalGenerationalGC::reportGCCycleStart(MM_EnvironmentBase *env)
21412141
{
21422142
PORT_ACCESS_FROM_ENVIRONMENT(env);
2143+
MM_CollectionStatisticsVLHGC *stats = (MM_CollectionStatisticsVLHGC *)env->_cycleState->_collectionStatistics;
2144+
stats->clearPauseStats();
21432145
MM_GCExtensions* extensions = MM_GCExtensions::getExtensions(env);
21442146
MM_CommonGCData commonData;
21452147

@@ -2363,6 +2365,7 @@ MM_IncrementalGenerationalGC::reportGCIncrementEnd(MM_EnvironmentBase *env)
23632365
}
23642366

23652367
stats->_endTime = j9time_hires_clock();
2368+
stats->processPauseDuration();
23662369
stats->_stallTime = static_cast<MM_CycleStateVLHGC*>(env->_cycleState)->_vlhgcIncrementStats.getTotalStallTime();
23672370

23682371
TRIGGER_J9HOOK_MM_PRIVATE_GC_INCREMENT_END(

0 commit comments

Comments
 (0)