changeset 4346:f842ea9b8830

8008737: The trace event vm/gc/heap/summary is missing for CMS Reviewed-by: mgerdin, brutisso
author ehelin
date Wed, 03 Apr 2013 17:49:23 +0200
parents c0b1bfa39232
children abeffed9e41a
files src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp src/share/vm/gc_implementation/shared/gcHeapSummary.hpp
diffstat 4 files changed, 34 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Tue Mar 26 12:55:26 2013 -0700
+++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Wed Apr 03 17:49:23 2013 +0200
@@ -2359,6 +2359,7 @@
           CMSTokenSync        z(true);   // not strictly needed.
           if (_collectorState == Resizing) {
             compute_new_size();
+            save_heap_summary();
             _collectorState = Resetting;
           } else {
             assert(_collectorState == Idling, "The state should only change"
@@ -2418,16 +2419,31 @@
   _cms_start_registered = true;
   _gc_timer_cm->register_gc_start(os::elapsed_counter());
   _gc_tracer_cm->report_gc_start(cause, _gc_timer_cm->gc_start());
+
+  save_heap_summary();
+  report_heap_summary(GCWhen::BeforeGC);
 }
 
 void CMSCollector::register_gc_end() {
   if (_cms_start_registered) {
+    report_heap_summary(GCWhen::AfterGC);
+
     _gc_timer_cm->register_gc_end(os::elapsed_counter());
     _gc_tracer_cm->report_gc_end(_gc_timer_cm->gc_end(), _gc_timer_cm->time_partitions());
     _cms_start_registered = false;
   }
 }
 
+void CMSCollector::save_heap_summary() {
+  GenCollectedHeap* gch = GenCollectedHeap::heap();
+  _last_heap_summary = gch->create_heap_summary();
+  _last_perm_gen_summary = gch->create_perm_gen_summary();
+}
+
+void CMSCollector::report_heap_summary(GCWhen::Type when) {
+  _gc_tracer_cm->report_gc_heap_summary(when, _last_heap_summary, _last_perm_gen_summary);
+}
+
 void CMSCollector::collect_in_foreground(bool clear_all_soft_refs) {
   assert(_foregroundGCIsActive && !_foregroundGCShouldWait,
          "Foreground collector should be waiting, not executing");
@@ -2514,6 +2530,7 @@
           gclog_or_tty->print("Verify before reset: ");
           Universe::verify();
         }
+        save_heap_summary();
         reset(false);
         assert(_collectorState == Idling, "Collector state should "
           "have changed");
--- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp	Tue Mar 26 12:55:26 2013 -0700
+++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp	Wed Apr 03 17:49:23 2013 +0200
@@ -25,8 +25,10 @@
 #ifndef SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CONCURRENTMARKSWEEPGENERATION_HPP
 #define SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CONCURRENTMARKSWEEPGENERATION_HPP
 
+#include "gc_implementation/shared/gcHeapSummary.hpp"
 #include "gc_implementation/shared/gSpaceCounters.hpp"
 #include "gc_implementation/shared/gcStats.hpp"
+#include "gc_implementation/shared/gcWhen.hpp"
 #include "gc_implementation/shared/generationCounters.hpp"
 #include "memory/freeBlockDictionary.hpp"
 #include "memory/generation.hpp"
@@ -615,8 +617,14 @@
   ConcurrentGCTimer* _gc_timer_cm;
 
   bool _cms_start_registered;
+
+  GCHeapSummary _last_heap_summary;
+  PermGenSummary _last_perm_gen_summary;
+
   void register_gc_start(GCCause::Cause cause);
   void register_gc_end();
+  void save_heap_summary();
+  void report_heap_summary(GCWhen::Type when);
 
  protected:
   ConcurrentMarkSweepGeneration* _cmsGen;  // old gen (CMS)
--- a/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp	Tue Mar 26 12:55:26 2013 -0700
+++ b/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp	Wed Apr 03 17:49:23 2013 +0200
@@ -195,6 +195,7 @@
 
   VM_CMS_Operation::verify_after_gc();
 
+  _collector->save_heap_summary();
   _collector->_gc_timer_cm->register_gc_pause_end(os::elapsed_counter());
 
 #ifndef USDT2
--- a/src/share/vm/gc_implementation/shared/gcHeapSummary.hpp	Tue Mar 26 12:55:26 2013 -0700
+++ b/src/share/vm/gc_implementation/shared/gcHeapSummary.hpp	Wed Apr 03 17:49:23 2013 +0200
@@ -32,6 +32,8 @@
   HeapWord* _committed_end;
   HeapWord* _reserved_end;
 public:
+  VirtualSpaceSummary() :
+      _start(NULL), _committed_end(NULL), _reserved_end(NULL) { }
   VirtualSpaceSummary(HeapWord* start, HeapWord* committed_end, HeapWord* reserved_end) :
       _start(start), _committed_end(committed_end), _reserved_end(reserved_end) { }
 
@@ -47,6 +49,8 @@
   HeapWord* _end;
   size_t    _used;
 public:
+  SpaceSummary() :
+      _start(NULL), _end(NULL), _used(0) { }
   SpaceSummary(HeapWord* start, HeapWord* end, size_t used) :
       _start(start), _end(end), _used(used) { }
 
@@ -70,6 +74,8 @@
   size_t _used;
 
  public:
+   GCHeapSummary() :
+       _heap(), _used(0) { }
    GCHeapSummary(VirtualSpaceSummary& heap_space, size_t used) :
        _heap(heap_space), _used(used) { }
 
@@ -108,6 +114,8 @@
   SpaceSummary        _object_space;
 
  public:
+  PermGenSummary() :
+       _perm_space(), _object_space() { }
   PermGenSummary(const VirtualSpaceSummary& perm_space, const SpaceSummary& object_space) :
        _perm_space(perm_space), _object_space(object_space) { }