mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-25 17:50:45 +00:00
8377180: Shenandoah: make escalation from degen to full more conservative
Reviewed-by: wkemper, xpeng
This commit is contained in:
parent
986d377224
commit
eec76d7b8c
@ -63,17 +63,10 @@ private:
|
||||
|
||||
public:
|
||||
// The most common scenario for lack of good progress following a degenerated GC is an accumulation of floating
|
||||
// garbage during the most recently aborted concurrent GC effort. With generational GC, it is far more effective to
|
||||
// garbage during the most recently aborted concurrent GC effort. Usually, it is far more effective to
|
||||
// reclaim this floating garbage with another degenerated cycle (which focuses on young generation and might require
|
||||
// a pause of 200 ms) rather than a full GC cycle (which may require over 2 seconds with a 10 GB old generation).
|
||||
//
|
||||
// In generational mode, we'll only upgrade to full GC if we've done two degen cycles in a row and both indicated
|
||||
// bad progress. In non-generational mode, we'll preserve the original behavior, which is to upgrade to full
|
||||
// immediately following a degenerated cycle with bad progress. This preserves original behavior of non-generational
|
||||
// Shenandoah to avoid introducing "surprising new behavior." It also makes less sense with non-generational
|
||||
// Shenandoah to replace a full GC with a degenerated GC, because both have similar pause times in non-generational
|
||||
// mode.
|
||||
static constexpr size_t GENERATIONAL_CONSECUTIVE_BAD_DEGEN_PROGRESS_THRESHOLD = 2;
|
||||
// a pause of 200 ms) rather than a full GC cycle (which may require multiple seconds with a 10 GB old generation).
|
||||
static constexpr size_t CONSECUTIVE_BAD_DEGEN_PROGRESS_THRESHOLD = 2;
|
||||
|
||||
ShenandoahCollectorPolicy();
|
||||
|
||||
@ -117,9 +110,9 @@ public:
|
||||
return _consecutive_degenerated_gcs;
|
||||
}
|
||||
|
||||
// Genshen will only upgrade to a full gc after the configured number of futile degenerated cycles.
|
||||
bool generational_should_upgrade_degenerated_gc() const {
|
||||
return _consecutive_degenerated_gcs_without_progress >= GENERATIONAL_CONSECUTIVE_BAD_DEGEN_PROGRESS_THRESHOLD;
|
||||
// Only upgrade to a full gc after the configured number of futile degenerated cycles.
|
||||
bool should_upgrade_degenerated_gc() const {
|
||||
return _consecutive_degenerated_gcs_without_progress >= CONSECUTIVE_BAD_DEGEN_PROGRESS_THRESHOLD;
|
||||
}
|
||||
|
||||
static bool is_allocation_failure(GCCause::Cause cause);
|
||||
|
||||
@ -314,7 +314,7 @@ void ShenandoahDegenGC::op_degenerated() {
|
||||
if (progress) {
|
||||
heap->notify_gc_progress();
|
||||
_generation->heuristics()->record_degenerated();
|
||||
} else if (!heap->mode()->is_generational() || policy->generational_should_upgrade_degenerated_gc()) {
|
||||
} else if (policy->should_upgrade_degenerated_gc()) {
|
||||
// Upgrade to full GC, register full-GC impact on heuristics.
|
||||
op_degenerated_futile();
|
||||
} else {
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
TEST(ShenandoahCollectorPolicyTest, track_degen_cycles_sanity) {
|
||||
ShenandoahCollectorPolicy policy;
|
||||
EXPECT_EQ(policy.consecutive_degenerated_gc_count(), 0UL);
|
||||
EXPECT_EQ(policy.generational_should_upgrade_degenerated_gc(), false);
|
||||
EXPECT_EQ(policy.should_upgrade_degenerated_gc(), false);
|
||||
}
|
||||
|
||||
TEST(ShenandoahCollectorPolicyTest, track_degen_cycles_no_upgrade) {
|
||||
@ -36,7 +36,7 @@ TEST(ShenandoahCollectorPolicyTest, track_degen_cycles_no_upgrade) {
|
||||
policy.record_degenerated(true, true, true);
|
||||
policy.record_degenerated(true, true, true);
|
||||
EXPECT_EQ(policy.consecutive_degenerated_gc_count(), 2UL);
|
||||
EXPECT_EQ(policy.generational_should_upgrade_degenerated_gc(), false);
|
||||
EXPECT_EQ(policy.should_upgrade_degenerated_gc(), false);
|
||||
}
|
||||
|
||||
TEST(ShenandoahCollectorPolicyTest, track_degen_cycles_upgrade) {
|
||||
@ -44,7 +44,7 @@ TEST(ShenandoahCollectorPolicyTest, track_degen_cycles_upgrade) {
|
||||
policy.record_degenerated(true, true, false);
|
||||
policy.record_degenerated(true, true, false);
|
||||
EXPECT_EQ(policy.consecutive_degenerated_gc_count(), 2UL);
|
||||
EXPECT_EQ(policy.generational_should_upgrade_degenerated_gc(), true);
|
||||
EXPECT_EQ(policy.should_upgrade_degenerated_gc(), true);
|
||||
}
|
||||
|
||||
TEST(ShenandoahCollectorPolicyTest, track_degen_cycles_reset_progress) {
|
||||
@ -52,7 +52,7 @@ TEST(ShenandoahCollectorPolicyTest, track_degen_cycles_reset_progress) {
|
||||
policy.record_degenerated(true, true, false);
|
||||
policy.record_degenerated(true, true, true);
|
||||
EXPECT_EQ(policy.consecutive_degenerated_gc_count(), 2UL);
|
||||
EXPECT_EQ(policy.generational_should_upgrade_degenerated_gc(), false);
|
||||
EXPECT_EQ(policy.should_upgrade_degenerated_gc(), false);
|
||||
}
|
||||
|
||||
TEST(ShenandoahCollectorPolicyTest, track_degen_cycles_full_reset) {
|
||||
@ -60,7 +60,7 @@ TEST(ShenandoahCollectorPolicyTest, track_degen_cycles_full_reset) {
|
||||
policy.record_degenerated(true, true, false);
|
||||
policy.record_success_full();
|
||||
EXPECT_EQ(policy.consecutive_degenerated_gc_count(), 0UL);
|
||||
EXPECT_EQ(policy.generational_should_upgrade_degenerated_gc(), false);
|
||||
EXPECT_EQ(policy.should_upgrade_degenerated_gc(), false);
|
||||
}
|
||||
|
||||
TEST(ShenandoahCollectorPolicyTest, track_degen_cycles_reset) {
|
||||
@ -68,5 +68,5 @@ TEST(ShenandoahCollectorPolicyTest, track_degen_cycles_reset) {
|
||||
policy.record_degenerated(true, true, false);
|
||||
policy.record_success_concurrent(true, true);
|
||||
EXPECT_EQ(policy.consecutive_degenerated_gc_count(), 0UL);
|
||||
EXPECT_EQ(policy.generational_should_upgrade_degenerated_gc(), false);
|
||||
EXPECT_EQ(policy.should_upgrade_degenerated_gc(), false);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user