Skip to content
Permalink
Browse files

8239904: Shenandoah: accumulated penalties should not be over 100% of…

… capacity

Reviewed-by: rkennke
  • Loading branch information
shipilev committed Feb 25, 2020
1 parent 7d5652f commit 98e0a704d4691f665651a5e8cf64baf571c3fb60
@@ -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() {
@@ -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

@@ -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
@@ -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();

0 comments on commit 98e0a70

Please sign in to comment.