< prev index next >

src/share/vm/gc/g1/g1IHOPControl.cpp

Print this page
rev 10164 : [mq]: 8140777-adapt-adaptive-ihop-logging
   1 /*
   2  * Copyright (c) 2015, 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  *


  30 #include "logging/log.hpp"
  31 
  32 G1IHOPControl::G1IHOPControl(double initial_ihop_percent, size_t target_occupancy) :
  33   _initial_ihop_percent(initial_ihop_percent),
  34   _target_occupancy(target_occupancy),
  35   _last_allocated_bytes(0),
  36   _last_allocation_time_s(0.0)
  37 {
  38   assert(_initial_ihop_percent >= 0.0 && _initial_ihop_percent <= 100.0, "Initial IHOP value must be between 0 and 100 but is %.3f", initial_ihop_percent);
  39 }
  40 
  41 void G1IHOPControl::update_allocation_info(double allocation_time_s, size_t allocated_bytes, size_t additional_buffer_size) {
  42   assert(allocation_time_s >= 0.0, "Allocation time must be positive but is %.3f", allocation_time_s);
  43 
  44   _last_allocation_time_s = allocation_time_s;
  45   _last_allocated_bytes = allocated_bytes;
  46 }
  47 
  48 void G1IHOPControl::print() {
  49   size_t cur_conc_mark_start_threshold = get_conc_mark_start_threshold();
  50   log_debug(gc, ihop)("Basic information (value update), threshold: " SIZE_FORMAT "B (%1.2f), target occupancy: " SIZE_FORMAT "B, current occupancy: " SIZE_FORMAT "B,"
  51                       " recent old gen allocation rate: %1.2f, recent marking phase length: %1.2f",
  52                       cur_conc_mark_start_threshold,
  53                       cur_conc_mark_start_threshold * 100.0 / _target_occupancy,
  54                       _target_occupancy,
  55                       G1CollectedHeap::heap()->used(),


  56                       _last_allocation_time_s > 0.0 ? _last_allocated_bytes / _last_allocation_time_s : 0.0,
  57                       last_marking_length_s());
  58 }
  59 
  60 void G1IHOPControl::send_trace_event(G1NewTracer* tracer) {
  61   tracer->report_basic_ihop_statistics(get_conc_mark_start_threshold(),
  62                                        _target_occupancy,
  63                                        G1CollectedHeap::heap()->used(),
  64                                        _last_allocated_bytes,
  65                                        _last_allocation_time_s,
  66                                        last_marking_length_s());
  67 }
  68 
  69 G1StaticIHOPControl::G1StaticIHOPControl(double ihop_percent, size_t target_occupancy) :
  70   G1IHOPControl(ihop_percent, target_occupancy),
  71   _last_marking_length_s(0.0) {
  72   assert(_target_occupancy > 0, "Target occupancy must be larger than zero.");
  73 }
  74 
  75 #ifndef PRODUCT
  76 static void test_update(G1IHOPControl* ctrl, double alloc_time, size_t alloc_amount, size_t young_size, double mark_time) {
  77   for (int i = 0; i < 100; i++) {


 174 
 175 void G1AdaptiveIHOPControl::update_allocation_info(double allocation_time_s,
 176                                                    size_t allocated_bytes,
 177                                                    size_t additional_buffer_size) {
 178   G1IHOPControl::update_allocation_info(allocation_time_s, allocated_bytes, additional_buffer_size);
 179 
 180   double allocation_rate = (double) allocated_bytes / allocation_time_s;
 181   _allocation_rate_s.add(allocation_rate);
 182 
 183   _last_unrestrained_young_size = additional_buffer_size;
 184 }
 185 
 186 void G1AdaptiveIHOPControl::update_marking_length(double marking_length_s) {
 187    assert(marking_length_s >= 0.0, "Marking length must be larger than zero but is %.3f", marking_length_s);
 188   _marking_times_s.add(marking_length_s);
 189 }
 190 
 191 void G1AdaptiveIHOPControl::print() {
 192   G1IHOPControl::print();
 193   size_t actual_target = actual_target_threshold();
 194   log_debug(gc, ihop)("Adaptive IHOP information (value update), threshold: " SIZE_FORMAT "B (%1.2f), internal target occupancy: " SIZE_FORMAT "B,"
 195                       " predicted old gen allocation rate: %1.2f, predicted marking phase length: %1.2f, prediction active: %s",

 196                       get_conc_mark_start_threshold(),
 197                       percent_of(get_conc_mark_start_threshold(), actual_target),
 198                       actual_target,


 199                       _predictor->get_new_prediction(&_allocation_rate_s),
 200                       _predictor->get_new_prediction(&_marking_times_s),
 201                       have_enough_data_for_prediction() ? "true" : "false");
 202 }
 203 
 204 void G1AdaptiveIHOPControl::send_trace_event(G1NewTracer* tracer) {
 205   G1IHOPControl::send_trace_event(tracer);
 206   tracer->report_adaptive_ihop_statistics(get_conc_mark_start_threshold(),
 207                                           actual_target_threshold(),
 208                                           G1CollectedHeap::heap()->used(),
 209                                           _last_unrestrained_young_size,
 210                                           _predictor->get_new_prediction(&_allocation_rate_s),
 211                                           _predictor->get_new_prediction(&_marking_times_s),
 212                                           have_enough_data_for_prediction());
 213 }
 214 
 215 #ifndef PRODUCT
 216 void G1AdaptiveIHOPControl::test() {
 217   size_t const initial_threshold = 45;
 218   size_t const young_size = 10;
 219   size_t const target_size = 100;
 220 


   1 /*
   2  * Copyright (c) 2015, 2016, 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  *


  30 #include "logging/log.hpp"
  31 
  32 G1IHOPControl::G1IHOPControl(double initial_ihop_percent, size_t target_occupancy) :
  33   _initial_ihop_percent(initial_ihop_percent),
  34   _target_occupancy(target_occupancy),
  35   _last_allocated_bytes(0),
  36   _last_allocation_time_s(0.0)
  37 {
  38   assert(_initial_ihop_percent >= 0.0 && _initial_ihop_percent <= 100.0, "Initial IHOP value must be between 0 and 100 but is %.3f", initial_ihop_percent);
  39 }
  40 
  41 void G1IHOPControl::update_allocation_info(double allocation_time_s, size_t allocated_bytes, size_t additional_buffer_size) {
  42   assert(allocation_time_s >= 0.0, "Allocation time must be positive but is %.3f", allocation_time_s);
  43 
  44   _last_allocation_time_s = allocation_time_s;
  45   _last_allocated_bytes = allocated_bytes;
  46 }
  47 
  48 void G1IHOPControl::print() {
  49   size_t cur_conc_mark_start_threshold = get_conc_mark_start_threshold();
  50   log_debug(gc, ihop)("Basic information (value update), threshold: " SIZE_FORMAT "B (%1.2f), target occupancy: " SIZE_FORMAT "B, current occupancy: " SIZE_FORMAT "B, "
  51                       "recent allocation size: " SIZE_FORMAT "B, recent allocation duration: %1.2fms, recent old gen allocation rate: %1.2fB/s, recent marking phase length: %1.2fms",
  52                       cur_conc_mark_start_threshold,
  53                       cur_conc_mark_start_threshold * 100.0 / _target_occupancy,
  54                       _target_occupancy,
  55                       G1CollectedHeap::heap()->used(),
  56                       _last_allocated_bytes,
  57                       _last_allocation_time_s * 1000.0,
  58                       _last_allocation_time_s > 0.0 ? _last_allocated_bytes / _last_allocation_time_s : 0.0,
  59                       last_marking_length_s() * 1000.0);
  60 }
  61 
  62 void G1IHOPControl::send_trace_event(G1NewTracer* tracer) {
  63   tracer->report_basic_ihop_statistics(get_conc_mark_start_threshold(),
  64                                        _target_occupancy,
  65                                        G1CollectedHeap::heap()->used(),
  66                                        _last_allocated_bytes,
  67                                        _last_allocation_time_s,
  68                                        last_marking_length_s());
  69 }
  70 
  71 G1StaticIHOPControl::G1StaticIHOPControl(double ihop_percent, size_t target_occupancy) :
  72   G1IHOPControl(ihop_percent, target_occupancy),
  73   _last_marking_length_s(0.0) {
  74   assert(_target_occupancy > 0, "Target occupancy must be larger than zero.");
  75 }
  76 
  77 #ifndef PRODUCT
  78 static void test_update(G1IHOPControl* ctrl, double alloc_time, size_t alloc_amount, size_t young_size, double mark_time) {
  79   for (int i = 0; i < 100; i++) {


 176 
 177 void G1AdaptiveIHOPControl::update_allocation_info(double allocation_time_s,
 178                                                    size_t allocated_bytes,
 179                                                    size_t additional_buffer_size) {
 180   G1IHOPControl::update_allocation_info(allocation_time_s, allocated_bytes, additional_buffer_size);
 181 
 182   double allocation_rate = (double) allocated_bytes / allocation_time_s;
 183   _allocation_rate_s.add(allocation_rate);
 184 
 185   _last_unrestrained_young_size = additional_buffer_size;
 186 }
 187 
 188 void G1AdaptiveIHOPControl::update_marking_length(double marking_length_s) {
 189    assert(marking_length_s >= 0.0, "Marking length must be larger than zero but is %.3f", marking_length_s);
 190   _marking_times_s.add(marking_length_s);
 191 }
 192 
 193 void G1AdaptiveIHOPControl::print() {
 194   G1IHOPControl::print();
 195   size_t actual_target = actual_target_threshold();
 196   log_debug(gc, ihop)("Adaptive IHOP information (value update), threshold: " SIZE_FORMAT "B (%1.2f), internal target occupancy: " SIZE_FORMAT "B, "
 197                       "occupancy: " SIZE_FORMAT "B, additional buffer size: " SIZE_FORMAT "B, predicted old gen allocation rate: %1.2fB/s, "
 198                       "predicted marking phase length: %1.2fms, prediction active: %s",
 199                       get_conc_mark_start_threshold(),
 200                       percent_of(get_conc_mark_start_threshold(), actual_target),
 201                       actual_target,
 202                       G1CollectedHeap::heap()->used(),
 203                       _last_unrestrained_young_size,
 204                       _predictor->get_new_prediction(&_allocation_rate_s),
 205                       _predictor->get_new_prediction(&_marking_times_s) * 1000.0,
 206                       have_enough_data_for_prediction() ? "true" : "false");
 207 }
 208 
 209 void G1AdaptiveIHOPControl::send_trace_event(G1NewTracer* tracer) {
 210   G1IHOPControl::send_trace_event(tracer);
 211   tracer->report_adaptive_ihop_statistics(get_conc_mark_start_threshold(),
 212                                           actual_target_threshold(),
 213                                           G1CollectedHeap::heap()->used(),
 214                                           _last_unrestrained_young_size,
 215                                           _predictor->get_new_prediction(&_allocation_rate_s),
 216                                           _predictor->get_new_prediction(&_marking_times_s),
 217                                           have_enough_data_for_prediction());
 218 }
 219 
 220 #ifndef PRODUCT
 221 void G1AdaptiveIHOPControl::test() {
 222   size_t const initial_threshold = 45;
 223   size_t const young_size = 10;
 224   size_t const target_size = 100;
 225 


< prev index next >