src/hotspot/share/gc/g1/g1YoungRemSetSamplingThread.cpp
changeset 53360 58e25974ede4
parent 53092 2a8dfb750d2c
parent 53354 528207d2e73e
child 53983 7935353a466a
equal deleted inserted replaced
53350:a47b8125b7cc 53360:58e25974ede4
    60     log_debug(gc, periodic)("Concurrent cycle in progress. Skipping.");
    60     log_debug(gc, periodic)("Concurrent cycle in progress. Skipping.");
    61     return false;
    61     return false;
    62   }
    62   }
    63 
    63 
    64   // Check if enough time has passed since the last GC.
    64   // Check if enough time has passed since the last GC.
    65   uintx time_since_last_gc;
    65   uintx time_since_last_gc = (uintx)Universe::heap()->millis_since_last_gc();
    66   if ((G1PeriodicGCInterval == 0) ||
    66   if ((time_since_last_gc < G1PeriodicGCInterval)) {
    67       ((time_since_last_gc = (uintx)Universe::heap()->millis_since_last_gc()) < G1PeriodicGCInterval)) {
       
    68     log_debug(gc, periodic)("Last GC occurred " UINTX_FORMAT "ms before which is below threshold " UINTX_FORMAT "ms. Skipping.",
    67     log_debug(gc, periodic)("Last GC occurred " UINTX_FORMAT "ms before which is below threshold " UINTX_FORMAT "ms. Skipping.",
    69                             time_since_last_gc, G1PeriodicGCInterval);
    68                             time_since_last_gc, G1PeriodicGCInterval);
    70     return false;
    69     return false;
    71   }
    70   }
    72 
    71 
    81 
    80 
    82   return true;
    81   return true;
    83 }
    82 }
    84 
    83 
    85 void G1YoungRemSetSamplingThread::check_for_periodic_gc(){
    84 void G1YoungRemSetSamplingThread::check_for_periodic_gc(){
       
    85   // If disabled, just return.
       
    86   if (G1PeriodicGCInterval == 0) {
       
    87     return;
       
    88   }
    86   if ((os::elapsedTime() - _last_periodic_gc_attempt_s) > (G1PeriodicGCInterval / 1000.0)) {
    89   if ((os::elapsedTime() - _last_periodic_gc_attempt_s) > (G1PeriodicGCInterval / 1000.0)) {
    87     log_debug(gc, periodic)("Checking for periodic GC.");
    90     log_debug(gc, periodic)("Checking for periodic GC.");
    88     if (should_start_periodic_gc()) {
    91     if (should_start_periodic_gc()) {
    89       Universe::heap()->collect(GCCause::_g1_periodic_collection);
    92       Universe::heap()->collect(GCCause::_g1_periodic_collection);
    90     }
    93     }
    92   }
    95   }
    93 }
    96 }
    94 
    97 
    95 void G1YoungRemSetSamplingThread::run_service() {
    98 void G1YoungRemSetSamplingThread::run_service() {
    96   double vtime_start = os::elapsedVTime();
    99   double vtime_start = os::elapsedVTime();
       
   100 
       
   101   // Print a message about periodic GC configuration.
       
   102   if (G1PeriodicGCInterval != 0) {
       
   103     log_info(gc)("Periodic GC enabled with interval " UINTX_FORMAT "ms", G1PeriodicGCInterval);
       
   104   } else {
       
   105     log_info(gc)("Periodic GC disabled");
       
   106   }
    97 
   107 
    98   while (!should_terminate()) {
   108   while (!should_terminate()) {
    99     sample_young_list_rs_lengths();
   109     sample_young_list_rs_lengths();
   100 
   110 
   101     if (os::supports_vtime()) {
   111     if (os::supports_vtime()) {