Skip to content

Commit 81de88c

Browse files
committed
8319342: GenShen: Reset the count of degenerated cycles in a row following Full GC
Reviewed-by: wkemper, ysr
1 parent 2db0157 commit 81de88c

7 files changed

+21
-28
lines changed

Diff for: src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp

+1-11
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ int ShenandoahHeuristics::compare_by_garbage(RegionData a, RegionData b) {
4646
ShenandoahHeuristics::ShenandoahHeuristics(ShenandoahSpaceInfo* space_info) :
4747
_space_info(space_info),
4848
_region_data(nullptr),
49-
_degenerated_cycles_in_a_row(0),
50-
_successful_cycles_in_a_row(0),
5149
_guaranteed_gc_interval(0),
5250
_cycle_start(os::elapsedTime()),
5351
_last_cycle_end(0),
@@ -211,7 +209,7 @@ bool ShenandoahHeuristics::should_start_gc() {
211209
}
212210

213211
bool ShenandoahHeuristics::should_degenerate_cycle() {
214-
return _degenerated_cycles_in_a_row <= ShenandoahFullGCThreshold;
212+
return ShenandoahHeap::heap()->shenandoah_policy()->consecutive_degenerated_gc_count() <= ShenandoahFullGCThreshold;
215213
}
216214

217215
void ShenandoahHeuristics::adjust_penalty(intx step) {
@@ -232,8 +230,6 @@ void ShenandoahHeuristics::adjust_penalty(intx step) {
232230
}
233231

234232
void ShenandoahHeuristics::record_success_concurrent(bool abbreviated) {
235-
_degenerated_cycles_in_a_row = 0;
236-
_successful_cycles_in_a_row++;
237233
_gc_times_learned++;
238234

239235
adjust_penalty(Concurrent_Adjust);
@@ -244,16 +240,10 @@ void ShenandoahHeuristics::record_success_concurrent(bool abbreviated) {
244240
}
245241

246242
void ShenandoahHeuristics::record_success_degenerated() {
247-
_degenerated_cycles_in_a_row++;
248-
_successful_cycles_in_a_row = 0;
249-
250243
adjust_penalty(Degenerated_Penalty);
251244
}
252245

253246
void ShenandoahHeuristics::record_success_full() {
254-
_degenerated_cycles_in_a_row = 0;
255-
_successful_cycles_in_a_row++;
256-
257247
adjust_penalty(Full_Penalty);
258248
}
259249

Diff for: src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.hpp

-3
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@ class ShenandoahHeuristics : public CHeapObj<mtGC> {
9797
// have negligible cost unless proven otherwise.
9898
RegionData* _region_data;
9999

100-
uint _degenerated_cycles_in_a_row;
101-
uint _successful_cycles_in_a_row;
102-
103100
size_t _guaranteed_gc_interval;
104101

105102
double _cycle_start;

Diff for: src/hotspot/share/gc/shenandoah/shenandoahCollectorPolicy.cpp

+11-5
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@
3333
ShenandoahCollectorPolicy::ShenandoahCollectorPolicy() :
3434
_success_concurrent_gcs(0),
3535
_mixed_gcs(0),
36-
_abbreviated_cycles(0),
36+
_abbreviated_gcs(0),
3737
_success_old_gcs(0),
3838
_interrupted_old_gcs(0),
3939
_success_degenerated_gcs(0),
4040
_success_full_gcs(0),
4141
_consecutive_young_gcs(0),
42+
_consecutive_degenerated_gcs(0),
4243
_alloc_failure_degenerated(0),
4344
_alloc_failure_degenerated_upgrade_to_full(0),
4445
_alloc_failure_full(0),
@@ -82,10 +83,12 @@ void ShenandoahCollectorPolicy::record_alloc_failure_to_degenerated(ShenandoahGC
8283

8384
void ShenandoahCollectorPolicy::record_degenerated_upgrade_to_full() {
8485
ShenandoahHeap::heap()->record_upgrade_to_full();
86+
_consecutive_degenerated_gcs = 0;
8587
_alloc_failure_degenerated_upgrade_to_full++;
8688
}
8789

8890
void ShenandoahCollectorPolicy::record_success_concurrent(bool is_young) {
91+
_consecutive_degenerated_gcs = 0;
8992
if (is_young) {
9093
_consecutive_young_gcs++;
9194
} else {
@@ -99,7 +102,7 @@ void ShenandoahCollectorPolicy::record_mixed_cycle() {
99102
}
100103

101104
void ShenandoahCollectorPolicy::record_abbreviated_cycle() {
102-
_abbreviated_cycles++;
105+
_abbreviated_gcs++;
103106
}
104107

105108
void ShenandoahCollectorPolicy::record_success_old() {
@@ -112,7 +115,10 @@ void ShenandoahCollectorPolicy::record_interrupted_old() {
112115
_interrupted_old_gcs++;
113116
}
114117

115-
void ShenandoahCollectorPolicy::record_success_degenerated(bool is_young) {
118+
void ShenandoahCollectorPolicy::record_success_degenerated(bool is_young, bool is_upgraded_to_full) {
119+
if (!is_upgraded_to_full) {
120+
_consecutive_degenerated_gcs++;
121+
}
116122
if (is_young) {
117123
_consecutive_young_gcs++;
118124
} else {
@@ -122,6 +128,7 @@ void ShenandoahCollectorPolicy::record_success_degenerated(bool is_young) {
122128
}
123129

124130
void ShenandoahCollectorPolicy::record_success_full() {
131+
_consecutive_degenerated_gcs = 0;
125132
_consecutive_young_gcs = 0;
126133
_success_full_gcs++;
127134
}
@@ -142,7 +149,6 @@ bool ShenandoahCollectorPolicy::is_at_shutdown() {
142149
return _in_shutdown.is_set();
143150
}
144151

145-
146152
void ShenandoahCollectorPolicy::print_gc_stats(outputStream* out) const {
147153
out->print_cr("Under allocation pressure, concurrent cycles may cancel, and either continue cycle");
148154
out->print_cr("under stop-the-world pause or result in stop-the-world Full GC. Increase heap size,");
@@ -172,7 +178,7 @@ void ShenandoahCollectorPolicy::print_gc_stats(outputStream* out) const {
172178
out->print_cr(" " SIZE_FORMAT_W(5) " upgraded to Full GC", _alloc_failure_degenerated_upgrade_to_full);
173179
out->cr();
174180

175-
out->print_cr(SIZE_FORMAT_W(5) " Abbreviated GCs", _abbreviated_cycles);
181+
out->print_cr(SIZE_FORMAT_W(5) " Abbreviated GCs", _abbreviated_gcs);
176182
out->cr();
177183

178184
out->print_cr(SIZE_FORMAT_W(5) " Full GCs", _success_full_gcs + _alloc_failure_degenerated_upgrade_to_full);

Diff for: src/hotspot/share/gc/shenandoah/shenandoahCollectorPolicy.hpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,14 @@ class ShenandoahCollectorPolicy : public CHeapObj<mtGC> {
4141
private:
4242
size_t _success_concurrent_gcs;
4343
size_t _mixed_gcs;
44-
size_t _abbreviated_cycles;
44+
size_t _abbreviated_gcs;
4545
size_t _success_old_gcs;
4646
size_t _interrupted_old_gcs;
4747
size_t _success_degenerated_gcs;
4848
// Written by control thread, read by mutators
4949
volatile size_t _success_full_gcs;
5050
volatile size_t _consecutive_young_gcs;
51+
uint _consecutive_degenerated_gcs;
5152
size_t _alloc_failure_degenerated;
5253
size_t _alloc_failure_degenerated_upgrade_to_full;
5354
size_t _alloc_failure_full;
@@ -61,6 +62,7 @@ class ShenandoahCollectorPolicy : public CHeapObj<mtGC> {
6162
ShenandoahSharedFlag _in_shutdown;
6263
ShenandoahTracer* _tracer;
6364

65+
6466
public:
6567
ShenandoahCollectorPolicy();
6668

@@ -73,7 +75,7 @@ class ShenandoahCollectorPolicy : public CHeapObj<mtGC> {
7375
void record_success_concurrent(bool is_young);
7476
void record_success_old();
7577
void record_interrupted_old();
76-
void record_success_degenerated(bool is_young);
78+
void record_success_degenerated(bool is_young, bool is_upgraded_to_full);
7779
void record_success_full();
7880
void record_alloc_failure_to_degenerated(ShenandoahGC::ShenandoahDegenPoint point);
7981
void record_alloc_failure_to_full();
@@ -99,6 +101,10 @@ class ShenandoahCollectorPolicy : public CHeapObj<mtGC> {
99101
inline size_t consecutive_young_gc_count() const {
100102
return _consecutive_young_gcs;
101103
}
104+
105+
inline size_t consecutive_degenerated_gc_count() const {
106+
return _consecutive_degenerated_gcs;
107+
}
102108
};
103109

104110
#endif // SHARE_GC_SHENANDOAH_SHENANDOAHCOLLECTORPOLICY_HPP

Diff for: src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ bool ShenandoahControlThread::service_stw_degenerated_cycle(GCCause::Cause cause
817817
}
818818

819819
_degen_generation->heuristics()->record_success_degenerated();
820-
heap->shenandoah_policy()->record_success_degenerated(_degen_generation->is_young());
820+
heap->shenandoah_policy()->record_success_degenerated(_degen_generation->is_young(), gc.upgraded_to_full());
821821
return !gc.upgraded_to_full();
822822
}
823823

Diff for: src/hotspot/share/gc/shenandoah/shenandoahGeneration.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -1018,8 +1018,3 @@ void ShenandoahGeneration::record_success_concurrent(bool abbreviated) {
10181018
heuristics()->record_success_concurrent(abbreviated);
10191019
ShenandoahHeap::heap()->shenandoah_policy()->record_success_concurrent(is_young());
10201020
}
1021-
1022-
void ShenandoahGeneration::record_success_degenerated() {
1023-
heuristics()->record_success_degenerated();
1024-
ShenandoahHeap::heap()->shenandoah_policy()->record_success_degenerated(is_young());
1025-
}

Diff for: src/hotspot/share/gc/shenandoah/shenandoahGeneration.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ class ShenandoahGeneration : public CHeapObj<mtGC>, public ShenandoahSpaceInfo {
213213
void confirm_heuristics_mode();
214214

215215
virtual void record_success_concurrent(bool abbreviated);
216-
virtual void record_success_degenerated();
217216
};
218217

219218
#endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHGENERATION_HPP

0 commit comments

Comments
 (0)