Skip to content

Commit 86a1640

Browse files
Ivan WalulyaThomas Schatzl
authored andcommitted
8244505: G1 pause time ratio calculation does not consider Remark/Cleanup pauses
Reviewed-by: tschatzl, sjohanss
1 parent 11c4ea9 commit 86a1640

File tree

4 files changed

+40
-14
lines changed

4 files changed

+40
-14
lines changed

src/hotspot/share/gc/g1/g1Analytics.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,6 @@ void G1Analytics::update_recent_gc_times(double end_time_sec,
324324
double pause_time_ms) {
325325
_recent_gc_times_ms->add(pause_time_ms);
326326
_recent_prev_end_times_for_all_gcs_sec->add(end_time_sec);
327-
_prev_collection_pause_end_ms = end_time_sec * 1000.0;
328327
}
329328

330329
void G1Analytics::report_concurrent_mark_cleanup_times_ms(double ms) {

src/hotspot/share/gc/g1/g1Analytics.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ class G1Analytics: public CHeapObj<mtGC> {
114114
_prev_collection_pause_end_ms += ms;
115115
}
116116

117+
void set_prev_collection_pause_end_ms(double ms) {
118+
_prev_collection_pause_end_ms = ms;
119+
}
120+
117121
void report_concurrent_mark_remark_times_ms(double ms);
118122
void report_concurrent_mark_cleanup_times_ms(double ms);
119123
void report_alloc_rate_ms(double alloc_rate);

src/hotspot/share/gc/g1/g1Policy.cpp

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -558,10 +558,6 @@ void G1Policy::record_full_collection_end() {
558558
// Consider this like a collection pause for the purposes of allocation
559559
// since last pause.
560560
double end_sec = os::elapsedTime();
561-
double full_gc_time_sec = end_sec - _full_collection_start_sec;
562-
double full_gc_time_ms = full_gc_time_sec * 1000.0;
563-
564-
_analytics->update_recent_gc_times(end_sec, full_gc_time_ms);
565561

566562
collector_state()->set_in_full_gc(false);
567563

@@ -677,7 +673,6 @@ void G1Policy::record_concurrent_mark_remark_end() {
677673
double end_time_sec = os::elapsedTime();
678674
double elapsed_time_ms = (end_time_sec - _mark_remark_start_sec)*1000.0;
679675
_analytics->report_concurrent_mark_remark_times_ms(elapsed_time_ms);
680-
_analytics->append_prev_collection_pause_end_ms(elapsed_time_ms);
681676

682677
record_pause(Remark, _mark_remark_start_sec, end_time_sec);
683678
}
@@ -753,20 +748,19 @@ void G1Policy::record_collection_pause_end(double pause_time_ms) {
753748
G1GCPhaseTimes* p = phase_times();
754749

755750
double end_time_sec = os::elapsedTime();
751+
double start_time_sec = phase_times()->cur_collection_start_sec();
756752

757753
PauseKind this_pause = young_gc_pause_kind();
758754

759-
bool update_stats = !_g1h->evacuation_failed();
760-
761-
record_pause(this_pause, end_time_sec - pause_time_ms / 1000.0, end_time_sec);
755+
bool update_stats = should_update_gc_stats();
762756

763757
if (is_concurrent_start_pause(this_pause)) {
764758
record_concurrent_mark_init_end(0.0);
765759
} else {
766760
maybe_start_marking();
767761
}
768762

769-
double app_time_ms = (phase_times()->cur_collection_start_sec() * 1000.0 - _analytics->prev_collection_pause_end_ms());
763+
double app_time_ms = (start_time_sec * 1000.0 - _analytics->prev_collection_pause_end_ms());
770764
if (app_time_ms < MIN_TIMER_GRANULARITY) {
771765
// This usually happens due to the timer not having the required
772766
// granularity. Some Linuxes are the usual culprits.
@@ -786,11 +780,10 @@ void G1Policy::record_collection_pause_end(double pause_time_ms) {
786780
uint regions_allocated = _collection_set->eden_region_length();
787781
double alloc_rate_ms = (double) regions_allocated / app_time_ms;
788782
_analytics->report_alloc_rate_ms(alloc_rate_ms);
789-
790-
_analytics->compute_pause_time_ratios(end_time_sec, pause_time_ms);
791-
_analytics->update_recent_gc_times(end_time_sec, pause_time_ms);
792783
}
793784

785+
record_pause(this_pause, start_time_sec, end_time_sec);
786+
794787
if (is_last_young_pause(this_pause)) {
795788
assert(!is_concurrent_start_pause(this_pause),
796789
"The young GC before mixed is not allowed to be concurrent start GC");
@@ -1238,7 +1231,6 @@ void G1Policy::record_concurrent_mark_cleanup_end() {
12381231
double end_sec = os::elapsedTime();
12391232
double elapsed_time_ms = (end_sec - _mark_cleanup_start_sec) * 1000.0;
12401233
_analytics->report_concurrent_mark_cleanup_times_ms(elapsed_time_ms);
1241-
_analytics->append_prev_collection_pause_end_ms(elapsed_time_ms);
12421234

12431235
record_pause(Cleanup, _mark_cleanup_start_sec, end_sec);
12441236
}
@@ -1312,11 +1304,37 @@ G1Policy::PauseKind G1Policy::young_gc_pause_kind() const {
13121304
}
13131305
}
13141306

1307+
bool G1Policy::should_update_gc_stats() {
1308+
// Evacuation failures skew the timing too much to be considered for statistics updates.
1309+
// We make the assumption that these are rare.
1310+
return !_g1h->evacuation_failed();
1311+
}
1312+
1313+
void G1Policy::update_gc_pause_time_ratios(PauseKind kind, double start_time_sec, double end_time_sec) {
1314+
1315+
double pause_time_sec = end_time_sec - start_time_sec;
1316+
double pause_time_ms = pause_time_sec * 1000.0;
1317+
1318+
_analytics->compute_pause_time_ratios(end_time_sec, pause_time_ms);
1319+
_analytics->update_recent_gc_times(end_time_sec, pause_time_ms);
1320+
1321+
if (kind == Cleanup || kind == Remark) {
1322+
_analytics->append_prev_collection_pause_end_ms(pause_time_ms);
1323+
} else {
1324+
_analytics->set_prev_collection_pause_end_ms(end_time_sec * 1000.0);
1325+
}
1326+
}
1327+
13151328
void G1Policy::record_pause(PauseKind kind, double start, double end) {
13161329
// Manage the MMU tracker. For some reason it ignores Full GCs.
13171330
if (kind != FullGC) {
13181331
_mmu_tracker->add_pause(start, end);
13191332
}
1333+
1334+
if (should_update_gc_stats()) {
1335+
update_gc_pause_time_ratios(kind, start, end);
1336+
}
1337+
13201338
// Manage the mutator time tracking from concurrent start to first mixed gc.
13211339
switch (kind) {
13221340
case FullGC:

src/hotspot/share/gc/g1/g1Policy.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,11 @@ class G1Policy: public CHeapObj<mtGC> {
285285
PauseKind young_gc_pause_kind() const;
286286
// Record the given STW pause with the given start and end times (in s).
287287
void record_pause(PauseKind kind, double start, double end);
288+
289+
bool should_update_gc_stats();
290+
291+
void update_gc_pause_time_ratios(PauseKind kind, double start_sec, double end_sec);
292+
288293
// Indicate that we aborted marking before doing any mixed GCs.
289294
void abort_time_to_mixed_tracking();
290295

0 commit comments

Comments
 (0)