1 /* |
1 /* |
2 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. |
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. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
23 */ |
23 */ |
24 |
24 |
25 #include "precompiled.hpp" |
25 #include "precompiled.hpp" |
26 #include "gc/g1/g1Analytics.hpp" |
26 #include "gc/g1/g1Analytics.hpp" |
27 #include "gc/g1/g1Predictions.hpp" |
27 #include "gc/g1/g1Predictions.hpp" |
|
28 #include "runtime/globals.hpp" |
28 #include "runtime/os.hpp" |
29 #include "runtime/os.hpp" |
29 #include "utilities/debug.hpp" |
30 #include "utilities/debug.hpp" |
30 #include "utilities/numberSeq.hpp" |
31 #include "utilities/numberSeq.hpp" |
31 |
32 |
32 // Different defaults for different number of GC threads |
33 // Different defaults for different number of GC threads |
36 // all the same |
37 // all the same |
37 static double rs_length_diff_defaults[] = { |
38 static double rs_length_diff_defaults[] = { |
38 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 |
39 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 |
39 }; |
40 }; |
40 |
41 |
41 static double cost_per_card_ms_defaults[] = { |
42 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 0.01, 0.005, 0.005, 0.003, 0.003, 0.002, 0.002, 0.0015 |
43 }; |
44 }; |
44 |
45 |
45 // all the same |
46 // all the same |
46 static double young_cards_per_entry_ratio_defaults[] = { |
47 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 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 |
48 }; |
49 }; |
49 |
50 |
50 static double cost_per_entry_ms_defaults[] = { |
51 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 0.015, 0.01, 0.01, 0.008, 0.008, 0.0055, 0.0055, 0.005 |
52 }; |
53 }; |
53 |
54 |
54 static double cost_per_byte_ms_defaults[] = { |
55 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 0.00006, 0.00003, 0.00003, 0.000015, 0.000015, 0.00001, 0.00001, 0.000009 |
75 _concurrent_mark_remark_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)), |
76 _concurrent_mark_remark_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)), |
76 _concurrent_mark_cleanup_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)), |
77 _concurrent_mark_cleanup_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)), |
77 _alloc_rate_ms_seq(new TruncatedSeq(TruncatedSeqLength)), |
78 _alloc_rate_ms_seq(new TruncatedSeq(TruncatedSeqLength)), |
78 _prev_collection_pause_end_ms(0.0), |
79 _prev_collection_pause_end_ms(0.0), |
79 _rs_length_diff_seq(new TruncatedSeq(TruncatedSeqLength)), |
80 _rs_length_diff_seq(new TruncatedSeq(TruncatedSeqLength)), |
80 _cost_per_card_ms_seq(new TruncatedSeq(TruncatedSeqLength)), |
81 _concurrent_refine_rate_ms_seq(new TruncatedSeq(TruncatedSeqLength)), |
|
82 _logged_cards_rate_ms_seq(new TruncatedSeq(TruncatedSeqLength)), |
|
83 _cost_per_logged_card_ms_seq(new TruncatedSeq(TruncatedSeqLength)), |
81 _cost_scan_hcc_seq(new TruncatedSeq(TruncatedSeqLength)), |
84 _cost_scan_hcc_seq(new TruncatedSeq(TruncatedSeqLength)), |
82 _young_cards_per_entry_ratio_seq(new TruncatedSeq(TruncatedSeqLength)), |
85 _young_cards_per_entry_ratio_seq(new TruncatedSeq(TruncatedSeqLength)), |
83 _mixed_cards_per_entry_ratio_seq(new TruncatedSeq(TruncatedSeqLength)), |
86 _mixed_cards_per_entry_ratio_seq(new TruncatedSeq(TruncatedSeqLength)), |
84 _cost_per_entry_ms_seq(new TruncatedSeq(TruncatedSeqLength)), |
87 _young_only_cost_per_remset_card_ms_seq(new TruncatedSeq(TruncatedSeqLength)), |
85 _mixed_cost_per_entry_ms_seq(new TruncatedSeq(TruncatedSeqLength)), |
88 _mixed_cost_per_remset_card_ms_seq(new TruncatedSeq(TruncatedSeqLength)), |
86 _cost_per_byte_ms_seq(new TruncatedSeq(TruncatedSeqLength)), |
89 _cost_per_byte_ms_seq(new TruncatedSeq(TruncatedSeqLength)), |
87 _constant_other_time_ms_seq(new TruncatedSeq(TruncatedSeqLength)), |
90 _constant_other_time_ms_seq(new TruncatedSeq(TruncatedSeqLength)), |
88 _young_other_cost_per_region_ms_seq(new TruncatedSeq(TruncatedSeqLength)), |
91 _young_other_cost_per_region_ms_seq(new TruncatedSeq(TruncatedSeqLength)), |
89 _non_young_other_cost_per_region_ms_seq(new TruncatedSeq(TruncatedSeqLength)), |
92 _non_young_other_cost_per_region_ms_seq(new TruncatedSeq(TruncatedSeqLength)), |
90 _pending_cards_seq(new TruncatedSeq(TruncatedSeqLength)), |
93 _pending_cards_seq(new TruncatedSeq(TruncatedSeqLength)), |
91 _rs_lengths_seq(new TruncatedSeq(TruncatedSeqLength)), |
94 _rs_length_seq(new TruncatedSeq(TruncatedSeqLength)), |
92 _cost_per_byte_ms_during_cm_seq(new TruncatedSeq(TruncatedSeqLength)), |
95 _cost_per_byte_ms_during_cm_seq(new TruncatedSeq(TruncatedSeqLength)), |
93 _recent_prev_end_times_for_all_gcs_sec(new TruncatedSeq(NumPrevPausesForHeuristics)), |
96 _recent_prev_end_times_for_all_gcs_sec(new TruncatedSeq(NumPrevPausesForHeuristics)), |
94 _recent_avg_pause_time_ratio(0.0), |
97 _recent_avg_pause_time_ratio(0.0), |
95 _last_pause_time_ratio(0.0) { |
98 _last_pause_time_ratio(0.0) { |
96 |
99 |
99 _prev_collection_pause_end_ms = os::elapsedTime() * 1000.0; |
102 _prev_collection_pause_end_ms = os::elapsedTime() * 1000.0; |
100 |
103 |
101 int index = MIN2(ParallelGCThreads - 1, 7u); |
104 int index = MIN2(ParallelGCThreads - 1, 7u); |
102 |
105 |
103 _rs_length_diff_seq->add(rs_length_diff_defaults[index]); |
106 _rs_length_diff_seq->add(rs_length_diff_defaults[index]); |
104 _cost_per_card_ms_seq->add(cost_per_card_ms_defaults[index]); |
107 // Start with inverse of maximum STW cost. |
|
108 _concurrent_refine_rate_ms_seq->add(1/cost_per_logged_card_ms_defaults[0]); |
|
109 // Some applications have very low rates for logging cards. |
|
110 _logged_cards_rate_ms_seq->add(0.0); |
|
111 _cost_per_logged_card_ms_seq->add(cost_per_logged_card_ms_defaults[index]); |
105 _cost_scan_hcc_seq->add(0.0); |
112 _cost_scan_hcc_seq->add(0.0); |
106 _young_cards_per_entry_ratio_seq->add(young_cards_per_entry_ratio_defaults[index]); |
113 _young_cards_per_entry_ratio_seq->add(young_cards_per_entry_ratio_defaults[index]); |
107 _cost_per_entry_ms_seq->add(cost_per_entry_ms_defaults[index]); |
114 _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]); |
115 _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]); |
116 _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]); |
117 _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]); |
118 _non_young_other_cost_per_region_ms_seq->add(non_young_other_cost_per_region_ms_defaults[index]); |
112 |
119 |
156 // This reduces the likelihood of a needless heap expansion being triggered. |
163 // This reduces the likelihood of a needless heap expansion being triggered. |
157 _last_pause_time_ratio = |
164 _last_pause_time_ratio = |
158 (pause_time_ms * _recent_prev_end_times_for_all_gcs_sec->num()) / interval_ms; |
165 (pause_time_ms * _recent_prev_end_times_for_all_gcs_sec->num()) / interval_ms; |
159 } |
166 } |
160 |
167 |
161 void G1Analytics::report_cost_per_card_ms(double cost_per_card_ms) { |
168 void G1Analytics::report_concurrent_refine_rate_ms(double cards_per_ms) { |
162 _cost_per_card_ms_seq->add(cost_per_card_ms); |
169 _concurrent_refine_rate_ms_seq->add(cards_per_ms); |
|
170 } |
|
171 |
|
172 void G1Analytics::report_logged_cards_rate_ms(double cards_per_ms) { |
|
173 _logged_cards_rate_ms_seq->add(cards_per_ms); |
|
174 } |
|
175 |
|
176 void G1Analytics::report_cost_per_logged_card_ms(double cost_per_logged_card_ms) { |
|
177 _cost_per_logged_card_ms_seq->add(cost_per_logged_card_ms); |
163 } |
178 } |
164 |
179 |
165 void G1Analytics::report_cost_scan_hcc(double cost_scan_hcc) { |
180 void G1Analytics::report_cost_scan_hcc(double cost_scan_hcc) { |
166 _cost_scan_hcc_seq->add(cost_scan_hcc); |
181 _cost_scan_hcc_seq->add(cost_scan_hcc); |
167 } |
182 } |
168 |
183 |
169 void G1Analytics::report_cost_per_entry_ms(double cost_per_entry_ms, bool for_young_gc) { |
184 void G1Analytics::report_cost_per_remset_card_ms(double cost_per_remset_card_ms, bool for_young_gc) { |
170 if (for_young_gc) { |
185 if (for_young_gc) { |
171 _cost_per_entry_ms_seq->add(cost_per_entry_ms); |
186 _young_only_cost_per_remset_card_ms_seq->add(cost_per_remset_card_ms); |
172 } else { |
187 } else { |
173 _mixed_cost_per_entry_ms_seq->add(cost_per_entry_ms); |
188 _mixed_cost_per_remset_card_ms_seq->add(cost_per_remset_card_ms); |
174 } |
189 } |
175 } |
190 } |
176 |
191 |
177 void G1Analytics::report_cards_per_entry_ratio(double cards_per_entry_ratio, bool for_young_gc) { |
192 void G1Analytics::report_cards_per_entry_ratio(double cards_per_entry_ratio, bool for_young_gc) { |
178 if (for_young_gc) { |
193 if (for_young_gc) { |
208 |
223 |
209 void G1Analytics::report_pending_cards(double pending_cards) { |
224 void G1Analytics::report_pending_cards(double pending_cards) { |
210 _pending_cards_seq->add(pending_cards); |
225 _pending_cards_seq->add(pending_cards); |
211 } |
226 } |
212 |
227 |
213 void G1Analytics::report_rs_lengths(double rs_lengths) { |
228 void G1Analytics::report_rs_length(double rs_length) { |
214 _rs_lengths_seq->add(rs_lengths); |
229 _rs_length_seq->add(rs_length); |
215 } |
230 } |
216 |
231 |
217 size_t G1Analytics::predict_rs_length_diff() const { |
232 size_t G1Analytics::predict_rs_length_diff() const { |
218 return get_new_size_prediction(_rs_length_diff_seq); |
233 return get_new_size_prediction(_rs_length_diff_seq); |
219 } |
234 } |
220 |
235 |
221 double G1Analytics::predict_alloc_rate_ms() const { |
236 double G1Analytics::predict_alloc_rate_ms() const { |
222 return get_new_prediction(_alloc_rate_ms_seq); |
237 return get_new_prediction(_alloc_rate_ms_seq); |
223 } |
238 } |
224 |
239 |
225 double G1Analytics::predict_cost_per_card_ms() const { |
240 double G1Analytics::predict_concurrent_refine_rate_ms() const { |
226 return get_new_prediction(_cost_per_card_ms_seq); |
241 return get_new_prediction(_concurrent_refine_rate_ms_seq); |
|
242 } |
|
243 |
|
244 double G1Analytics::predict_logged_cards_rate_ms() const { |
|
245 return get_new_prediction(_logged_cards_rate_ms_seq); |
|
246 } |
|
247 |
|
248 double G1Analytics::predict_cost_per_logged_card_ms() const { |
|
249 return get_new_prediction(_cost_per_logged_card_ms_seq); |
227 } |
250 } |
228 |
251 |
229 double G1Analytics::predict_scan_hcc_ms() const { |
252 double G1Analytics::predict_scan_hcc_ms() const { |
230 return get_new_prediction(_cost_scan_hcc_seq); |
253 return get_new_prediction(_cost_scan_hcc_seq); |
231 } |
254 } |
232 |
255 |
233 double G1Analytics::predict_rs_update_time_ms(size_t pending_cards) const { |
256 double G1Analytics::predict_rs_update_time_ms(size_t pending_cards) const { |
234 return pending_cards * predict_cost_per_card_ms() + predict_scan_hcc_ms(); |
257 return pending_cards * predict_cost_per_logged_card_ms() + predict_scan_hcc_ms(); |
235 } |
258 } |
236 |
259 |
237 double G1Analytics::predict_young_cards_per_entry_ratio() const { |
260 double G1Analytics::predict_young_cards_per_entry_ratio() const { |
238 return get_new_prediction(_young_cards_per_entry_ratio_seq); |
261 return get_new_prediction(_young_cards_per_entry_ratio_seq); |
239 } |
262 } |
254 } |
277 } |
255 } |
278 } |
256 |
279 |
257 double G1Analytics::predict_rs_scan_time_ms(size_t card_num, bool for_young_gc) const { |
280 double G1Analytics::predict_rs_scan_time_ms(size_t card_num, bool for_young_gc) const { |
258 if (for_young_gc) { |
281 if (for_young_gc) { |
259 return card_num * get_new_prediction(_cost_per_entry_ms_seq); |
282 return card_num * get_new_prediction(_young_only_cost_per_remset_card_ms_seq); |
260 } else { |
283 } else { |
261 return predict_mixed_rs_scan_time_ms(card_num); |
284 return predict_mixed_rs_scan_time_ms(card_num); |
262 } |
285 } |
263 } |
286 } |
264 |
287 |
265 double G1Analytics::predict_mixed_rs_scan_time_ms(size_t card_num) const { |
288 double G1Analytics::predict_mixed_rs_scan_time_ms(size_t card_num) const { |
266 if (_mixed_cost_per_entry_ms_seq->num() < 3) { |
289 if (_mixed_cost_per_remset_card_ms_seq->num() < 3) { |
267 return card_num * get_new_prediction(_cost_per_entry_ms_seq); |
290 return card_num * get_new_prediction(_young_only_cost_per_remset_card_ms_seq); |
268 } else { |
291 } else { |
269 return card_num * get_new_prediction(_mixed_cost_per_entry_ms_seq); |
292 return card_num * get_new_prediction(_mixed_cost_per_remset_card_ms_seq); |
270 } |
293 } |
271 } |
294 } |
272 |
295 |
273 double G1Analytics::predict_object_copy_time_ms_during_cm(size_t bytes_to_copy) const { |
296 double G1Analytics::predict_object_copy_time_ms_during_cm(size_t bytes_to_copy) const { |
274 if (_cost_per_byte_ms_during_cm_seq->num() < 3) { |
297 if (_cost_per_byte_ms_during_cm_seq->num() < 3) { |