< prev index next >

src/hotspot/share/gc/g1/g1Analytics.cpp

Print this page
rev 56067 : [mq]: renaming
rev 56069 : [mq]: copyrights
   1 /*
   2  * Copyright (c) 2016, 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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc/g1/g1Analytics.hpp"
  27 #include "gc/g1/g1Predictions.hpp"
  28 #include "runtime/os.hpp"
  29 #include "utilities/debug.hpp"
  30 #include "utilities/numberSeq.hpp"
  31 
  32 // Different defaults for different number of GC threads
  33 // They were chosen by running GCOld and SPECjbb on debris with different
  34 //   numbers of GC threads and choosing them based on the results
  35 
  36 // all the same
  37 static double rs_length_diff_defaults[] = {
  38   0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
  39 };
  40 
  41 static double cost_per_log_buffer_entry_ms_defaults[] = {
  42   0.01, 0.005, 0.005, 0.003, 0.003, 0.002, 0.002, 0.0015
  43 };
  44 
  45 // all the same
  46 static double young_cards_per_entry_ratio_defaults[] = {
  47   1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0
  48 };
  49 
  50 static double young_only_cost_per_remset_card_ms_defaults[] = {
  51   0.015, 0.01, 0.01, 0.008, 0.008, 0.0055, 0.0055, 0.005
  52 };
  53 
  54 static double cost_per_byte_ms_defaults[] = {
  55   0.00006, 0.00003, 0.00003, 0.000015, 0.000015, 0.00001, 0.00001, 0.000009
  56 };
  57 
  58 // these should be pretty consistent
  59 static double constant_other_time_ms_defaults[] = {
  60   5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0
  61 };
  62 
  63 
  64 static double young_other_cost_per_region_ms_defaults[] = {
  65   0.3, 0.2, 0.2, 0.15, 0.15, 0.12, 0.12, 0.1
  66 };
  67 
  68 static double non_young_other_cost_per_region_ms_defaults[] = {
  69   1.0, 0.7, 0.7, 0.5, 0.5, 0.42, 0.42, 0.30
  70 };
  71 
  72 G1Analytics::G1Analytics(const G1Predictions* predictor) :
  73     _predictor(predictor),
  74     _recent_gc_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)),
  75     _concurrent_mark_remark_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)),
  76     _concurrent_mark_cleanup_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)),
  77     _alloc_rate_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
  78     _prev_collection_pause_end_ms(0.0),
  79     _rs_length_diff_seq(new TruncatedSeq(TruncatedSeqLength)),
  80     _cost_per_log_buffer_entry_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
  81     _cost_scan_hcc_seq(new TruncatedSeq(TruncatedSeqLength)),
  82     _young_cards_per_entry_ratio_seq(new TruncatedSeq(TruncatedSeqLength)),
  83     _mixed_cards_per_entry_ratio_seq(new TruncatedSeq(TruncatedSeqLength)),
  84     _young_only_cost_per_remset_card_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
  85     _mixed_cost_per_remset_card_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
  86     _cost_per_byte_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
  87     _constant_other_time_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
  88     _young_other_cost_per_region_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
  89     _non_young_other_cost_per_region_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
  90     _pending_cards_seq(new TruncatedSeq(TruncatedSeqLength)),
  91     _rs_length_seq(new TruncatedSeq(TruncatedSeqLength)),
  92     _cost_per_byte_ms_during_cm_seq(new TruncatedSeq(TruncatedSeqLength)),
  93     _recent_prev_end_times_for_all_gcs_sec(new TruncatedSeq(NumPrevPausesForHeuristics)),
  94     _recent_avg_pause_time_ratio(0.0),
  95     _last_pause_time_ratio(0.0) {
  96 
  97   // Seed sequences with initial values.
  98   _recent_prev_end_times_for_all_gcs_sec->add(os::elapsedTime());
  99   _prev_collection_pause_end_ms = os::elapsedTime() * 1000.0;
 100 
 101   int index = MIN2(ParallelGCThreads - 1, 7u);
 102 
 103   _rs_length_diff_seq->add(rs_length_diff_defaults[index]);
 104   _cost_per_log_buffer_entry_ms_seq->add(cost_per_log_buffer_entry_ms_defaults[index]);
 105   _cost_scan_hcc_seq->add(0.0);
 106   _young_cards_per_entry_ratio_seq->add(young_cards_per_entry_ratio_defaults[index]);
 107   _young_only_cost_per_remset_card_ms_seq->add(young_only_cost_per_remset_card_ms_defaults[index]);
 108   _cost_per_byte_ms_seq->add(cost_per_byte_ms_defaults[index]);
 109   _constant_other_time_ms_seq->add(constant_other_time_ms_defaults[index]);
 110   _young_other_cost_per_region_ms_seq->add(young_other_cost_per_region_ms_defaults[index]);
 111   _non_young_other_cost_per_region_ms_seq->add(non_young_other_cost_per_region_ms_defaults[index]);
 112 
 113   // start conservatively (around 50ms is about right)
 114   _concurrent_mark_remark_times_ms->add(0.05);
 115   _concurrent_mark_cleanup_times_ms->add(0.20);
 116 }
 117 
 118 double G1Analytics::get_new_prediction(TruncatedSeq const* seq) const {
 119   return _predictor->get_new_prediction(seq);
 120 }
 121 
 122 size_t G1Analytics::get_new_size_prediction(TruncatedSeq const* seq) const {
 123   return (size_t)get_new_prediction(seq);
 124 }


 141       (_recent_avg_pause_time_ratio - 1.0 > 0.0)) {
 142     // Clip ratio between 0.0 and 1.0, and continue. This will be fixed in
 143     // CR 6902692 by redoing the manner in which the ratio is incrementally computed.
 144     if (_recent_avg_pause_time_ratio < 0.0) {
 145       _recent_avg_pause_time_ratio = 0.0;
 146     } else {
 147       assert(_recent_avg_pause_time_ratio - 1.0 > 0.0, "Ctl-point invariant");
 148       _recent_avg_pause_time_ratio = 1.0;
 149     }
 150   }
 151 
 152   // Compute the ratio of just this last pause time to the entire time range stored
 153   // in the vectors. Comparing this pause to the entire range, rather than only the
 154   // most recent interval, has the effect of smoothing over a possible transient 'burst'
 155   // of more frequent pauses that don't really reflect a change in heap occupancy.
 156   // This reduces the likelihood of a needless heap expansion being triggered.
 157   _last_pause_time_ratio =
 158     (pause_time_ms * _recent_prev_end_times_for_all_gcs_sec->num()) / interval_ms;
 159 }
 160 
 161 void G1Analytics::report_cost_per_log_buffer_entry_ms(double cost_per_log_buffer_entry_ms) {
 162   _cost_per_log_buffer_entry_ms_seq->add(cost_per_log_buffer_entry_ms);
 163 }
 164 
 165 void G1Analytics::report_cost_scan_hcc(double cost_scan_hcc) {
 166   _cost_scan_hcc_seq->add(cost_scan_hcc);
 167 }
 168 
 169 void G1Analytics::report_cost_per_remset_card_ms(double cost_per_remset_card_ms, bool for_young_gc) {
 170   if (for_young_gc) {
 171     _young_only_cost_per_remset_card_ms_seq->add(cost_per_remset_card_ms);
 172   } else {
 173     _mixed_cost_per_remset_card_ms_seq->add(cost_per_remset_card_ms);
 174   }
 175 }
 176 
 177 void G1Analytics::report_cards_per_entry_ratio(double cards_per_entry_ratio, bool for_young_gc) {
 178   if (for_young_gc) {
 179     _young_cards_per_entry_ratio_seq->add(cards_per_entry_ratio);
 180   } else {
 181     _mixed_cards_per_entry_ratio_seq->add(cards_per_entry_ratio);
 182   }


 205 void G1Analytics::report_constant_other_time_ms(double constant_other_time_ms) {
 206   _constant_other_time_ms_seq->add(constant_other_time_ms);
 207 }
 208 
 209 void G1Analytics::report_pending_cards(double pending_cards) {
 210   _pending_cards_seq->add(pending_cards);
 211 }
 212 
 213 void G1Analytics::report_rs_length(double rs_length) {
 214   _rs_length_seq->add(rs_length);
 215 }
 216 
 217 size_t G1Analytics::predict_rs_length_diff() const {
 218   return get_new_size_prediction(_rs_length_diff_seq);
 219 }
 220 
 221 double G1Analytics::predict_alloc_rate_ms() const {
 222   return get_new_prediction(_alloc_rate_ms_seq);
 223 }
 224 
 225 double G1Analytics::predict_cost_per_log_buffer_entry_ms() const {
 226   return get_new_prediction(_cost_per_log_buffer_entry_ms_seq);
 227 }
 228 
 229 double G1Analytics::predict_scan_hcc_ms() const {
 230   return get_new_prediction(_cost_scan_hcc_seq);
 231 }
 232 
 233 double G1Analytics::predict_rs_update_time_ms(size_t pending_cards) const {
 234   return pending_cards * predict_cost_per_log_buffer_entry_ms() + predict_scan_hcc_ms();
 235 }
 236 
 237 double G1Analytics::predict_young_cards_per_entry_ratio() const {
 238   return get_new_prediction(_young_cards_per_entry_ratio_seq);
 239 }
 240 
 241 double G1Analytics::predict_mixed_cards_per_entry_ratio() const {
 242   if (_mixed_cards_per_entry_ratio_seq->num() < 2) {
 243     return predict_young_cards_per_entry_ratio();
 244   } else {
 245     return get_new_prediction(_mixed_cards_per_entry_ratio_seq);
 246   }
 247 }
 248 
 249 size_t G1Analytics::predict_card_num(size_t rs_length, bool for_young_gc) const {
 250   if (for_young_gc) {
 251     return (size_t) (rs_length * predict_young_cards_per_entry_ratio());
 252   } else {
 253     return (size_t) (rs_length * predict_mixed_cards_per_entry_ratio());
 254   }


   1 /*
   2  * Copyright (c) 2016, 2019, 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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc/g1/g1Analytics.hpp"
  27 #include "gc/g1/g1Predictions.hpp"
  28 #include "runtime/os.hpp"
  29 #include "utilities/debug.hpp"
  30 #include "utilities/numberSeq.hpp"
  31 
  32 // Different defaults for different number of GC threads
  33 // They were chosen by running GCOld and SPECjbb on debris with different
  34 //   numbers of GC threads and choosing them based on the results
  35 
  36 // all the same
  37 static double rs_length_diff_defaults[] = {
  38   0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
  39 };
  40 
  41 static double cost_per_logged_card_ms_defaults[] = {
  42   0.01, 0.005, 0.005, 0.003, 0.003, 0.002, 0.002, 0.0015
  43 };
  44 
  45 // all the same
  46 static double young_cards_per_entry_ratio_defaults[] = {
  47   1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0
  48 };
  49 
  50 static double young_only_cost_per_remset_card_ms_defaults[] = {
  51   0.015, 0.01, 0.01, 0.008, 0.008, 0.0055, 0.0055, 0.005
  52 };
  53 
  54 static double cost_per_byte_ms_defaults[] = {
  55   0.00006, 0.00003, 0.00003, 0.000015, 0.000015, 0.00001, 0.00001, 0.000009
  56 };
  57 
  58 // these should be pretty consistent
  59 static double constant_other_time_ms_defaults[] = {
  60   5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0
  61 };
  62 
  63 
  64 static double young_other_cost_per_region_ms_defaults[] = {
  65   0.3, 0.2, 0.2, 0.15, 0.15, 0.12, 0.12, 0.1
  66 };
  67 
  68 static double non_young_other_cost_per_region_ms_defaults[] = {
  69   1.0, 0.7, 0.7, 0.5, 0.5, 0.42, 0.42, 0.30
  70 };
  71 
  72 G1Analytics::G1Analytics(const G1Predictions* predictor) :
  73     _predictor(predictor),
  74     _recent_gc_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)),
  75     _concurrent_mark_remark_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)),
  76     _concurrent_mark_cleanup_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)),
  77     _alloc_rate_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
  78     _prev_collection_pause_end_ms(0.0),
  79     _rs_length_diff_seq(new TruncatedSeq(TruncatedSeqLength)),
  80     _cost_per_logged_card_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
  81     _cost_scan_hcc_seq(new TruncatedSeq(TruncatedSeqLength)),
  82     _young_cards_per_entry_ratio_seq(new TruncatedSeq(TruncatedSeqLength)),
  83     _mixed_cards_per_entry_ratio_seq(new TruncatedSeq(TruncatedSeqLength)),
  84     _young_only_cost_per_remset_card_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
  85     _mixed_cost_per_remset_card_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
  86     _cost_per_byte_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
  87     _constant_other_time_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
  88     _young_other_cost_per_region_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
  89     _non_young_other_cost_per_region_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
  90     _pending_cards_seq(new TruncatedSeq(TruncatedSeqLength)),
  91     _rs_length_seq(new TruncatedSeq(TruncatedSeqLength)),
  92     _cost_per_byte_ms_during_cm_seq(new TruncatedSeq(TruncatedSeqLength)),
  93     _recent_prev_end_times_for_all_gcs_sec(new TruncatedSeq(NumPrevPausesForHeuristics)),
  94     _recent_avg_pause_time_ratio(0.0),
  95     _last_pause_time_ratio(0.0) {
  96 
  97   // Seed sequences with initial values.
  98   _recent_prev_end_times_for_all_gcs_sec->add(os::elapsedTime());
  99   _prev_collection_pause_end_ms = os::elapsedTime() * 1000.0;
 100 
 101   int index = MIN2(ParallelGCThreads - 1, 7u);
 102 
 103   _rs_length_diff_seq->add(rs_length_diff_defaults[index]);
 104   _cost_per_logged_card_ms_seq->add(cost_per_logged_card_ms_defaults[index]);
 105   _cost_scan_hcc_seq->add(0.0);
 106   _young_cards_per_entry_ratio_seq->add(young_cards_per_entry_ratio_defaults[index]);
 107   _young_only_cost_per_remset_card_ms_seq->add(young_only_cost_per_remset_card_ms_defaults[index]);
 108   _cost_per_byte_ms_seq->add(cost_per_byte_ms_defaults[index]);
 109   _constant_other_time_ms_seq->add(constant_other_time_ms_defaults[index]);
 110   _young_other_cost_per_region_ms_seq->add(young_other_cost_per_region_ms_defaults[index]);
 111   _non_young_other_cost_per_region_ms_seq->add(non_young_other_cost_per_region_ms_defaults[index]);
 112 
 113   // start conservatively (around 50ms is about right)
 114   _concurrent_mark_remark_times_ms->add(0.05);
 115   _concurrent_mark_cleanup_times_ms->add(0.20);
 116 }
 117 
 118 double G1Analytics::get_new_prediction(TruncatedSeq const* seq) const {
 119   return _predictor->get_new_prediction(seq);
 120 }
 121 
 122 size_t G1Analytics::get_new_size_prediction(TruncatedSeq const* seq) const {
 123   return (size_t)get_new_prediction(seq);
 124 }


 141       (_recent_avg_pause_time_ratio - 1.0 > 0.0)) {
 142     // Clip ratio between 0.0 and 1.0, and continue. This will be fixed in
 143     // CR 6902692 by redoing the manner in which the ratio is incrementally computed.
 144     if (_recent_avg_pause_time_ratio < 0.0) {
 145       _recent_avg_pause_time_ratio = 0.0;
 146     } else {
 147       assert(_recent_avg_pause_time_ratio - 1.0 > 0.0, "Ctl-point invariant");
 148       _recent_avg_pause_time_ratio = 1.0;
 149     }
 150   }
 151 
 152   // Compute the ratio of just this last pause time to the entire time range stored
 153   // in the vectors. Comparing this pause to the entire range, rather than only the
 154   // most recent interval, has the effect of smoothing over a possible transient 'burst'
 155   // of more frequent pauses that don't really reflect a change in heap occupancy.
 156   // This reduces the likelihood of a needless heap expansion being triggered.
 157   _last_pause_time_ratio =
 158     (pause_time_ms * _recent_prev_end_times_for_all_gcs_sec->num()) / interval_ms;
 159 }
 160 
 161 void G1Analytics::report_cost_per_logged_card_ms(double cost_per_logged_card_ms) {
 162   _cost_per_logged_card_ms_seq->add(cost_per_logged_card_ms);
 163 }
 164 
 165 void G1Analytics::report_cost_scan_hcc(double cost_scan_hcc) {
 166   _cost_scan_hcc_seq->add(cost_scan_hcc);
 167 }
 168 
 169 void G1Analytics::report_cost_per_remset_card_ms(double cost_per_remset_card_ms, bool for_young_gc) {
 170   if (for_young_gc) {
 171     _young_only_cost_per_remset_card_ms_seq->add(cost_per_remset_card_ms);
 172   } else {
 173     _mixed_cost_per_remset_card_ms_seq->add(cost_per_remset_card_ms);
 174   }
 175 }
 176 
 177 void G1Analytics::report_cards_per_entry_ratio(double cards_per_entry_ratio, bool for_young_gc) {
 178   if (for_young_gc) {
 179     _young_cards_per_entry_ratio_seq->add(cards_per_entry_ratio);
 180   } else {
 181     _mixed_cards_per_entry_ratio_seq->add(cards_per_entry_ratio);
 182   }


 205 void G1Analytics::report_constant_other_time_ms(double constant_other_time_ms) {
 206   _constant_other_time_ms_seq->add(constant_other_time_ms);
 207 }
 208 
 209 void G1Analytics::report_pending_cards(double pending_cards) {
 210   _pending_cards_seq->add(pending_cards);
 211 }
 212 
 213 void G1Analytics::report_rs_length(double rs_length) {
 214   _rs_length_seq->add(rs_length);
 215 }
 216 
 217 size_t G1Analytics::predict_rs_length_diff() const {
 218   return get_new_size_prediction(_rs_length_diff_seq);
 219 }
 220 
 221 double G1Analytics::predict_alloc_rate_ms() const {
 222   return get_new_prediction(_alloc_rate_ms_seq);
 223 }
 224 
 225 double G1Analytics::predict_cost_per_logged_card_ms() const {
 226   return get_new_prediction(_cost_per_logged_card_ms_seq);
 227 }
 228 
 229 double G1Analytics::predict_scan_hcc_ms() const {
 230   return get_new_prediction(_cost_scan_hcc_seq);
 231 }
 232 
 233 double G1Analytics::predict_rs_update_time_ms(size_t pending_cards) const {
 234   return pending_cards * predict_cost_per_logged_card_ms() + predict_scan_hcc_ms();
 235 }
 236 
 237 double G1Analytics::predict_young_cards_per_entry_ratio() const {
 238   return get_new_prediction(_young_cards_per_entry_ratio_seq);
 239 }
 240 
 241 double G1Analytics::predict_mixed_cards_per_entry_ratio() const {
 242   if (_mixed_cards_per_entry_ratio_seq->num() < 2) {
 243     return predict_young_cards_per_entry_ratio();
 244   } else {
 245     return get_new_prediction(_mixed_cards_per_entry_ratio_seq);
 246   }
 247 }
 248 
 249 size_t G1Analytics::predict_card_num(size_t rs_length, bool for_young_gc) const {
 250   if (for_young_gc) {
 251     return (size_t) (rs_length * predict_young_cards_per_entry_ratio());
 252   } else {
 253     return (size_t) (rs_length * predict_mixed_cards_per_entry_ratio());
 254   }


< prev index next >