< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahMonitoringSupport.cpp

Print this page

 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "gc/shared/collectorCounters.hpp"
 27 #include "gc/shared/generationCounters.hpp"
 28 #include "gc/shared/hSpaceCounters.hpp"
 29 #include "gc/shenandoah/shenandoahMonitoringSupport.hpp"
 30 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
 31 #include "gc/shenandoah/shenandoahHeapRegionCounters.hpp"
 32 #include "memory/metaspaceCounters.hpp"
 33 #include "services/memoryService.hpp"
 34 
 35 class ShenandoahYoungGenerationCounters : public GenerationCounters {
 36 public:
 37   ShenandoahYoungGenerationCounters() :
 38           GenerationCounters("Young", 0, 0, 0, (size_t)0, (size_t)0) {};
 39 
 40   virtual void update_all() {
 41     // no update
 42   }
 43 };
 44 
 45 class ShenandoahGenerationCounters : public GenerationCounters {
 46 private:
 47   ShenandoahHeap* _heap;
 48 public:
 49   ShenandoahGenerationCounters(ShenandoahHeap* heap) :
 50           GenerationCounters("Heap", 1, 1, heap->initial_capacity(), heap->max_capacity(), heap->capacity()),
 51           _heap(heap)
 52   {};
 53 
 54   virtual void update_all() {
 55     _current_size->set_value(_heap->capacity());
 56   }
 57 };
 58 
 59 ShenandoahMonitoringSupport::ShenandoahMonitoringSupport(ShenandoahHeap* heap) :
 60         _partial_counters(nullptr),
 61         _full_counters(nullptr)

 62 {
 63   // Collection counters do not fit Shenandoah very well.
 64   // We record partial cycles as "young", and full cycles (including full STW GC) as "old".
 65   _partial_counters  = new CollectorCounters("Shenandoah partial", 0);
 66   _full_counters     = new CollectorCounters("Shenandoah full",    1);
 67 
 68   // We report young gen as unused.
 69   _young_counters = new ShenandoahYoungGenerationCounters();
 70   _heap_counters  = new ShenandoahGenerationCounters(heap);
 71   _space_counters = new HSpaceCounters(_heap_counters->name_space(), "Heap", 0, heap->max_capacity(), heap->initial_capacity());
 72 
 73   _heap_region_counters = new ShenandoahHeapRegionCounters();


 74 }
 75 
 76 CollectorCounters* ShenandoahMonitoringSupport::stw_collection_counters() {
 77   return _full_counters;
 78 }
 79 
 80 CollectorCounters* ShenandoahMonitoringSupport::full_stw_collection_counters() {
 81   return _full_counters;
 82 }
 83 
 84 CollectorCounters* ShenandoahMonitoringSupport::concurrent_collection_counters() {
 85   return _full_counters;
 86 }
 87 
 88 CollectorCounters* ShenandoahMonitoringSupport::partial_collection_counters() {
 89   return _partial_counters;
 90 }
 91 
 92 void ShenandoahMonitoringSupport::update_counters() {
 93   MemoryService::track_memory_usage();
 94 
 95   if (UsePerfData) {
 96     ShenandoahHeap* heap = ShenandoahHeap::heap();
 97     size_t used = heap->used();
 98     size_t capacity = heap->max_capacity();
 99     _heap_counters->update_all();
100     _space_counters->update_all(capacity, used);
101     _heap_region_counters->update();
102 
103     MetaspaceCounters::update_performance_counters();
104   }
105 }










































 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "gc/shared/collectorCounters.hpp"
 27 #include "gc/shared/generationCounters.hpp"
 28 #include "gc/shared/hSpaceCounters.hpp"
 29 #include "gc/shenandoah/shenandoahMonitoringSupport.hpp"
 30 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
 31 #include "gc/shenandoah/shenandoahHeapRegionCounters.hpp"
 32 #include "memory/metaspaceCounters.hpp"
 33 #include "services/memoryService.hpp"
 34 
 35 class ShenandoahYoungGenerationCounters : public GenerationCounters {
 36 public:
 37   ShenandoahYoungGenerationCounters() :
 38           GenerationCounters("Young", 0, 0, 0, (size_t)0, (size_t)0) {};
 39 
 40   void update_all() override {
 41     // no update
 42   }
 43 };
 44 
 45 class ShenandoahGenerationCounters : public GenerationCounters {
 46 private:
 47   ShenandoahHeap* _heap;
 48 public:
 49   explicit ShenandoahGenerationCounters(ShenandoahHeap* heap) :
 50           GenerationCounters("Heap", 1, 1, heap->initial_capacity(), heap->max_capacity(), heap->capacity()),
 51           _heap(heap)
 52   {};
 53 
 54   void update_all() override {
 55     _current_size->set_value(_heap->capacity());
 56   }
 57 };
 58 
 59 ShenandoahMonitoringSupport::ShenandoahMonitoringSupport(ShenandoahHeap* heap) :
 60         _partial_counters(nullptr),
 61         _full_counters(nullptr),
 62         _counters_update_task(this)
 63 {
 64   // Collection counters do not fit Shenandoah very well.
 65   // We record partial cycles as "young", and full cycles (including full STW GC) as "old".
 66   _partial_counters  = new CollectorCounters("Shenandoah partial", 0);
 67   _full_counters     = new CollectorCounters("Shenandoah full",    1);
 68 
 69   // We report young gen as unused.
 70   _young_counters = new ShenandoahYoungGenerationCounters();
 71   _heap_counters  = new ShenandoahGenerationCounters(heap);
 72   _space_counters = new HSpaceCounters(_heap_counters->name_space(), "Heap", 0, heap->max_capacity(), heap->initial_capacity());
 73 
 74   _heap_region_counters = new ShenandoahHeapRegionCounters();
 75 
 76   _counters_update_task.enroll();
 77 }
 78 
 79 CollectorCounters* ShenandoahMonitoringSupport::stw_collection_counters() {
 80   return _full_counters;
 81 }
 82 
 83 CollectorCounters* ShenandoahMonitoringSupport::full_stw_collection_counters() {
 84   return _full_counters;
 85 }
 86 
 87 CollectorCounters* ShenandoahMonitoringSupport::concurrent_collection_counters() {
 88   return _full_counters;
 89 }
 90 
 91 CollectorCounters* ShenandoahMonitoringSupport::partial_collection_counters() {
 92   return _partial_counters;
 93 }
 94 
 95 void ShenandoahMonitoringSupport::update_counters() {
 96   MemoryService::track_memory_usage();
 97 
 98   if (UsePerfData) {
 99     ShenandoahHeap* heap = ShenandoahHeap::heap();
100     size_t used = heap->used();
101     size_t capacity = heap->max_capacity();
102     _heap_counters->update_all();
103     _space_counters->update_all(capacity, used);
104     _heap_region_counters->update();
105 
106     MetaspaceCounters::update_performance_counters();
107   }
108 }
109 
110 void ShenandoahMonitoringSupport::notify_heap_changed() {
111   _counters_update_task.notify_heap_changed();
112 }
113 
114 void ShenandoahMonitoringSupport::set_forced_counters_update(bool value) {
115   _counters_update_task.set_forced_counters_update(value);
116 }
117 
118 void ShenandoahMonitoringSupport::handle_force_counters_update() {
119   _counters_update_task.handle_force_counters_update();
120 }
121 
122 void ShenandoahPeriodicCountersUpdateTask::task() {
123   handle_force_counters_update();
124   handle_counters_update();
125 }
126 
127 void ShenandoahPeriodicCountersUpdateTask::handle_counters_update() {
128   if (_do_counters_update.is_set()) {
129     _do_counters_update.unset();
130     _monitoring_support->update_counters();
131   }
132 }
133 
134 void ShenandoahPeriodicCountersUpdateTask::handle_force_counters_update() {
135   if (_force_counters_update.is_set()) {
136     _do_counters_update.unset(); // reset these too, we do update now!
137     _monitoring_support->update_counters();
138   }
139 }
140 
141 void ShenandoahPeriodicCountersUpdateTask::notify_heap_changed() {
142   if (_do_counters_update.is_unset()) {
143     _do_counters_update.set();
144   }
145 }
146 
147 void ShenandoahPeriodicCountersUpdateTask::set_forced_counters_update(bool value) {
148   _force_counters_update.set_cond(value);
149 }
< prev index next >