< prev index next >

src/share/vm/gc_implementation/shenandoah/shenandoahUtils.cpp

Print this page
rev 10498 : [backport] Move heuristics from ShCollectorPolicy to ShHeap
rev 10546 : [backport] Wrap worker id in thread local worker session
rev 10612 : [backport] Wiring GC events to JFR + Restore heap occupancy in GC logs after JFR changes
rev 10615 : [backport] Wiring heap and metaspace info to JFR

@@ -25,20 +25,30 @@
 
 #include "gc_implementation/shenandoah/shenandoahAllocTracker.hpp"
 #include "gc_implementation/shenandoah/shenandoahCollectorPolicy.hpp"
 #include "gc_implementation/shenandoah/shenandoahMarkCompact.hpp"
 #include "gc_implementation/shenandoah/shenandoahHeap.hpp"
+#include "gc_implementation/shenandoah/shenandoahHeuristics.hpp"
 #include "gc_implementation/shenandoah/shenandoahUtils.hpp"
 #include "gc_implementation/shenandoah/shenandoahLogging.hpp"
+#include "gc_interface/gcCause.hpp"
 #include "gc_implementation/shared/gcTimer.hpp"
+#include "gc_implementation/shared/gcWhen.hpp"
+#include "gc_implementation/shared/gcTrace.hpp"
 
 
-ShenandoahGCSession::ShenandoahGCSession() {
+ShenandoahGCSession::ShenandoahGCSession(GCCause::Cause cause) :
+  _timer(ShenandoahHeap::heap()->gc_timer()),
+  _tracer(ShenandoahHeap::heap()->tracer()) {
   ShenandoahHeap* sh = ShenandoahHeap::heap();
-  _timer = sh->gc_timer();
+
   _timer->register_gc_start();
+  _tracer->report_gc_start(cause, _timer->gc_start());
+  sh->trace_heap(GCWhen::BeforeGC, _tracer);
+
   sh->shenandoahPolicy()->record_cycle_start();
+  sh->heuristics()->record_cycle_start();
   _trace_cycle.initialize(false, sh->gc_cause(),
           /* recordGCBeginTime = */       true,
           /* recordPreGCUsage = */        true,
           /* recordPeakUsage = */         true,
           /* recordPostGCUsage = */       true,

@@ -47,33 +57,39 @@
           /* countCollection = */         true
   );
 }
 
 ShenandoahGCSession::~ShenandoahGCSession() {
-  ShenandoahHeap::heap()->shenandoahPolicy()->record_cycle_end();
+  ShenandoahHeap::heap()->heuristics()->record_cycle_end();
+  _tracer->report_gc_end(_timer->gc_end(), _timer->time_partitions());
   _timer->register_gc_end();
 }
 
 ShenandoahGCPauseMark::ShenandoahGCPauseMark(SvcGCMarker::reason_type type) :
         _svc_gc_mark(type), _is_gc_active_mark() {
   ShenandoahHeap* sh = ShenandoahHeap::heap();
-  sh->shenandoahPolicy()->record_gc_start();
 
+  // FIXME: It seems that JMC throws away level 0 events, which are the Shenandoah
+  // pause events. Create this pseudo level 0 event to push real events to level 1.
+  sh->gc_timer()->register_gc_phase_start("Shenandoah", Ticks::now());
   _trace_pause.initialize(true, sh->gc_cause(),
           /* recordGCBeginTime = */       true,
           /* recordPreGCUsage = */        false,
           /* recordPeakUsage = */         false,
           /* recordPostGCUsage = */       false,
           /* recordAccumulatedGCTime = */ true,
           /* recordGCEndTime = */         true,
           /* countCollection = */         true
   );
+
+  sh->heuristics()->record_gc_start();
 }
 
 ShenandoahGCPauseMark::~ShenandoahGCPauseMark() {
   ShenandoahHeap* sh = ShenandoahHeap::heap();
-  sh->shenandoahPolicy()->record_gc_end();
+  sh->gc_timer()->register_gc_phase_end(Ticks::now());
+  sh->heuristics()->record_gc_end();
 }
 
 ShenandoahGCPhase::ShenandoahGCPhase(const ShenandoahPhaseTimings::Phase phase) :
   _phase(phase) {
   ShenandoahHeap::heap()->phase_timings()->record_phase_start(_phase);

@@ -107,5 +123,20 @@
       log_warning(gc)("Allocation stall: %.0f us (threshold: " INTX_FORMAT " us)",
                       duration_us, ShenandoahAllocationStallThreshold);
     }
   }
 }
+
+ShenandoahWorkerSession::ShenandoahWorkerSession(uint worker_id) {
+  Thread* thr = Thread::current();
+  assert(thr->worker_id() == INVALID_WORKER_ID, "Already set");
+  thr->set_worker_id(worker_id);
+}
+
+ShenandoahWorkerSession::~ShenandoahWorkerSession() {
+#ifdef ASSERT
+  Thread* thr = Thread::current();
+  assert(thr->worker_id() != INVALID_WORKER_ID, "Must be set");
+  thr->set_worker_id(INVALID_WORKER_ID);
+#endif
+}
+
< prev index next >