@@ -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+
13151328void 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:
0 commit comments