--- old/src/hotspot/share/gc/g1/g1CollectedHeap.cpp 2020-06-25 15:26:39.055043353 +0200 +++ new/src/hotspot/share/gc/g1/g1CollectedHeap.cpp 2020-06-25 15:26:38.951042048 +0200 @@ -1480,6 +1480,8 @@ _workers(NULL), _card_table(NULL), _soft_ref_policy(), + _collection_pause_end(Ticks::now()), + _time_of_last_gc_ns(os::javaTimeNanos()), _old_set("Old Region Set", new OldRegionSetChecker()), _archive_set("Archive Region Set", new ArchiveRegionSetChecker()), _humongous_set("Humongous Region Set", new HumongousRegionSetChecker()), @@ -2431,7 +2433,7 @@ jlong G1CollectedHeap::millis_since_last_gc() { // See the notes in GenCollectedHeap::millis_since_last_gc() // for more information about the implementation. - jlong ret_val = (os::javaTimeNanos() - _policy->time_of_last_gc()) / + jlong ret_val = (os::javaTimeNanos() - _time_of_last_gc_ns) / NANOSECS_PER_MILLISEC; if (ret_val < 0) { NOT_PRODUCT(log_warning(gc)("time warp: " JLONG_FORMAT, ret_val);) @@ -2726,6 +2728,8 @@ // Print NUMA statistics. _numa->print_statistics(); + + _collection_pause_end = Ticks::now(); } void G1CollectedHeap::verify_numa_regions(const char* desc) { @@ -3120,6 +3124,8 @@ double sample_end_time_sec = os::elapsedTime(); double pause_time_ms = (sample_end_time_sec - sample_start_time_sec) * MILLIUNITS; policy()->record_collection_pause_end(pause_time_ms); + + _time_of_last_gc_ns = os::javaTimeNanos(); } verify_after_young_collection(verify_type);