--- old/src/share/vm/gc/shenandoah/shenandoahCollectorPolicy.cpp 2017-05-03 18:44:41.185113585 +0200 +++ new/src/share/vm/gc/shenandoah/shenandoahCollectorPolicy.cpp 2017-05-03 18:44:41.113114839 +0200 @@ -76,6 +76,9 @@ uint _cancelled_cm_cycles_in_a_row; uint _successful_cm_cycles_in_a_row; + uint _cancelled_uprefs_cycles_in_a_row; + uint _successful_uprefs_cycles_in_a_row; + size_t _bytes_in_cset; public: @@ -115,6 +118,10 @@ return _cancelled_cm_cycles_in_a_row <= ShenandoahFullGCThreshold; } + virtual bool handover_cancelled_uprefs() { + return _cancelled_uprefs_cycles_in_a_row <= ShenandoahFullGCThreshold; + } + virtual void record_cm_cancelled() { _cancelled_cm_cycles_in_a_row++; _successful_cm_cycles_in_a_row = 0; @@ -125,6 +132,16 @@ _successful_cm_cycles_in_a_row++; } + virtual void record_uprefs_cancelled() { + _cancelled_uprefs_cycles_in_a_row++; + _successful_uprefs_cycles_in_a_row = 0; + } + + virtual void record_uprefs_success() { + _cancelled_uprefs_cycles_in_a_row = 0; + _successful_uprefs_cycles_in_a_row++; + } + virtual void record_full_gc() { _bytes_in_cset = 0; } @@ -170,6 +187,8 @@ _bytes_in_cset(0), _cancelled_cm_cycles_in_a_row(0), _successful_cm_cycles_in_a_row(0), + _cancelled_uprefs_cycles_in_a_row(0), + _successful_uprefs_cycles_in_a_row(0), _region_garbage(NULL), _region_garbage_size(0) { @@ -470,24 +489,50 @@ return r->garbage() > threshold; } - virtual void record_cm_cancelled() { - ShenandoahHeuristics::record_cm_cancelled(); + void optimize_free_threshold() { + if (_successful_cm_cycles_in_a_row > ShenandoahHappyCyclesThreshold && + _free_threshold > ShenandoahMinFreeThreshold) { + _free_threshold--; + log_info(gc,ergo)("reducing free threshold to: "UINTX_FORMAT, _free_threshold); + _successful_cm_cycles_in_a_row = 0; + } + } + + void pessimize_free_threshold() { if (_free_threshold < ShenandoahMaxFreeThreshold) { _free_threshold++; log_info(gc,ergo)("increasing free threshold to: "UINTX_FORMAT, _free_threshold); } } + virtual void record_cm_cancelled() { + ShenandoahHeuristics::record_cm_cancelled(); + pessimize_free_threshold(); + } + virtual void record_cm_success() { ShenandoahHeuristics::record_cm_success(); - if (_successful_cm_cycles_in_a_row > ShenandoahHappyCyclesThreshold && - _free_threshold > ShenandoahMinFreeThreshold) { - _free_threshold--; - log_info(gc,ergo)("reducing free threshold to: "UINTX_FORMAT, _free_threshold); - _successful_cm_cycles_in_a_row = 0; + if (update_refs_early()) { + optimize_free_threshold(); } } + virtual void record_uprefs_cancelled() { + ShenandoahHeuristics::record_uprefs_cancelled(); + pessimize_free_threshold(); + } + + virtual void record_uprefs_success() { + ShenandoahHeuristics::record_uprefs_success(); + optimize_free_threshold(); + } + + virtual void record_full_gc() { + ShenandoahHeuristics::record_full_gc(); + pessimize_free_threshold(); + } + + virtual bool should_start_concurrent_mark(size_t used, size_t capacity) const { bool shouldStartConcurrentMark = false; @@ -722,7 +767,9 @@ ShenandoahCollectorPolicy::ShenandoahCollectorPolicy() : _cycle_counter(0), _successful_cm(0), - _degenerated_cm(0) + _degenerated_cm(0), + _successful_uprefs(0), + _degenerated_uprefs(0) { ShenandoahHeapRegion::setup_heap_region_size(initial_heap_byte_size(), max_heap_byte_size()); @@ -947,6 +994,10 @@ return _heuristics->handover_cancelled_marking(); } +bool ShenandoahCollectorPolicy::handover_cancelled_uprefs() { + return _heuristics->handover_cancelled_uprefs(); +} + bool ShenandoahCollectorPolicy::update_refs_early() { return _heuristics->update_refs_early(); } @@ -964,6 +1015,19 @@ _heuristics->record_cm_cancelled(); } +void ShenandoahCollectorPolicy::record_uprefs_success() { + _heuristics->record_uprefs_success(); + _successful_uprefs++; +} + +void ShenandoahCollectorPolicy::record_uprefs_degenerated() { + _degenerated_uprefs++; +} + +void ShenandoahCollectorPolicy::record_uprefs_cancelled() { + _heuristics->record_uprefs_cancelled(); +} + void ShenandoahCollectorPolicy::record_full_gc() { _heuristics->record_full_gc(); } @@ -1002,6 +1066,7 @@ out->cr(); out->print_cr("" SIZE_FORMAT " allocation failure and " SIZE_FORMAT " user requested GCs", _allocation_failure_gcs, _user_requested_gcs); out->print_cr("" SIZE_FORMAT " successful and " SIZE_FORMAT " degenerated concurrent markings", _successful_cm, _degenerated_cm); + out->print_cr("" SIZE_FORMAT " successful and " SIZE_FORMAT " degenerated update references ", _successful_uprefs, _degenerated_uprefs); out->cr(); }