Skip to content

Commit

Permalink
8239904: Shenandoah: accumulated penalties should not be over 100% of…
Browse files Browse the repository at this point in the history
… capacity

Reviewed-by: rkennke
  • Loading branch information
shipilev committed Feb 25, 2020
1 parent 7d5652f commit 98e0a70
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
26 changes: 23 additions & 3 deletions src/hotspot/share/gc/shenandoah/shenandoahHeuristics.cpp
Expand Up @@ -261,25 +261,45 @@ bool ShenandoahHeuristics::should_degenerate_cycle() {
return _degenerated_cycles_in_a_row <= ShenandoahFullGCThreshold;
}

void ShenandoahHeuristics::adjust_penalty(intx step) {
assert(0 <= _gc_time_penalties && _gc_time_penalties <= 100,
"In range before adjustment: " INTX_FORMAT, _gc_time_penalties);

intx new_val = _gc_time_penalties + step;
if (new_val < 0) {
new_val = 0;
}
if (new_val > 100) {
new_val = 100;
}
_gc_time_penalties = new_val;

assert(0 <= _gc_time_penalties && _gc_time_penalties <= 100,
"In range after adjustment: " INTX_FORMAT, _gc_time_penalties);
}

void ShenandoahHeuristics::record_success_concurrent() {
_degenerated_cycles_in_a_row = 0;
_successful_cycles_in_a_row++;

_gc_time_history->add(time_since_last_gc());
_gc_times_learned++;
_gc_time_penalties -= MIN2<size_t>(_gc_time_penalties, Concurrent_Adjust);

adjust_penalty(Concurrent_Adjust);
}

void ShenandoahHeuristics::record_success_degenerated() {
_degenerated_cycles_in_a_row++;
_successful_cycles_in_a_row = 0;
_gc_time_penalties += Degenerated_Penalty;

adjust_penalty(Degenerated_Penalty);
}

void ShenandoahHeuristics::record_success_full() {
_degenerated_cycles_in_a_row = 0;
_successful_cycles_in_a_row++;
_gc_time_penalties += Full_Penalty;

adjust_penalty(Full_Penalty);
}

void ShenandoahHeuristics::record_allocation_failure_gc() {
Expand Down
6 changes: 4 additions & 2 deletions src/hotspot/share/gc/shenandoah/shenandoahHeuristics.hpp
Expand Up @@ -67,7 +67,7 @@ class ShenandoahCollectionSet;
class ShenandoahHeapRegion;

class ShenandoahHeuristics : public CHeapObj<mtGC> {
static const intx Concurrent_Adjust = 1; // recover from penalties
static const intx Concurrent_Adjust = -1; // recover from penalties
static const intx Degenerated_Penalty = 10; // how much to penalize average GC duration history on Degenerated GC
static const intx Full_Penalty = 20; // how much to penalize average GC duration history on Full GC

Expand All @@ -93,7 +93,7 @@ class ShenandoahHeuristics : public CHeapObj<mtGC> {
double _last_cycle_end;

size_t _gc_times_learned;
size_t _gc_time_penalties;
intx _gc_time_penalties;
TruncatedSeq* _gc_time_history;

// There may be many threads that contend to set this flag
Expand All @@ -110,6 +110,8 @@ class ShenandoahHeuristics : public CHeapObj<mtGC> {
RegionData* data, size_t data_size,
size_t free) = 0;

void adjust_penalty(intx step);

public:
ShenandoahHeuristics();
virtual ~ShenandoahHeuristics();
Expand Down

0 comments on commit 98e0a70

Please sign in to comment.