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/g1Measurements.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_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[] = {
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 G1Measurements::G1Measurements(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_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 _cost_per_entry_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
85 _mixed_cost_per_entry_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
86 _cost_per_byte_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
87 _cost_per_byte_ms_during_cm_seq(new TruncatedSeq(TruncatedSeqLength)),
88 _constant_other_time_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
89 _young_other_cost_per_region_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
90 _non_young_other_cost_per_region_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
91 _pending_cards_seq(new TruncatedSeq(TruncatedSeqLength)),
92 _rs_lengths_seq(new TruncatedSeq(TruncatedSeqLength)),
93 _recent_prev_end_times_for_all_gcs_sec(new TruncatedSeq(NumPrevPausesForHeuristics)) {
94
95 // Seed sequences with initial values.
96 _recent_prev_end_times_for_all_gcs_sec->add(os::elapsedTime());
97 _prev_collection_pause_end_ms = os::elapsedTime() * 1000.0;
98
99 int index = MIN2(ParallelGCThreads - 1, 7u);
100
101 _rs_length_diff_seq->add(rs_length_diff_defaults[index]);
102 _cost_per_card_ms_seq->add(cost_per_card_ms_defaults[index]);
103 _cost_scan_hcc_seq->add(0.0);
104 _young_cards_per_entry_ratio_seq->add(
105 young_cards_per_entry_ratio_defaults[index]);
106 _cost_per_entry_ms_seq->add(cost_per_entry_ms_defaults[index]);
107 _cost_per_byte_ms_seq->add(cost_per_byte_ms_defaults[index]);
108 _constant_other_time_ms_seq->add(constant_other_time_ms_defaults[index]);
109 _young_other_cost_per_region_ms_seq->add(
110 young_other_cost_per_region_ms_defaults[index]);
111 _non_young_other_cost_per_region_ms_seq->add(
112 non_young_other_cost_per_region_ms_defaults[index]);
113
114 // start conservatively (around 50ms is about right)
115 _concurrent_mark_remark_times_ms->add(0.05);
116 _concurrent_mark_cleanup_times_ms->add(0.20);
117 }
118
119 double G1Measurements::get_new_prediction(TruncatedSeq const* seq) const {
120 return _predictor->get_new_prediction(seq);
121 }
122
123 size_t G1Measurements::get_new_size_prediction(TruncatedSeq const* seq) const {
124 return (size_t)get_new_prediction(seq);
125 }
126
127 int G1Measurements::num_alloc_rate_ms() const {
128 return _alloc_rate_ms_seq->num();
129 }
130
131 void G1Measurements::report_concurrent_mark_remark_times_ms(double ms) {
132 _concurrent_mark_remark_times_ms->add(ms);
133 }
134
135 void G1Measurements::report_alloc_rate_ms(double alloc_rate) {
136 _alloc_rate_ms_seq->add(alloc_rate);
137 }
138
139 void G1Measurements::compute_pause_time_ratio(double interval_ms, double pause_time_ms) {
140 _recent_avg_pause_time_ratio = _recent_gc_times_ms->sum() / interval_ms;
141 if (_recent_avg_pause_time_ratio < 0.0 ||
142 (_recent_avg_pause_time_ratio - 1.0 > 0.0)) {
143 // Clip ratio between 0.0 and 1.0, and continue. This will be fixed in
144 // CR 6902692 by redoing the manner in which the ratio is incrementally computed.
145 if (_recent_avg_pause_time_ratio < 0.0) {
146 _recent_avg_pause_time_ratio = 0.0;
147 } else {
148 assert(_recent_avg_pause_time_ratio - 1.0 > 0.0, "Ctl-point invariant");
149 _recent_avg_pause_time_ratio = 1.0;
150 }
151 }
152
153 // Compute the ratio of just this last pause time to the entire time range stored
154 // in the vectors. Comparing this pause to the entire range, rather than only the
155 // most recent interval, has the effect of smoothing over a possible transient 'burst'
156 // of more frequent pauses that don't really reflect a change in heap occupancy.
157 // This reduces the likelihood of a needless heap expansion being triggered.
158 _last_pause_time_ratio =
159 (pause_time_ms * _recent_prev_end_times_for_all_gcs_sec->num()) / interval_ms;
160 }
161
162 void G1Measurements::report_cost_per_card_ms(double cost_per_card_ms) {
163 _cost_per_card_ms_seq->add(cost_per_card_ms);
164 }
165
166 void G1Measurements::report_cost_scan_hcc(double cost_scan_hcc) {
167 _cost_scan_hcc_seq->add(cost_scan_hcc);
168 }
169
170 void G1Measurements::report_cost_per_entry_ms(double cost_per_entry_ms, bool last_gc_was_young) {
171 if (last_gc_was_young) {
172 _cost_per_entry_ms_seq->add(cost_per_entry_ms);
173 } else {
174 _mixed_cost_per_entry_ms_seq->add(cost_per_entry_ms);
175 }
176 }
177
178 void G1Measurements::report_cards_per_entry_ratio(double cards_per_entry_ratio, bool last_gc_was_young) {
179 if (last_gc_was_young) {
180 _young_cards_per_entry_ratio_seq->add(cards_per_entry_ratio);
181 } else {
182 _mixed_cards_per_entry_ratio_seq->add(cards_per_entry_ratio);
183 }
184 }
185
186 void G1Measurements::report_rs_length_diff(double rs_length_diff) {
187 _rs_length_diff_seq->add(rs_length_diff);
188 }
189
190 void G1Measurements::report_cost_per_byte_ms(double cost_per_byte_ms, bool in_marking_window) {
191 if (in_marking_window) {
192 _cost_per_byte_ms_during_cm_seq->add(cost_per_byte_ms);
193 } else {
194 _cost_per_byte_ms_seq->add(cost_per_byte_ms);
195 }
196 }
197
198 void G1Measurements::report_young_other_cost_per_region_ms(double other_cost_per_region_ms) {
199 _young_other_cost_per_region_ms_seq->add(other_cost_per_region_ms);
200 }
201
202 void G1Measurements::report_non_young_other_cost_per_region_ms(double other_cost_per_region_ms) {
203 _non_young_other_cost_per_region_ms_seq->add(other_cost_per_region_ms);
204 }
205
206 void G1Measurements::report_constant_other_time_ms(double constant_other_time_ms) {
207 _constant_other_time_ms_seq->add(constant_other_time_ms);
208 }
209
210 void G1Measurements::report_pending_cards(double pending_cards) {
211 _pending_cards_seq->add(pending_cards);
212 }
213
214 void G1Measurements::report_rs_lengths(double rs_lengths) {
215 _rs_lengths_seq->add(rs_lengths);
216 }
217
218 size_t G1Measurements::predict_rs_length_diff() const {
219 return get_new_size_prediction(_rs_length_diff_seq);
220 }
221
222 double G1Measurements::predict_alloc_rate_ms() const {
223 return get_new_prediction(_alloc_rate_ms_seq);
224 }
225
226 double G1Measurements::predict_cost_per_card_ms() const {
227 return get_new_prediction(_cost_per_card_ms_seq);
228 }
229
230 double G1Measurements::predict_scan_hcc_ms() const {
231 return get_new_prediction(_cost_scan_hcc_seq);
232 }
233
234 double G1Measurements::predict_rs_update_time_ms(size_t pending_cards) const {
235 return pending_cards * predict_cost_per_card_ms() + predict_scan_hcc_ms();
236 }
237
238 double G1Measurements::predict_young_cards_per_entry_ratio() const {
239 return get_new_prediction(_young_cards_per_entry_ratio_seq);
240 }
241
242 double G1Measurements::predict_mixed_cards_per_entry_ratio() const {
243 if (_mixed_cards_per_entry_ratio_seq->num() < 2) {
244 return predict_young_cards_per_entry_ratio();
245 } else {
246 return get_new_prediction(_mixed_cards_per_entry_ratio_seq);
247 }
248 }
249
250 size_t G1Measurements::predict_card_num(size_t rs_length, bool gcs_are_young) const {
251 if (gcs_are_young) {
252 return (size_t) (rs_length * predict_young_cards_per_entry_ratio());
253 } else {
254 return (size_t) (rs_length * predict_mixed_cards_per_entry_ratio());
255 }
256 }
257
258 double G1Measurements::predict_rs_scan_time_ms(size_t card_num, bool gcs_are_young) const {
259 if (gcs_are_young) {
260 return card_num * get_new_prediction(_cost_per_entry_ms_seq);
261 } else {
262 return predict_mixed_rs_scan_time_ms(card_num);
263 }
264 }
265
266 double G1Measurements::predict_mixed_rs_scan_time_ms(size_t card_num) const {
267 if (_mixed_cost_per_entry_ms_seq->num() < 3) {
268 return card_num * get_new_prediction(_cost_per_entry_ms_seq);
269 } else {
270 return card_num * get_new_prediction(_mixed_cost_per_entry_ms_seq);
271 }
272 }
273
274 double G1Measurements::predict_object_copy_time_ms_during_cm(size_t bytes_to_copy) const {
275 if (_cost_per_byte_ms_during_cm_seq->num() < 3) {
276 return (1.1 * bytes_to_copy) * get_new_prediction(_cost_per_byte_ms_seq);
277 } else {
278 return bytes_to_copy * get_new_prediction(_cost_per_byte_ms_during_cm_seq);
279 }
280 }
281
282 double G1Measurements::predict_object_copy_time_ms(size_t bytes_to_copy, bool during_concurrent_mark) const {
283 if (during_concurrent_mark) {
284 return predict_object_copy_time_ms_during_cm(bytes_to_copy);
285 } else {
286 return bytes_to_copy * get_new_prediction(_cost_per_byte_ms_seq);
287 }
288 }
289
290 double G1Measurements::predict_constant_other_time_ms() const {
291 return get_new_prediction(_constant_other_time_ms_seq);
292 }
293
294 double G1Measurements::predict_young_other_time_ms(size_t young_num) const {
295 return young_num * get_new_prediction(_young_other_cost_per_region_ms_seq);
296 }
297
298 double G1Measurements::predict_non_young_other_time_ms(size_t non_young_num) const {
299 return non_young_num * get_new_prediction(_non_young_other_cost_per_region_ms_seq);
300 }
301
302 double G1Measurements::predict_remark_time_ms() const {
303 return get_new_prediction(_concurrent_mark_remark_times_ms);
304 }
305
306 double G1Measurements::predict_cleanup_time_ms() const {
307 return get_new_prediction(_concurrent_mark_cleanup_times_ms);
308 }
309
310 size_t G1Measurements::predict_rs_lengths() const {
311 return get_new_size_prediction(_rs_lengths_seq);
312 }
313
314 size_t G1Measurements::predict_pending_cards() const {
315 return get_new_size_prediction(_pending_cards_seq);
316 }
317
318 void G1Measurements::update_recent_gc_times(double end_time_sec,
319 double pause_time_ms) {
320 double interval_ms =
321 (end_time_sec - _recent_prev_end_times_for_all_gcs_sec->oldest()) * 1000.0;
322 _recent_gc_times_ms->add(pause_time_ms);
323 _recent_prev_end_times_for_all_gcs_sec->add(end_time_sec);
324 _prev_collection_pause_end_ms = end_time_sec * 1000.0;
325
326 compute_pause_time_ratio(interval_ms, pause_time_ms);
327 }
328
329 void G1Measurements::report_concurrent_mark_cleanup_times_ms(double ms) {
330 _concurrent_mark_cleanup_times_ms->add(ms);
331 }
332
|
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_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[] = {
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_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 _cost_per_entry_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
85 _mixed_cost_per_entry_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
86 _cost_per_byte_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
87 _cost_per_byte_ms_during_cm_seq(new TruncatedSeq(TruncatedSeqLength)),
88 _constant_other_time_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
89 _young_other_cost_per_region_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
90 _non_young_other_cost_per_region_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
91 _pending_cards_seq(new TruncatedSeq(TruncatedSeqLength)),
92 _rs_lengths_seq(new TruncatedSeq(TruncatedSeqLength)),
93 _recent_prev_end_times_for_all_gcs_sec(new TruncatedSeq(NumPrevPausesForHeuristics)) {
94
95 // Seed sequences with initial values.
96 _recent_prev_end_times_for_all_gcs_sec->add(os::elapsedTime());
97 _prev_collection_pause_end_ms = os::elapsedTime() * 1000.0;
98
99 int index = MIN2(ParallelGCThreads - 1, 7u);
100
101 _rs_length_diff_seq->add(rs_length_diff_defaults[index]);
102 _cost_per_card_ms_seq->add(cost_per_card_ms_defaults[index]);
103 _cost_scan_hcc_seq->add(0.0);
104 _young_cards_per_entry_ratio_seq->add(young_cards_per_entry_ratio_defaults[index]);
105 _cost_per_entry_ms_seq->add(cost_per_entry_ms_defaults[index]);
106 _cost_per_byte_ms_seq->add(cost_per_byte_ms_defaults[index]);
107 _constant_other_time_ms_seq->add(constant_other_time_ms_defaults[index]);
108 _young_other_cost_per_region_ms_seq->add(young_other_cost_per_region_ms_defaults[index]);
109 _non_young_other_cost_per_region_ms_seq->add(non_young_other_cost_per_region_ms_defaults[index]);
110
111 // start conservatively (around 50ms is about right)
112 _concurrent_mark_remark_times_ms->add(0.05);
113 _concurrent_mark_cleanup_times_ms->add(0.20);
114 }
115
116 double G1Analytics::get_new_prediction(TruncatedSeq const* seq) const {
117 return _predictor->get_new_prediction(seq);
118 }
119
120 size_t G1Analytics::get_new_size_prediction(TruncatedSeq const* seq) const {
121 return (size_t)get_new_prediction(seq);
122 }
123
124 int G1Analytics::num_alloc_rate_ms() const {
125 return _alloc_rate_ms_seq->num();
126 }
127
128 void G1Analytics::report_concurrent_mark_remark_times_ms(double ms) {
129 _concurrent_mark_remark_times_ms->add(ms);
130 }
131
132 void G1Analytics::report_alloc_rate_ms(double alloc_rate) {
133 _alloc_rate_ms_seq->add(alloc_rate);
134 }
135
136 void G1Analytics::compute_pause_time_ratio(double interval_ms, double pause_time_ms) {
137 _recent_avg_pause_time_ratio = _recent_gc_times_ms->sum() / interval_ms;
138 if (_recent_avg_pause_time_ratio < 0.0 ||
139 (_recent_avg_pause_time_ratio - 1.0 > 0.0)) {
140 // Clip ratio between 0.0 and 1.0, and continue. This will be fixed in
141 // CR 6902692 by redoing the manner in which the ratio is incrementally computed.
142 if (_recent_avg_pause_time_ratio < 0.0) {
143 _recent_avg_pause_time_ratio = 0.0;
144 } else {
145 assert(_recent_avg_pause_time_ratio - 1.0 > 0.0, "Ctl-point invariant");
146 _recent_avg_pause_time_ratio = 1.0;
147 }
148 }
149
150 // Compute the ratio of just this last pause time to the entire time range stored
151 // in the vectors. Comparing this pause to the entire range, rather than only the
152 // most recent interval, has the effect of smoothing over a possible transient 'burst'
153 // of more frequent pauses that don't really reflect a change in heap occupancy.
154 // This reduces the likelihood of a needless heap expansion being triggered.
155 _last_pause_time_ratio =
156 (pause_time_ms * _recent_prev_end_times_for_all_gcs_sec->num()) / interval_ms;
157 }
158
159 void G1Analytics::report_cost_per_card_ms(double cost_per_card_ms) {
160 _cost_per_card_ms_seq->add(cost_per_card_ms);
161 }
162
163 void G1Analytics::report_cost_scan_hcc(double cost_scan_hcc) {
164 _cost_scan_hcc_seq->add(cost_scan_hcc);
165 }
166
167 void G1Analytics::report_cost_per_entry_ms(double cost_per_entry_ms, bool last_gc_was_young) {
168 if (last_gc_was_young) {
169 _cost_per_entry_ms_seq->add(cost_per_entry_ms);
170 } else {
171 _mixed_cost_per_entry_ms_seq->add(cost_per_entry_ms);
172 }
173 }
174
175 void G1Analytics::report_cards_per_entry_ratio(double cards_per_entry_ratio, bool last_gc_was_young) {
176 if (last_gc_was_young) {
177 _young_cards_per_entry_ratio_seq->add(cards_per_entry_ratio);
178 } else {
179 _mixed_cards_per_entry_ratio_seq->add(cards_per_entry_ratio);
180 }
181 }
182
183 void G1Analytics::report_rs_length_diff(double rs_length_diff) {
184 _rs_length_diff_seq->add(rs_length_diff);
185 }
186
187 void G1Analytics::report_cost_per_byte_ms(double cost_per_byte_ms, bool in_marking_window) {
188 if (in_marking_window) {
189 _cost_per_byte_ms_during_cm_seq->add(cost_per_byte_ms);
190 } else {
191 _cost_per_byte_ms_seq->add(cost_per_byte_ms);
192 }
193 }
194
195 void G1Analytics::report_young_other_cost_per_region_ms(double other_cost_per_region_ms) {
196 _young_other_cost_per_region_ms_seq->add(other_cost_per_region_ms);
197 }
198
199 void G1Analytics::report_non_young_other_cost_per_region_ms(double other_cost_per_region_ms) {
200 _non_young_other_cost_per_region_ms_seq->add(other_cost_per_region_ms);
201 }
202
203 void G1Analytics::report_constant_other_time_ms(double constant_other_time_ms) {
204 _constant_other_time_ms_seq->add(constant_other_time_ms);
205 }
206
207 void G1Analytics::report_pending_cards(double pending_cards) {
208 _pending_cards_seq->add(pending_cards);
209 }
210
211 void G1Analytics::report_rs_lengths(double rs_lengths) {
212 _rs_lengths_seq->add(rs_lengths);
213 }
214
215 size_t G1Analytics::predict_rs_length_diff() const {
216 return get_new_size_prediction(_rs_length_diff_seq);
217 }
218
219 double G1Analytics::predict_alloc_rate_ms() const {
220 return get_new_prediction(_alloc_rate_ms_seq);
221 }
222
223 double G1Analytics::predict_cost_per_card_ms() const {
224 return get_new_prediction(_cost_per_card_ms_seq);
225 }
226
227 double G1Analytics::predict_scan_hcc_ms() const {
228 return get_new_prediction(_cost_scan_hcc_seq);
229 }
230
231 double G1Analytics::predict_rs_update_time_ms(size_t pending_cards) const {
232 return pending_cards * predict_cost_per_card_ms() + predict_scan_hcc_ms();
233 }
234
235 double G1Analytics::predict_young_cards_per_entry_ratio() const {
236 return get_new_prediction(_young_cards_per_entry_ratio_seq);
237 }
238
239 double G1Analytics::predict_mixed_cards_per_entry_ratio() const {
240 if (_mixed_cards_per_entry_ratio_seq->num() < 2) {
241 return predict_young_cards_per_entry_ratio();
242 } else {
243 return get_new_prediction(_mixed_cards_per_entry_ratio_seq);
244 }
245 }
246
247 size_t G1Analytics::predict_card_num(size_t rs_length, bool gcs_are_young) const {
248 if (gcs_are_young) {
249 return (size_t) (rs_length * predict_young_cards_per_entry_ratio());
250 } else {
251 return (size_t) (rs_length * predict_mixed_cards_per_entry_ratio());
252 }
253 }
254
255 double G1Analytics::predict_rs_scan_time_ms(size_t card_num, bool gcs_are_young) const {
256 if (gcs_are_young) {
257 return card_num * get_new_prediction(_cost_per_entry_ms_seq);
258 } else {
259 return predict_mixed_rs_scan_time_ms(card_num);
260 }
261 }
262
263 double G1Analytics::predict_mixed_rs_scan_time_ms(size_t card_num) const {
264 if (_mixed_cost_per_entry_ms_seq->num() < 3) {
265 return card_num * get_new_prediction(_cost_per_entry_ms_seq);
266 } else {
267 return card_num * get_new_prediction(_mixed_cost_per_entry_ms_seq);
268 }
269 }
270
271 double G1Analytics::predict_object_copy_time_ms_during_cm(size_t bytes_to_copy) const {
272 if (_cost_per_byte_ms_during_cm_seq->num() < 3) {
273 return (1.1 * bytes_to_copy) * get_new_prediction(_cost_per_byte_ms_seq);
274 } else {
275 return bytes_to_copy * get_new_prediction(_cost_per_byte_ms_during_cm_seq);
276 }
277 }
278
279 double G1Analytics::predict_object_copy_time_ms(size_t bytes_to_copy, bool during_concurrent_mark) const {
280 if (during_concurrent_mark) {
281 return predict_object_copy_time_ms_during_cm(bytes_to_copy);
282 } else {
283 return bytes_to_copy * get_new_prediction(_cost_per_byte_ms_seq);
284 }
285 }
286
287 double G1Analytics::predict_constant_other_time_ms() const {
288 return get_new_prediction(_constant_other_time_ms_seq);
289 }
290
291 double G1Analytics::predict_young_other_time_ms(size_t young_num) const {
292 return young_num * get_new_prediction(_young_other_cost_per_region_ms_seq);
293 }
294
295 double G1Analytics::predict_non_young_other_time_ms(size_t non_young_num) const {
296 return non_young_num * get_new_prediction(_non_young_other_cost_per_region_ms_seq);
297 }
298
299 double G1Analytics::predict_remark_time_ms() const {
300 return get_new_prediction(_concurrent_mark_remark_times_ms);
301 }
302
303 double G1Analytics::predict_cleanup_time_ms() const {
304 return get_new_prediction(_concurrent_mark_cleanup_times_ms);
305 }
306
307 size_t G1Analytics::predict_rs_lengths() const {
308 return get_new_size_prediction(_rs_lengths_seq);
309 }
310
311 size_t G1Analytics::predict_pending_cards() const {
312 return get_new_size_prediction(_pending_cards_seq);
313 }
314
315 double G1Analytics::last_known_gc_end_time_sec() const {
316 return _recent_prev_end_times_for_all_gcs_sec->oldest();
317 }
318
319 void G1Analytics::update_recent_gc_times(double end_time_sec,
320 double pause_time_ms) {
321 _recent_gc_times_ms->add(pause_time_ms);
322 _recent_prev_end_times_for_all_gcs_sec->add(end_time_sec);
323 _prev_collection_pause_end_ms = end_time_sec * 1000.0;
324 }
325
326 void G1Analytics::report_concurrent_mark_cleanup_times_ms(double ms) {
327 _concurrent_mark_cleanup_times_ms->add(ms);
328 }
329
|