< prev index next >

src/hotspot/share/gc/z/zDirector.cpp

Print this page


   1 /*
   2  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


 132   // time and end up starting the GC too late in the next interval.
 133   const double sample_interval = 1.0 / ZStatAllocRate::sample_hz;
 134   const double time_until_gc = time_until_oom - max_duration_of_gc - sample_interval;
 135 
 136   log_debug(gc, director)("Rule: Allocation Rate, MaxAllocRate: %.3lfMB/s, Free: " SIZE_FORMAT "MB, MaxDurationOfGC: %.3lfs, TimeUntilGC: %.3lfs",
 137                           max_alloc_rate / M, free / M, max_duration_of_gc, time_until_gc);
 138 
 139   return time_until_gc <= 0;
 140 }
 141 
 142 bool ZDirector::rule_proactive() const {
 143   if (!is_warm()) {
 144     // Rule disabled
 145     return false;
 146   }
 147 
 148   // Perform GC if the impact of doing so, in terms of application throughput
 149   // reduction, is considered acceptable. This rule allows us to keep the heap
 150   // size down and allow reference processing to happen even when we have a lot
 151   // of free space on the heap.
















 152   const double assumed_throughput_drop_during_gc = 0.50; // 50%
 153   const double acceptable_throughput_drop = 0.01;        // 1%
 154 
 155   const AbsSeq& duration_of_gc = ZStatPhaseCycle::duration();
 156   const double max_duration_of_gc = duration_of_gc.davg() + (duration_of_gc.dsd() * one_in_1000);
 157   const double acceptable_gc_interval = max_duration_of_gc * ((assumed_throughput_drop_during_gc / acceptable_throughput_drop) - 1.0);
 158   const double time_since_last_gc = ZStatPhaseCycle::time_since_last();
 159   const double time_until_gc = acceptable_gc_interval - time_since_last_gc;
 160 
 161   log_debug(gc, director)("Rule: Proactive, AcceptableGCInterval: %.3lfs, TimeSinceLastGC: %.3lfs, TimeUntilGC: %.3lfs",
 162                           acceptable_gc_interval, time_since_last_gc, time_until_gc);
 163 
 164   return time_until_gc <= 0;
 165 }
 166 
 167 GCCause::Cause ZDirector::make_gc_decision() const {
 168   // Rule 0: Timer
 169   if (rule_timer()) {
 170     return GCCause::_z_timer;
 171   }
 172 
 173   // Rule 1: Warmup
 174   if (rule_warmup()) {
 175     return GCCause::_z_warmup;
 176   }
 177 
 178   // Rule 2: Allocation rate


   1 /*
   2  * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


 132   // time and end up starting the GC too late in the next interval.
 133   const double sample_interval = 1.0 / ZStatAllocRate::sample_hz;
 134   const double time_until_gc = time_until_oom - max_duration_of_gc - sample_interval;
 135 
 136   log_debug(gc, director)("Rule: Allocation Rate, MaxAllocRate: %.3lfMB/s, Free: " SIZE_FORMAT "MB, MaxDurationOfGC: %.3lfs, TimeUntilGC: %.3lfs",
 137                           max_alloc_rate / M, free / M, max_duration_of_gc, time_until_gc);
 138 
 139   return time_until_gc <= 0;
 140 }
 141 
 142 bool ZDirector::rule_proactive() const {
 143   if (!is_warm()) {
 144     // Rule disabled
 145     return false;
 146   }
 147 
 148   // Perform GC if the impact of doing so, in terms of application throughput
 149   // reduction, is considered acceptable. This rule allows us to keep the heap
 150   // size down and allow reference processing to happen even when we have a lot
 151   // of free space on the heap.
 152 
 153   // Only consider doing a proactive GC if the heap usage has grown by at least
 154   // 10% of the max capacity since the previous GC, or more than 5 minutes has
 155   // passed since the previous GC. This helps avoid superfluous GCs when running
 156   // applications with very low allocation rate.
 157   const size_t used_after_last_gc = ZStatHeap::used_at_relocate_end();
 158   const size_t used_increase_threshold = ZHeap::heap()->max_capacity() * 0.10; // 10%
 159   const size_t used_threshold = used_after_last_gc + used_increase_threshold;
 160   const size_t used = ZHeap::heap()->used();
 161   const double time_since_last_gc = ZStatPhaseCycle::time_since_last();
 162   const double time_since_last_gc_threshold = 5 * 60; // 5 minutes
 163   if (used < used_threshold && time_since_last_gc < time_since_last_gc_threshold) {
 164     // Don't even consider doing a proactive GC
 165     return false;
 166   }
 167 
 168   const double assumed_throughput_drop_during_gc = 0.50; // 50%
 169   const double acceptable_throughput_drop = 0.01;        // 1%

 170   const AbsSeq& duration_of_gc = ZStatPhaseCycle::duration();
 171   const double max_duration_of_gc = duration_of_gc.davg() + (duration_of_gc.dsd() * one_in_1000);
 172   const double acceptable_gc_interval = max_duration_of_gc * ((assumed_throughput_drop_during_gc / acceptable_throughput_drop) - 1.0);

 173   const double time_until_gc = acceptable_gc_interval - time_since_last_gc;
 174 
 175   log_debug(gc, director)("Rule: Proactive, AcceptableGCInterval: %.3lfs, TimeSinceLastGC: %.3lfs, TimeUntilGC: %.3lfs",
 176                           acceptable_gc_interval, time_since_last_gc, time_until_gc);
 177 
 178   return time_until_gc <= 0;
 179 }
 180 
 181 GCCause::Cause ZDirector::make_gc_decision() const {
 182   // Rule 0: Timer
 183   if (rule_timer()) {
 184     return GCCause::_z_timer;
 185   }
 186 
 187   // Rule 1: Warmup
 188   if (rule_warmup()) {
 189     return GCCause::_z_warmup;
 190   }
 191 
 192   // Rule 2: Allocation rate


< prev index next >