changeset 7467:b581d6e6b640 default tip

Improve counting of full GCs.
author Roman Kennke <rkennke@redhat.com>
date Fri, 13 Feb 2015 12:25:04 +0100
parents 8a704517c74e
children
files src/share/vm/gc_implementation/shenandoah/shenandoahCollectorPolicy.cpp src/share/vm/gc_implementation/shenandoah/shenandoahCollectorPolicy.hpp src/share/vm/gc_implementation/shenandoah/shenandoahConcurrentThread.cpp src/share/vm/gc_implementation/shenandoah/shenandoahConcurrentThread.hpp src/share/vm/gc_implementation/shenandoah/shenandoahHeap.cpp
diffstat 5 files changed, 20 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/gc_implementation/shenandoah/shenandoahCollectorPolicy.cpp	Thu Feb 12 21:42:09 2015 +0100
+++ b/src/share/vm/gc_implementation/shenandoah/shenandoahCollectorPolicy.cpp	Fri Feb 13 12:25:04 2015 +0100
@@ -366,6 +366,7 @@
   initialize_all();
 
   _user_requested_gcs = 0;
+  _allocation_failure_gcs = 0;
 
   _phase_names[init_mark] = "InitMark";
   _phase_names[final_mark] = "FinalMark";
@@ -480,6 +481,10 @@
   _user_requested_gcs++;
 }
 
+void ShenandoahCollectorPolicy::record_allocation_failure_gc() {
+  _allocation_failure_gcs++;
+}
+
 bool ShenandoahCollectorPolicy::should_start_concurrent_mark(size_t used,
 							     size_t capacity) {
   ShenandoahHeap* heap = ShenandoahHeap::heap();
@@ -521,6 +526,7 @@
   print_summary_sd("Full GC Times", 0, &(_timing_data[full_gc]._ms));
 
   gclog_or_tty->print_cr("User requested GCs: "SIZE_FORMAT, _user_requested_gcs);
+  gclog_or_tty->print_cr("Allocation failure GCs: "SIZE_FORMAT, _allocation_failure_gcs);
 
   gclog_or_tty->print_cr(" ");
   double total_sum = _timing_data[init_mark]._ms.sum() +
--- a/src/share/vm/gc_implementation/shenandoah/shenandoahCollectorPolicy.hpp	Thu Feb 12 21:42:09 2015 +0100
+++ b/src/share/vm/gc_implementation/shenandoah/shenandoahCollectorPolicy.hpp	Fri Feb 13 12:25:04 2015 +0100
@@ -52,6 +52,7 @@
   const char* _phase_names[_num_phases];
 
   size_t _user_requested_gcs;
+  size_t _allocation_failure_gcs;
 
   ShenandoahHeap* _pgc;
   ShenandoahHeuristics* _heuristics;
@@ -81,6 +82,7 @@
   void record_phase_end(TimingPhase phase);
 
   void record_user_requested_gc();
+  void record_allocation_failure_gc();
 
   void record_bytes_allocated(size_t bytes);
   void record_bytes_reclaimed(size_t bytes);
--- a/src/share/vm/gc_implementation/shenandoah/shenandoahConcurrentThread.cpp	Thu Feb 12 21:42:09 2015 +0100
+++ b/src/share/vm/gc_implementation/shenandoah/shenandoahConcurrentThread.cpp	Fri Feb 13 12:25:04 2015 +0100
@@ -84,6 +84,11 @@
     if (_do_full_gc) {
       {
         MonitorLockerEx ml(ShenandoahJNICritical_lock, true);
+        if (_full_gc_cause == GCCause::_allocation_failure) {
+          heap->shenandoahPolicy()->record_allocation_failure_gc();
+        } else {
+          heap->shenandoahPolicy()->record_user_requested_gc();
+        }
         VM_ShenandoahFullGC full_gc;
         VMThread::execute(&full_gc);
         while (_waiting_for_jni_critical) {
@@ -153,12 +158,13 @@
   }
 }
 
-void ShenandoahConcurrentThread::do_full_gc() {
+void ShenandoahConcurrentThread::do_full_gc(GCCause::Cause cause) {
 
   assert(Thread::current()->is_Java_thread(), "expect Java thread here");
 
   MonitorLockerEx ml(ShenandoahFullGC_lock);
   _do_full_gc = true;
+  _full_gc_cause = cause;
   while (_do_full_gc) {
     ml.wait();
   }
--- a/src/share/vm/gc_implementation/shenandoah/shenandoahConcurrentThread.hpp	Thu Feb 12 21:42:09 2015 +0100
+++ b/src/share/vm/gc_implementation/shenandoah/shenandoahConcurrentThread.hpp	Fri Feb 13 12:25:04 2015 +0100
@@ -5,6 +5,7 @@
 #define SHARE_VM_GC_IMPLEMENTATION_SHENANDOAH_SHENANDOAHCONCURRENTTHREAD_HPP
 
 #include "gc_implementation/shared/concurrentGCThread.hpp"
+#include "gc_interface/gcCause.hpp"
 #include "memory/resourceArea.hpp"
 
 // For now we just want to have a concurrent marking thread. 
@@ -29,6 +30,7 @@
   static SuspendibleThreadSet _sts;
 
   bool _do_full_gc;
+  GCCause::Cause _full_gc_cause;
 
   void sleepBeforeNextCycle();
 
@@ -56,7 +58,7 @@
   bool cm_has_aborted() { return _concurrent_mark_aborted;}
   void clear_cm_aborted() { _concurrent_mark_aborted = false;}
 
-  void do_full_gc();
+  void do_full_gc(GCCause::Cause cause);
 
   void schedule_full_gc();
 
--- a/src/share/vm/gc_implementation/shenandoah/shenandoahHeap.cpp	Thu Feb 12 21:42:09 2015 +0100
+++ b/src/share/vm/gc_implementation/shenandoah/shenandoahHeap.cpp	Fri Feb 13 12:25:04 2015 +0100
@@ -1554,8 +1554,7 @@
       if (ShenandoahTraceFullGC) {
         gclog_or_tty->print_cr("Shenandoah-full-gc: requested full GC");
       }
-      shenandoahPolicy()->record_user_requested_gc();
-      _concurrent_gc_thread->do_full_gc();
+      _concurrent_gc_thread->do_full_gc(cause);
     }
   } else if (cause == GCCause::_allocation_failure) {
 
@@ -1563,7 +1562,7 @@
       gclog_or_tty->print_cr("Shenandoah-full-gc: full GC for allocation failure");
     }
     collector_policy()->set_should_clear_all_soft_refs(true);
-      _concurrent_gc_thread->do_full_gc();
+      _concurrent_gc_thread->do_full_gc(cause);
 
   } else if (cause == GCCause::_gc_locker) {