< prev index next >

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

Print this page
*** 35,32 ***
  class ShenandoahYoungGenerationCounters : public GenerationCounters {
  public:
    ShenandoahYoungGenerationCounters() :
            GenerationCounters("Young", 0, 0, 0, (size_t)0, (size_t)0) {};
  
!   virtual void update_all() {
      // no update
    }
  };
  
  class ShenandoahGenerationCounters : public GenerationCounters {
  private:
    ShenandoahHeap* _heap;
  public:
!   ShenandoahGenerationCounters(ShenandoahHeap* heap) :
            GenerationCounters("Heap", 1, 1, heap->initial_capacity(), heap->max_capacity(), heap->capacity()),
            _heap(heap)
    {};
  
!   virtual void update_all() {
      _current_size->set_value(_heap->capacity());
    }
  };
  
  ShenandoahMonitoringSupport::ShenandoahMonitoringSupport(ShenandoahHeap* heap) :
          _partial_counters(nullptr),
!         _full_counters(nullptr)
  {
    // Collection counters do not fit Shenandoah very well.
    // We record partial cycles as "young", and full cycles (including full STW GC) as "old".
    _partial_counters  = new CollectorCounters("Shenandoah partial", 0);
    _full_counters     = new CollectorCounters("Shenandoah full",    1);
--- 35,33 ---
  class ShenandoahYoungGenerationCounters : public GenerationCounters {
  public:
    ShenandoahYoungGenerationCounters() :
            GenerationCounters("Young", 0, 0, 0, (size_t)0, (size_t)0) {};
  
!   void update_all() override {
      // no update
    }
  };
  
  class ShenandoahGenerationCounters : public GenerationCounters {
  private:
    ShenandoahHeap* _heap;
  public:
!   explicit ShenandoahGenerationCounters(ShenandoahHeap* heap) :
            GenerationCounters("Heap", 1, 1, heap->initial_capacity(), heap->max_capacity(), heap->capacity()),
            _heap(heap)
    {};
  
!   void update_all() override {
      _current_size->set_value(_heap->capacity());
    }
  };
  
  ShenandoahMonitoringSupport::ShenandoahMonitoringSupport(ShenandoahHeap* heap) :
          _partial_counters(nullptr),
!         _full_counters(nullptr),
+         _counters_update_task(this)
  {
    // Collection counters do not fit Shenandoah very well.
    // We record partial cycles as "young", and full cycles (including full STW GC) as "old".
    _partial_counters  = new CollectorCounters("Shenandoah partial", 0);
    _full_counters     = new CollectorCounters("Shenandoah full",    1);

*** 69,10 ***
--- 70,12 ---
    _young_counters = new ShenandoahYoungGenerationCounters();
    _heap_counters  = new ShenandoahGenerationCounters(heap);
    _space_counters = new HSpaceCounters(_heap_counters->name_space(), "Heap", 0, heap->max_capacity(), heap->initial_capacity());
  
    _heap_region_counters = new ShenandoahHeapRegionCounters();
+ 
+   _counters_update_task.enroll();
  }
  
  CollectorCounters* ShenandoahMonitoringSupport::stw_collection_counters() {
    return _full_counters;
  }

*** 101,5 ***
--- 104,46 ---
      _heap_region_counters->update();
  
      MetaspaceCounters::update_performance_counters();
    }
  }
+ 
+ void ShenandoahMonitoringSupport::notify_heap_changed() {
+   _counters_update_task.notify_heap_changed();
+ }
+ 
+ void ShenandoahMonitoringSupport::set_forced_counters_update(bool value) {
+   _counters_update_task.set_forced_counters_update(value);
+ }
+ 
+ void ShenandoahMonitoringSupport::handle_force_counters_update() {
+   _counters_update_task.handle_force_counters_update();
+ }
+ 
+ void ShenandoahPeriodicCountersUpdateTask::task() {
+   handle_force_counters_update();
+   handle_counters_update();
+ }
+ 
+ void ShenandoahPeriodicCountersUpdateTask::handle_counters_update() {
+   if (_do_counters_update.is_set()) {
+     _do_counters_update.unset();
+     _monitoring_support->update_counters();
+   }
+ }
+ 
+ void ShenandoahPeriodicCountersUpdateTask::handle_force_counters_update() {
+   if (_force_counters_update.is_set()) {
+     _do_counters_update.unset(); // reset these too, we do update now!
+     _monitoring_support->update_counters();
+   }
+ }
+ 
+ void ShenandoahPeriodicCountersUpdateTask::notify_heap_changed() {
+   if (_do_counters_update.is_unset()) {
+     _do_counters_update.set();
+   }
+ }
+ 
+ void ShenandoahPeriodicCountersUpdateTask::set_forced_counters_update(bool value) {
+   _force_counters_update.set_cond(value);
+ }
< prev index next >