src/hotspot/share/gc/g1/g1YoungRemSetSamplingThread.cpp
changeset 53354 528207d2e73e
parent 53090 759266b1c89b
child 53360 58e25974ede4
--- a/src/hotspot/share/gc/g1/g1YoungRemSetSamplingThread.cpp	Wed Jan 16 09:48:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1YoungRemSetSamplingThread.cpp	Wed Jan 16 11:43:51 2019 +0100
@@ -61,9 +61,8 @@
   }
 
   // Check if enough time has passed since the last GC.
-  uintx time_since_last_gc;
-  if ((G1PeriodicGCInterval == 0) ||
-      ((time_since_last_gc = (uintx)Universe::heap()->millis_since_last_gc()) < G1PeriodicGCInterval)) {
+  uintx time_since_last_gc = (uintx)Universe::heap()->millis_since_last_gc();
+  if ((time_since_last_gc < G1PeriodicGCInterval)) {
     log_debug(gc, periodic)("Last GC occurred " UINTX_FORMAT "ms before which is below threshold " UINTX_FORMAT "ms. Skipping.",
                             time_since_last_gc, G1PeriodicGCInterval);
     return false;
@@ -82,6 +81,10 @@
 }
 
 void G1YoungRemSetSamplingThread::check_for_periodic_gc(){
+  // If disabled, just return.
+  if (G1PeriodicGCInterval == 0) {
+    return;
+  }
   if ((os::elapsedTime() - _last_periodic_gc_attempt_s) > (G1PeriodicGCInterval / 1000.0)) {
     log_debug(gc, periodic)("Checking for periodic GC.");
     if (should_start_periodic_gc()) {
@@ -94,6 +97,13 @@
 void G1YoungRemSetSamplingThread::run_service() {
   double vtime_start = os::elapsedVTime();
 
+  // Print a message about periodic GC configuration.
+  if (G1PeriodicGCInterval != 0) {
+    log_info(gc)("Periodic GC enabled with interval " UINTX_FORMAT "ms", G1PeriodicGCInterval);
+  } else {
+    log_info(gc)("Periodic GC disabled");
+  }
+
   while (!should_terminate()) {
     sample_young_list_rs_lengths();