< prev index next >

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

Print this page
rev 9310 : dihop-changes
rev 9311 : imported patch sihop-thomas-review
rev 9312 : imported patch 8136678-implement-adaptive-sizing-algorithm-for-IHOP
rev 9313 : imported patch aihop-thomas-review
rev 9314 : imported patch 8136679-jfr-event-for-dynamic-ihop
rev 9315 : imported patch sangheon-review


  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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc/g1/g1CollectedHeap.inline.hpp"
  27 #include "gc/g1/g1ErgoVerbose.hpp"
  28 #include "gc/g1/g1IHOPControl.hpp"
  29 #include "gc/g1/g1Predictions.hpp"

  30 
  31 G1IHOPControl::G1IHOPControl(double initial_ihop_percent, size_t target_occupancy) :
  32   _ihop_percent(initial_ihop_percent),
  33   _target_occupancy(target_occupancy) {
  34   assert(_ihop_percent >= 0.0 && _ihop_percent <= 100.0, "Initial IHOP value must be between 0 and 100 but is %.3f", initial_ihop_percent);
  35 }
  36 
  37 G1StaticIHOPControl::G1StaticIHOPControl(double ihop_percent, size_t target_occupancy) :
  38   G1IHOPControl(ihop_percent, target_occupancy),
  39   _last_allocation_time_s(0.0),
  40   _last_allocated_bytes(0),
  41   _last_marking_length_s(0.0) {
  42   assert(_target_occupancy > 0, "Target occupancy must be larger than zero.");
  43 }
  44 
  45 void G1StaticIHOPControl::print() {
  46   ergo_verbose6(ErgoIHOP,
  47                 "basic information",
  48                 ergo_format_reason("value update")
  49                 ergo_format_byte_perc("threshold")
  50                 ergo_format_byte("target occupancy")
  51                 ergo_format_byte("current occupancy")
  52                 ergo_format_double("recent old gen allocation rate")
  53                 ergo_format_double("recent marking phase length"),
  54                 get_conc_mark_start_threshold(),
  55                 (double) get_conc_mark_start_threshold() / _target_occupancy * 100.0,
  56                 _target_occupancy,
  57                 G1CollectedHeap::heap()->used(),
  58                 _last_allocation_time_s > 0.0 ? _last_allocated_bytes / _last_allocation_time_s : 0.0,
  59                 _last_marking_length_s);
  60 }
  61 









  62 #ifndef PRODUCT
  63 static void test_update(G1IHOPControl* ctrl, double alloc_time, size_t alloc_amount, size_t young_size, double mark_time) {
  64   for (int i = 0; i < 100; i++) {
  65     ctrl->update_allocation_info(alloc_time, alloc_amount, young_size);
  66     ctrl->update_time_to_mixed(mark_time);
  67   }
  68 }
  69 
  70 void G1StaticIHOPControl::test() {
  71   size_t const initial_ihop = 45;
  72 
  73   G1StaticIHOPControl ctrl(initial_ihop, 100);
  74   size_t threshold;
  75   
  76   threshold = ctrl.get_conc_mark_start_threshold();
  77   assert(threshold == initial_ihop,
  78          "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_ihop, threshold);
  79 
  80   ctrl.update_allocation_info(100.0, 100, 100);
  81   threshold = ctrl.get_conc_mark_start_threshold();


 165                 ergo_format_byte("current occupancy")
 166                 ergo_format_double("recent old gen allocation rate")
 167                 ergo_format_double("recent marking phase length"),
 168                 get_conc_mark_start_threshold(),
 169                 _target_occupancy > 0 ? (double) get_conc_mark_start_threshold() / _target_occupancy * 100.0 : 0.0,
 170                 _target_occupancy,
 171                 G1CollectedHeap::heap()->used(),
 172                 _allocation_rate_s.last(),
 173                 _marking_times_s.last()
 174                 );
 175   ergo_verbose3(ErgoIHOP, 
 176                 "adaptive IHOP information",
 177                 ergo_format_reason("value update")
 178                 ergo_format_double("predicted old gen allocation rate")
 179                 ergo_format_double("predicted marking phase length")
 180                 ergo_format_str("prediction active"),
 181                 _predictor->get_new_prediction(&_allocation_rate_s),
 182                 _predictor->get_new_prediction(&_marking_times_s),
 183                 have_enough_data_for_prediction() ? "true" : "false"
 184                 );













 185 }
 186 
 187 #ifndef PRODUCT
 188 void G1AdaptiveIHOPControl::test() {
 189   size_t const initial_threshold = 45;
 190   size_t const young_size = 10;
 191   size_t const target_size = 100;
 192 
 193   // The final IHOP value is always
 194   // target_size - (young_size + alloc_amount/alloc_time * marking_time)
 195 
 196   G1Predictions pred(0.95);
 197   G1AdaptiveIHOPControl ctrl(initial_threshold, target_size, &pred);
 198 
 199   // First "load".
 200   size_t const alloc_time1 = 2;
 201   size_t const alloc_amount1 = 10;
 202   size_t const marking_time1 = 2;
 203   size_t const settled_ihop1 = target_size - (young_size + alloc_amount1/alloc_time1 * marking_time1);
 204 




  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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc/g1/g1CollectedHeap.inline.hpp"
  27 #include "gc/g1/g1ErgoVerbose.hpp"
  28 #include "gc/g1/g1IHOPControl.hpp"
  29 #include "gc/g1/g1Predictions.hpp"
  30 #include "gc/shared/gcTrace.hpp"
  31 
  32 G1IHOPControl::G1IHOPControl(double initial_ihop_percent, size_t target_occupancy) :
  33   _ihop_percent(initial_ihop_percent),
  34   _target_occupancy(target_occupancy) {
  35   assert(_ihop_percent >= 0.0 && _ihop_percent <= 100.0, "Initial IHOP value must be between 0 and 100 but is %.3f", initial_ihop_percent);
  36 }
  37 
  38 G1StaticIHOPControl::G1StaticIHOPControl(double ihop_percent, size_t target_occupancy) :
  39   G1IHOPControl(ihop_percent, target_occupancy),
  40   _last_allocation_time_s(0.0),
  41   _last_allocated_bytes(0),
  42   _last_marking_length_s(0.0) {
  43   assert(_target_occupancy > 0, "Target occupancy must be larger than zero.");
  44 }
  45 
  46 void G1StaticIHOPControl::print() {
  47   ergo_verbose6(ErgoIHOP,
  48                 "basic information",
  49                 ergo_format_reason("value update")
  50                 ergo_format_byte_perc("threshold")
  51                 ergo_format_byte("target occupancy")
  52                 ergo_format_byte("current occupancy")
  53                 ergo_format_double("recent old gen allocation rate")
  54                 ergo_format_double("recent marking phase length"),
  55                 get_conc_mark_start_threshold(),
  56                 (double) get_conc_mark_start_threshold() / _target_occupancy * 100.0,
  57                 _target_occupancy,
  58                 G1CollectedHeap::heap()->used(),
  59                 _last_allocation_time_s > 0.0 ? _last_allocated_bytes / _last_allocation_time_s : 0.0,
  60                 _last_marking_length_s);
  61 }
  62 
  63 void G1StaticIHOPControl::send_event(G1NewTracer* tracer) {
  64   tracer->report_basic_ihop_statistics(get_conc_mark_start_threshold(),
  65                                        _target_occupancy,
  66                                        G1CollectedHeap::heap()->used(),
  67                                        _last_allocated_bytes,
  68                                        _last_allocation_time_s,
  69                                        _last_marking_length_s);
  70 }
  71 
  72 #ifndef PRODUCT
  73 static void test_update(G1IHOPControl* ctrl, double alloc_time, size_t alloc_amount, size_t young_size, double mark_time) {
  74   for (int i = 0; i < 100; i++) {
  75     ctrl->update_allocation_info(alloc_time, alloc_amount, young_size);
  76     ctrl->update_time_to_mixed(mark_time);
  77   }
  78 }
  79 
  80 void G1StaticIHOPControl::test() {
  81   size_t const initial_ihop = 45;
  82 
  83   G1StaticIHOPControl ctrl(initial_ihop, 100);
  84   size_t threshold;
  85   
  86   threshold = ctrl.get_conc_mark_start_threshold();
  87   assert(threshold == initial_ihop,
  88          "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_ihop, threshold);
  89 
  90   ctrl.update_allocation_info(100.0, 100, 100);
  91   threshold = ctrl.get_conc_mark_start_threshold();


 175                 ergo_format_byte("current occupancy")
 176                 ergo_format_double("recent old gen allocation rate")
 177                 ergo_format_double("recent marking phase length"),
 178                 get_conc_mark_start_threshold(),
 179                 _target_occupancy > 0 ? (double) get_conc_mark_start_threshold() / _target_occupancy * 100.0 : 0.0,
 180                 _target_occupancy,
 181                 G1CollectedHeap::heap()->used(),
 182                 _allocation_rate_s.last(),
 183                 _marking_times_s.last()
 184                 );
 185   ergo_verbose3(ErgoIHOP, 
 186                 "adaptive IHOP information",
 187                 ergo_format_reason("value update")
 188                 ergo_format_double("predicted old gen allocation rate")
 189                 ergo_format_double("predicted marking phase length")
 190                 ergo_format_str("prediction active"),
 191                 _predictor->get_new_prediction(&_allocation_rate_s),
 192                 _predictor->get_new_prediction(&_marking_times_s),
 193                 have_enough_data_for_prediction() ? "true" : "false"
 194                 );
 195 }
 196 
 197 void G1AdaptiveIHOPControl::send_event(G1NewTracer* tracer) {
 198   tracer->report_basic_ihop_statistics(get_conc_mark_start_threshold(),
 199                                        _target_occupancy,
 200                                        G1CollectedHeap::heap()->used(),
 201                                        _last_allocation_bytes,
 202                                        _allocation_rate_s.last(),
 203                                        _marking_times_s.last());
 204   tracer->report_adaptive_ihop_statistics(_prev_unrestrained_young_size,
 205                                           _predictor->get_new_prediction(&_allocation_rate_s),
 206                                           _predictor->get_new_prediction(&_marking_times_s),
 207                                           have_enough_data_for_prediction());
 208 }
 209 
 210 #ifndef PRODUCT
 211 void G1AdaptiveIHOPControl::test() {
 212   size_t const initial_threshold = 45;
 213   size_t const young_size = 10;
 214   size_t const target_size = 100;
 215 
 216   // The final IHOP value is always
 217   // target_size - (young_size + alloc_amount/alloc_time * marking_time)
 218 
 219   G1Predictions pred(0.95);
 220   G1AdaptiveIHOPControl ctrl(initial_threshold, target_size, &pred);
 221 
 222   // First "load".
 223   size_t const alloc_time1 = 2;
 224   size_t const alloc_amount1 = 10;
 225   size_t const marking_time1 = 2;
 226   size_t const settled_ihop1 = target_size - (young_size + alloc_amount1/alloc_time1 * marking_time1);
 227 


< prev index next >