src/hotspot/share/gc/g1/g1Analytics.cpp
changeset 59319 9ee940f1de90
parent 59222 f4f60bb75ee4
child 59320 11ff4e485670
equal deleted inserted replaced
59318:70021dbed82b 59319:9ee940f1de90
    43 static double cost_per_logged_card_ms_defaults[] = {
    43 static double cost_per_logged_card_ms_defaults[] = {
    44   0.01, 0.005, 0.005, 0.003, 0.003, 0.002, 0.002, 0.0015
    44   0.01, 0.005, 0.005, 0.003, 0.003, 0.002, 0.002, 0.0015
    45 };
    45 };
    46 
    46 
    47 // all the same
    47 // all the same
    48 static double young_cards_per_entry_ratio_defaults[] = {
    48 static double young_card_merge_to_scan_ratio_defaults[] = {
    49   1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0
    49   1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0
    50 };
    50 };
    51 
    51 
    52 static double young_only_cost_per_remset_card_ms_defaults[] = {
    52 static double young_only_cost_per_card_scan_ms_defaults[] = {
    53   0.015, 0.01, 0.01, 0.008, 0.008, 0.0055, 0.0055, 0.005
    53   0.015, 0.01, 0.01, 0.008, 0.008, 0.0055, 0.0055, 0.005
    54 };
    54 };
    55 
    55 
    56 static double cost_per_byte_ms_defaults[] = {
    56 static double cost_per_byte_ms_defaults[] = {
    57   0.00006, 0.00003, 0.00003, 0.000015, 0.000015, 0.00001, 0.00001, 0.000009
    57   0.00006, 0.00003, 0.00003, 0.000015, 0.000015, 0.00001, 0.00001, 0.000009
    59 
    59 
    60 // these should be pretty consistent
    60 // these should be pretty consistent
    61 static double constant_other_time_ms_defaults[] = {
    61 static double constant_other_time_ms_defaults[] = {
    62   5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0
    62   5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0
    63 };
    63 };
    64 
       
    65 
    64 
    66 static double young_other_cost_per_region_ms_defaults[] = {
    65 static double young_other_cost_per_region_ms_defaults[] = {
    67   0.3, 0.2, 0.2, 0.15, 0.15, 0.12, 0.12, 0.1
    66   0.3, 0.2, 0.2, 0.15, 0.15, 0.12, 0.12, 0.1
    68 };
    67 };
    69 
    68 
    79     _alloc_rate_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
    78     _alloc_rate_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
    80     _prev_collection_pause_end_ms(0.0),
    79     _prev_collection_pause_end_ms(0.0),
    81     _rs_length_diff_seq(new TruncatedSeq(TruncatedSeqLength)),
    80     _rs_length_diff_seq(new TruncatedSeq(TruncatedSeqLength)),
    82     _concurrent_refine_rate_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
    81     _concurrent_refine_rate_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
    83     _logged_cards_rate_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
    82     _logged_cards_rate_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
    84     _cost_per_logged_card_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
    83     _young_card_merge_to_scan_ratio_seq(new TruncatedSeq(TruncatedSeqLength)),
    85     _cost_scan_hcc_seq(new TruncatedSeq(TruncatedSeqLength)),
    84     _mixed_card_merge_to_scan_ratio_seq(new TruncatedSeq(TruncatedSeqLength)),
    86     _young_cards_per_entry_ratio_seq(new TruncatedSeq(TruncatedSeqLength)),
    85     _young_cost_per_card_scan_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
    87     _mixed_cards_per_entry_ratio_seq(new TruncatedSeq(TruncatedSeqLength)),
    86     _mixed_cost_per_card_scan_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
    88     _young_only_cost_per_remset_card_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
    87     _young_cost_per_card_merge_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
    89     _mixed_cost_per_remset_card_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
    88     _mixed_cost_per_card_merge_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
    90     _cost_per_byte_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
    89     _copy_cost_per_byte_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
    91     _constant_other_time_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
    90     _constant_other_time_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
    92     _young_other_cost_per_region_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
    91     _young_other_cost_per_region_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
    93     _non_young_other_cost_per_region_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
    92     _non_young_other_cost_per_region_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
    94     _pending_cards_seq(new TruncatedSeq(TruncatedSeqLength)),
    93     _pending_cards_seq(new TruncatedSeq(TruncatedSeqLength)),
    95     _rs_length_seq(new TruncatedSeq(TruncatedSeqLength)),
    94     _rs_length_seq(new TruncatedSeq(TruncatedSeqLength)),
   107   _rs_length_diff_seq->add(rs_length_diff_defaults[index]);
   106   _rs_length_diff_seq->add(rs_length_diff_defaults[index]);
   108   // Start with inverse of maximum STW cost.
   107   // Start with inverse of maximum STW cost.
   109   _concurrent_refine_rate_ms_seq->add(1/cost_per_logged_card_ms_defaults[0]);
   108   _concurrent_refine_rate_ms_seq->add(1/cost_per_logged_card_ms_defaults[0]);
   110   // Some applications have very low rates for logging cards.
   109   // Some applications have very low rates for logging cards.
   111   _logged_cards_rate_ms_seq->add(0.0);
   110   _logged_cards_rate_ms_seq->add(0.0);
   112   _cost_per_logged_card_ms_seq->add(cost_per_logged_card_ms_defaults[index]);
   111   _young_card_merge_to_scan_ratio_seq->add(young_card_merge_to_scan_ratio_defaults[index]);
   113   _cost_scan_hcc_seq->add(0.0);
   112   _young_cost_per_card_scan_ms_seq->add(young_only_cost_per_card_scan_ms_defaults[index]);
   114   _young_cards_per_entry_ratio_seq->add(young_cards_per_entry_ratio_defaults[index]);
   113 
   115   _young_only_cost_per_remset_card_ms_seq->add(young_only_cost_per_remset_card_ms_defaults[index]);
   114   _copy_cost_per_byte_ms_seq->add(cost_per_byte_ms_defaults[index]);
   116   _cost_per_byte_ms_seq->add(cost_per_byte_ms_defaults[index]);
       
   117   _constant_other_time_ms_seq->add(constant_other_time_ms_defaults[index]);
   115   _constant_other_time_ms_seq->add(constant_other_time_ms_defaults[index]);
   118   _young_other_cost_per_region_ms_seq->add(young_other_cost_per_region_ms_defaults[index]);
   116   _young_other_cost_per_region_ms_seq->add(young_other_cost_per_region_ms_defaults[index]);
   119   _non_young_other_cost_per_region_ms_seq->add(non_young_other_cost_per_region_ms_defaults[index]);
   117   _non_young_other_cost_per_region_ms_seq->add(non_young_other_cost_per_region_ms_defaults[index]);
   120 
   118 
   121   // start conservatively (around 50ms is about right)
   119   // start conservatively (around 50ms is about right)
   122   _concurrent_mark_remark_times_ms->add(0.05);
   120   _concurrent_mark_remark_times_ms->add(0.05);
   123   _concurrent_mark_cleanup_times_ms->add(0.20);
   121   _concurrent_mark_cleanup_times_ms->add(0.20);
       
   122 }
       
   123 
       
   124 bool G1Analytics::enough_samples_available(TruncatedSeq const* seq) const {
       
   125   return seq->num() >= 3;
   124 }
   126 }
   125 
   127 
   126 double G1Analytics::get_new_prediction(TruncatedSeq const* seq) const {
   128 double G1Analytics::get_new_prediction(TruncatedSeq const* seq) const {
   127   return _predictor->get_new_prediction(seq);
   129   return _predictor->get_new_prediction(seq);
   128 }
   130 }
   164 
   166 
   165 void G1Analytics::report_logged_cards_rate_ms(double cards_per_ms) {
   167 void G1Analytics::report_logged_cards_rate_ms(double cards_per_ms) {
   166   _logged_cards_rate_ms_seq->add(cards_per_ms);
   168   _logged_cards_rate_ms_seq->add(cards_per_ms);
   167 }
   169 }
   168 
   170 
   169 void G1Analytics::report_cost_per_logged_card_ms(double cost_per_logged_card_ms) {
   171 void G1Analytics::report_cost_per_card_scan_ms(double cost_per_card_ms, bool for_young_gc) {
   170   _cost_per_logged_card_ms_seq->add(cost_per_logged_card_ms);
       
   171 }
       
   172 
       
   173 void G1Analytics::report_cost_scan_hcc(double cost_scan_hcc) {
       
   174   _cost_scan_hcc_seq->add(cost_scan_hcc);
       
   175 }
       
   176 
       
   177 void G1Analytics::report_cost_per_remset_card_ms(double cost_per_remset_card_ms, bool for_young_gc) {
       
   178   if (for_young_gc) {
   172   if (for_young_gc) {
   179     _young_only_cost_per_remset_card_ms_seq->add(cost_per_remset_card_ms);
   173     _young_cost_per_card_scan_ms_seq->add(cost_per_card_ms);
   180   } else {
   174   } else {
   181     _mixed_cost_per_remset_card_ms_seq->add(cost_per_remset_card_ms);
   175     _mixed_cost_per_card_scan_ms_seq->add(cost_per_card_ms);
   182   }
   176   }
   183 }
   177 }
   184 
   178 
   185 void G1Analytics::report_cards_per_entry_ratio(double cards_per_entry_ratio, bool for_young_gc) {
   179 void G1Analytics::report_cost_per_card_merge_ms(double cost_per_card_ms, bool for_young_gc) {
   186   if (for_young_gc) {
   180   if (for_young_gc) {
   187     _young_cards_per_entry_ratio_seq->add(cards_per_entry_ratio);
   181     _young_cost_per_card_merge_ms_seq->add(cost_per_card_ms);
   188   } else {
   182   } else {
   189     _mixed_cards_per_entry_ratio_seq->add(cards_per_entry_ratio);
   183     _mixed_cost_per_card_merge_ms_seq->add(cost_per_card_ms);
       
   184   }
       
   185 }
       
   186 
       
   187 void G1Analytics::report_card_merge_to_scan_ratio(double merge_to_scan_ratio, bool for_young_gc) {
       
   188   if (for_young_gc) {
       
   189     _young_card_merge_to_scan_ratio_seq->add(merge_to_scan_ratio);
       
   190   } else {
       
   191     _mixed_card_merge_to_scan_ratio_seq->add(merge_to_scan_ratio);
   190   }
   192   }
   191 }
   193 }
   192 
   194 
   193 void G1Analytics::report_rs_length_diff(double rs_length_diff) {
   195 void G1Analytics::report_rs_length_diff(double rs_length_diff) {
   194   _rs_length_diff_seq->add(rs_length_diff);
   196   _rs_length_diff_seq->add(rs_length_diff);
   196 
   198 
   197 void G1Analytics::report_cost_per_byte_ms(double cost_per_byte_ms, bool mark_or_rebuild_in_progress) {
   199 void G1Analytics::report_cost_per_byte_ms(double cost_per_byte_ms, bool mark_or_rebuild_in_progress) {
   198   if (mark_or_rebuild_in_progress) {
   200   if (mark_or_rebuild_in_progress) {
   199     _cost_per_byte_ms_during_cm_seq->add(cost_per_byte_ms);
   201     _cost_per_byte_ms_during_cm_seq->add(cost_per_byte_ms);
   200   } else {
   202   } else {
   201     _cost_per_byte_ms_seq->add(cost_per_byte_ms);
   203     _copy_cost_per_byte_ms_seq->add(cost_per_byte_ms);
   202   }
   204   }
   203 }
   205 }
   204 
   206 
   205 void G1Analytics::report_young_other_cost_per_region_ms(double other_cost_per_region_ms) {
   207 void G1Analytics::report_young_other_cost_per_region_ms(double other_cost_per_region_ms) {
   206   _young_other_cost_per_region_ms_seq->add(other_cost_per_region_ms);
   208   _young_other_cost_per_region_ms_seq->add(other_cost_per_region_ms);
   232 
   234 
   233 double G1Analytics::predict_logged_cards_rate_ms() const {
   235 double G1Analytics::predict_logged_cards_rate_ms() const {
   234   return get_new_prediction(_logged_cards_rate_ms_seq);
   236   return get_new_prediction(_logged_cards_rate_ms_seq);
   235 }
   237 }
   236 
   238 
   237 double G1Analytics::predict_cost_per_logged_card_ms() const {
   239 double G1Analytics::predict_young_card_merge_to_scan_ratio() const {
   238   return get_new_prediction(_cost_per_logged_card_ms_seq);
   240   return get_new_prediction(_young_card_merge_to_scan_ratio_seq);
   239 }
   241 }
   240 
   242 
   241 double G1Analytics::predict_scan_hcc_ms() const {
   243 size_t G1Analytics::predict_scan_card_num(size_t rs_length, bool for_young_gc) const {
   242   return get_new_prediction(_cost_scan_hcc_seq);
   244   if (for_young_gc || !enough_samples_available(_mixed_card_merge_to_scan_ratio_seq)) {
   243 }
   245     return (size_t) (rs_length * predict_young_card_merge_to_scan_ratio());
   244 
   246   } else {
   245 double G1Analytics::predict_rs_update_time_ms(size_t pending_cards) const {
   247     return (size_t) (rs_length * get_new_prediction(_mixed_card_merge_to_scan_ratio_seq));
   246   return pending_cards * predict_cost_per_logged_card_ms() + predict_scan_hcc_ms();
   248   }
   247 }
   249 }
   248 
   250 
   249 double G1Analytics::predict_young_cards_per_entry_ratio() const {
   251 double G1Analytics::predict_card_merge_time_ms(size_t card_num, bool for_young_gc) const {
   250   return get_new_prediction(_young_cards_per_entry_ratio_seq);
   252   if (for_young_gc || !enough_samples_available(_mixed_cost_per_card_merge_ms_seq)) {
   251 }
   253     return card_num * get_new_prediction(_young_cost_per_card_merge_ms_seq);
   252 
   254   } else {
   253 double G1Analytics::predict_mixed_cards_per_entry_ratio() const {
   255     return card_num * get_new_prediction(_mixed_cost_per_card_merge_ms_seq);
   254   if (_mixed_cards_per_entry_ratio_seq->num() < 2) {
   256   }
   255     return predict_young_cards_per_entry_ratio();
   257 }
   256   } else {
   258 
   257     return get_new_prediction(_mixed_cards_per_entry_ratio_seq);
   259 double G1Analytics::predict_card_scan_time_ms(size_t card_num, bool for_young_gc) const {
   258   }
   260   if (for_young_gc || !enough_samples_available(_mixed_cost_per_card_scan_ms_seq)) {
   259 }
   261     return card_num * get_new_prediction(_young_cost_per_card_scan_ms_seq);
   260 
   262   } else {
   261 size_t G1Analytics::predict_card_num(size_t rs_length, bool for_young_gc) const {
   263     return card_num * get_new_prediction(_mixed_cost_per_card_scan_ms_seq);
   262   if (for_young_gc) {
       
   263     return (size_t) (rs_length * predict_young_cards_per_entry_ratio());
       
   264   } else {
       
   265     return (size_t) (rs_length * predict_mixed_cards_per_entry_ratio());
       
   266   }
       
   267 }
       
   268 
       
   269 double G1Analytics::predict_rs_scan_time_ms(size_t card_num, bool for_young_gc) const {
       
   270   if (for_young_gc) {
       
   271     return card_num * get_new_prediction(_young_only_cost_per_remset_card_ms_seq);
       
   272   } else {
       
   273     return predict_mixed_rs_scan_time_ms(card_num);
       
   274   }
       
   275 }
       
   276 
       
   277 double G1Analytics::predict_mixed_rs_scan_time_ms(size_t card_num) const {
       
   278   if (_mixed_cost_per_remset_card_ms_seq->num() < 3) {
       
   279     return card_num * get_new_prediction(_young_only_cost_per_remset_card_ms_seq);
       
   280   } else {
       
   281     return card_num * get_new_prediction(_mixed_cost_per_remset_card_ms_seq);
       
   282   }
   264   }
   283 }
   265 }
   284 
   266 
   285 double G1Analytics::predict_object_copy_time_ms_during_cm(size_t bytes_to_copy) const {
   267 double G1Analytics::predict_object_copy_time_ms_during_cm(size_t bytes_to_copy) const {
   286   if (_cost_per_byte_ms_during_cm_seq->num() < 3) {
   268   if (!enough_samples_available(_cost_per_byte_ms_during_cm_seq)) {
   287     return (1.1 * bytes_to_copy) * get_new_prediction(_cost_per_byte_ms_seq);
   269     return (1.1 * bytes_to_copy) * get_new_prediction(_copy_cost_per_byte_ms_seq);
   288   } else {
   270   } else {
   289     return bytes_to_copy * get_new_prediction(_cost_per_byte_ms_during_cm_seq);
   271     return bytes_to_copy * get_new_prediction(_cost_per_byte_ms_during_cm_seq);
   290   }
   272   }
   291 }
   273 }
   292 
   274 
   293 double G1Analytics::predict_object_copy_time_ms(size_t bytes_to_copy, bool during_concurrent_mark) const {
   275 double G1Analytics::predict_object_copy_time_ms(size_t bytes_to_copy, bool during_concurrent_mark) const {
   294   if (during_concurrent_mark) {
   276   if (during_concurrent_mark) {
   295     return predict_object_copy_time_ms_during_cm(bytes_to_copy);
   277     return predict_object_copy_time_ms_during_cm(bytes_to_copy);
   296   } else {
   278   } else {
   297     return bytes_to_copy * get_new_prediction(_cost_per_byte_ms_seq);
   279     return bytes_to_copy * get_new_prediction(_copy_cost_per_byte_ms_seq);
   298   }
   280   }
   299 }
       
   300 
       
   301 double G1Analytics::predict_cost_per_byte_ms() const {
       
   302   return get_new_prediction(_cost_per_byte_ms_seq);
       
   303 }
   281 }
   304 
   282 
   305 double G1Analytics::predict_constant_other_time_ms() const {
   283 double G1Analytics::predict_constant_other_time_ms() const {
   306   return get_new_prediction(_constant_other_time_ms_seq);
   284   return get_new_prediction(_constant_other_time_ms_seq);
   307 }
   285 }