< prev index next >

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

Print this page
rev 59939 : [mq]: 8243974-investigate-millis-since-last-gc-move

@@ -1478,10 +1478,12 @@
   CollectedHeap(),
   _young_gen_sampling_thread(NULL),
   _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()),
   _bot(NULL),
   _listener(),

@@ -2429,11 +2431,11 @@
 }
 
 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);)
     return 0;
   }

@@ -2724,10 +2726,12 @@
   // policy with the new heap occupancy
   Universe::update_heap_info_at_gc();
 
   // Print NUMA statistics.
   _numa->print_statistics();
+
+  _collection_pause_end = Ticks::now();
 }
 
 void G1CollectedHeap::verify_numa_regions(const char* desc) {
   LogTarget(Trace, gc, heap, verify) lt;
 

@@ -3118,10 +3122,12 @@
         expand_heap_after_young_collection();
 
         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);
 
       gc_epilogue(false);
< prev index next >