Mercurial > hg > truffle
annotate src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp @ 941:8b46c4d82093
4957990: Perm heap bloat in JVM
Summary: Treat ProfileData in MDO's as a source of weak, not strong, roots. Fixes the bug for stop-world collection -- the case of concurrent collection will be fixed separately.
Reviewed-by: jcoomes, jmasa, kvn, never
author | ysr |
---|---|
date | Wed, 02 Sep 2009 00:04:29 -0700 |
parents | e1fdf4fd34dc |
children | 2c79770d1f6e |
rev | line source |
---|---|
342 | 1 /* |
579 | 2 * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved. |
342 | 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 #include "incls/_precompiled.incl" | |
26 #include "incls/_g1CollectorPolicy.cpp.incl" | |
27 | |
28 #define PREDICTIONS_VERBOSE 0 | |
29 | |
30 // <NEW PREDICTION> | |
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 static double cost_per_scan_only_region_ms_defaults[] = { | |
46 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 | |
47 }; | |
48 | |
49 // all the same | |
50 static double fully_young_cards_per_entry_ratio_defaults[] = { | |
51 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 | |
52 }; | |
53 | |
54 static double cost_per_entry_ms_defaults[] = { | |
55 0.015, 0.01, 0.01, 0.008, 0.008, 0.0055, 0.0055, 0.005 | |
56 }; | |
57 | |
58 static double cost_per_byte_ms_defaults[] = { | |
59 0.00006, 0.00003, 0.00003, 0.000015, 0.000015, 0.00001, 0.00001, 0.000009 | |
60 }; | |
61 | |
62 // these should be pretty consistent | |
63 static double constant_other_time_ms_defaults[] = { | |
64 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 | |
65 }; | |
66 | |
67 | |
68 static double young_other_cost_per_region_ms_defaults[] = { | |
69 0.3, 0.2, 0.2, 0.15, 0.15, 0.12, 0.12, 0.1 | |
70 }; | |
71 | |
72 static double non_young_other_cost_per_region_ms_defaults[] = { | |
73 1.0, 0.7, 0.7, 0.5, 0.5, 0.42, 0.42, 0.30 | |
74 }; | |
75 | |
76 // </NEW PREDICTION> | |
77 | |
78 G1CollectorPolicy::G1CollectorPolicy() : | |
79 _parallel_gc_threads((ParallelGCThreads > 0) ? ParallelGCThreads : 1), | |
80 _n_pauses(0), | |
81 _recent_CH_strong_roots_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)), | |
82 _recent_G1_strong_roots_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)), | |
83 _recent_evac_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)), | |
84 _recent_pause_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)), | |
85 _recent_rs_sizes(new TruncatedSeq(NumPrevPausesForHeuristics)), | |
86 _recent_gc_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)), | |
87 _all_pause_times_ms(new NumberSeq()), | |
88 _stop_world_start(0.0), | |
89 _all_stop_world_times_ms(new NumberSeq()), | |
90 _all_yield_times_ms(new NumberSeq()), | |
91 | |
92 _all_mod_union_times_ms(new NumberSeq()), | |
93 | |
677 | 94 _summary(new Summary()), |
95 _abandoned_summary(new AbandonedSummary()), | |
342 | 96 |
890
6cb8e9df7174
6819077: G1: first GC thread coming late into the GC.
johnc
parents:
845
diff
changeset
|
97 #ifndef PRODUCT |
342 | 98 _cur_clear_ct_time_ms(0.0), |
890
6cb8e9df7174
6819077: G1: first GC thread coming late into the GC.
johnc
parents:
845
diff
changeset
|
99 _min_clear_cc_time_ms(-1.0), |
6cb8e9df7174
6819077: G1: first GC thread coming late into the GC.
johnc
parents:
845
diff
changeset
|
100 _max_clear_cc_time_ms(-1.0), |
6cb8e9df7174
6819077: G1: first GC thread coming late into the GC.
johnc
parents:
845
diff
changeset
|
101 _cur_clear_cc_time_ms(0.0), |
6cb8e9df7174
6819077: G1: first GC thread coming late into the GC.
johnc
parents:
845
diff
changeset
|
102 _cum_clear_cc_time_ms(0.0), |
6cb8e9df7174
6819077: G1: first GC thread coming late into the GC.
johnc
parents:
845
diff
changeset
|
103 _num_cc_clears(0L), |
6cb8e9df7174
6819077: G1: first GC thread coming late into the GC.
johnc
parents:
845
diff
changeset
|
104 #endif |
342 | 105 |
106 _region_num_young(0), | |
107 _region_num_tenured(0), | |
108 _prev_region_num_young(0), | |
109 _prev_region_num_tenured(0), | |
110 | |
111 _aux_num(10), | |
112 _all_aux_times_ms(new NumberSeq[_aux_num]), | |
113 _cur_aux_start_times_ms(new double[_aux_num]), | |
114 _cur_aux_times_ms(new double[_aux_num]), | |
115 _cur_aux_times_set(new bool[_aux_num]), | |
116 | |
117 _concurrent_mark_init_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)), | |
118 _concurrent_mark_remark_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)), | |
119 _concurrent_mark_cleanup_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)), | |
120 | |
121 // <NEW PREDICTION> | |
122 | |
123 _alloc_rate_ms_seq(new TruncatedSeq(TruncatedSeqLength)), | |
124 _prev_collection_pause_end_ms(0.0), | |
125 _pending_card_diff_seq(new TruncatedSeq(TruncatedSeqLength)), | |
126 _rs_length_diff_seq(new TruncatedSeq(TruncatedSeqLength)), | |
127 _cost_per_card_ms_seq(new TruncatedSeq(TruncatedSeqLength)), | |
128 _cost_per_scan_only_region_ms_seq(new TruncatedSeq(TruncatedSeqLength)), | |
129 _fully_young_cards_per_entry_ratio_seq(new TruncatedSeq(TruncatedSeqLength)), | |
130 _partially_young_cards_per_entry_ratio_seq( | |
131 new TruncatedSeq(TruncatedSeqLength)), | |
132 _cost_per_entry_ms_seq(new TruncatedSeq(TruncatedSeqLength)), | |
133 _partially_young_cost_per_entry_ms_seq(new TruncatedSeq(TruncatedSeqLength)), | |
134 _cost_per_byte_ms_seq(new TruncatedSeq(TruncatedSeqLength)), | |
135 _cost_per_byte_ms_during_cm_seq(new TruncatedSeq(TruncatedSeqLength)), | |
136 _cost_per_scan_only_region_ms_during_cm_seq(new TruncatedSeq(TruncatedSeqLength)), | |
137 _constant_other_time_ms_seq(new TruncatedSeq(TruncatedSeqLength)), | |
138 _young_other_cost_per_region_ms_seq(new TruncatedSeq(TruncatedSeqLength)), | |
139 _non_young_other_cost_per_region_ms_seq( | |
140 new TruncatedSeq(TruncatedSeqLength)), | |
141 | |
142 _pending_cards_seq(new TruncatedSeq(TruncatedSeqLength)), | |
143 _scanned_cards_seq(new TruncatedSeq(TruncatedSeqLength)), | |
144 _rs_lengths_seq(new TruncatedSeq(TruncatedSeqLength)), | |
145 | |
751 | 146 _pause_time_target_ms((double) MaxGCPauseMillis), |
342 | 147 |
148 // </NEW PREDICTION> | |
149 | |
150 _in_young_gc_mode(false), | |
151 _full_young_gcs(true), | |
152 _full_young_pause_num(0), | |
153 _partial_young_pause_num(0), | |
154 | |
155 _during_marking(false), | |
156 _in_marking_window(false), | |
157 _in_marking_window_im(false), | |
158 | |
159 _known_garbage_ratio(0.0), | |
160 _known_garbage_bytes(0), | |
161 | |
162 _young_gc_eff_seq(new TruncatedSeq(TruncatedSeqLength)), | |
163 _target_pause_time_ms(-1.0), | |
164 | |
165 _recent_prev_end_times_for_all_gcs_sec(new TruncatedSeq(NumPrevPausesForHeuristics)), | |
166 | |
167 _recent_CS_bytes_used_before(new TruncatedSeq(NumPrevPausesForHeuristics)), | |
168 _recent_CS_bytes_surviving(new TruncatedSeq(NumPrevPausesForHeuristics)), | |
169 | |
170 _recent_avg_pause_time_ratio(0.0), | |
171 _num_markings(0), | |
172 _n_marks(0), | |
173 _n_pauses_at_mark_end(0), | |
174 | |
175 _all_full_gc_times_ms(new NumberSeq()), | |
176 | |
177 // G1PausesBtwnConcMark defaults to -1 | |
178 // so the hack is to do the cast QQQ FIXME | |
179 _pauses_btwn_concurrent_mark((size_t)G1PausesBtwnConcMark), | |
180 _n_marks_since_last_pause(0), | |
181 _conc_mark_initiated(false), | |
182 _should_initiate_conc_mark(false), | |
183 _should_revert_to_full_young_gcs(false), | |
184 _last_full_young_gc(false), | |
185 | |
186 _prev_collection_pause_used_at_end_bytes(0), | |
187 | |
188 _collection_set(NULL), | |
189 #ifdef _MSC_VER // the use of 'this' below gets a warning, make it go away | |
190 #pragma warning( disable:4355 ) // 'this' : used in base member initializer list | |
191 #endif // _MSC_VER | |
192 | |
193 _short_lived_surv_rate_group(new SurvRateGroup(this, "Short Lived", | |
194 G1YoungSurvRateNumRegionsSummary)), | |
195 _survivor_surv_rate_group(new SurvRateGroup(this, "Survivor", | |
545 | 196 G1YoungSurvRateNumRegionsSummary)), |
342 | 197 // add here any more surv rate groups |
545 | 198 _recorded_survivor_regions(0), |
199 _recorded_survivor_head(NULL), | |
200 _recorded_survivor_tail(NULL), | |
201 _survivors_age_table(true) | |
202 | |
342 | 203 { |
204 _recent_prev_end_times_for_all_gcs_sec->add(os::elapsedTime()); | |
205 _prev_collection_pause_end_ms = os::elapsedTime() * 1000.0; | |
206 | |
207 _par_last_ext_root_scan_times_ms = new double[_parallel_gc_threads]; | |
208 _par_last_mark_stack_scan_times_ms = new double[_parallel_gc_threads]; | |
209 _par_last_scan_only_times_ms = new double[_parallel_gc_threads]; | |
210 _par_last_scan_only_regions_scanned = new double[_parallel_gc_threads]; | |
211 | |
212 _par_last_update_rs_start_times_ms = new double[_parallel_gc_threads]; | |
213 _par_last_update_rs_times_ms = new double[_parallel_gc_threads]; | |
214 _par_last_update_rs_processed_buffers = new double[_parallel_gc_threads]; | |
215 | |
216 _par_last_scan_rs_start_times_ms = new double[_parallel_gc_threads]; | |
217 _par_last_scan_rs_times_ms = new double[_parallel_gc_threads]; | |
218 _par_last_scan_new_refs_times_ms = new double[_parallel_gc_threads]; | |
219 | |
220 _par_last_obj_copy_times_ms = new double[_parallel_gc_threads]; | |
221 | |
222 _par_last_termination_times_ms = new double[_parallel_gc_threads]; | |
223 | |
224 // start conservatively | |
751 | 225 _expensive_region_limit_ms = 0.5 * (double) MaxGCPauseMillis; |
342 | 226 |
227 // <NEW PREDICTION> | |
228 | |
229 int index; | |
230 if (ParallelGCThreads == 0) | |
231 index = 0; | |
232 else if (ParallelGCThreads > 8) | |
233 index = 7; | |
234 else | |
235 index = ParallelGCThreads - 1; | |
236 | |
237 _pending_card_diff_seq->add(0.0); | |
238 _rs_length_diff_seq->add(rs_length_diff_defaults[index]); | |
239 _cost_per_card_ms_seq->add(cost_per_card_ms_defaults[index]); | |
240 _cost_per_scan_only_region_ms_seq->add( | |
241 cost_per_scan_only_region_ms_defaults[index]); | |
242 _fully_young_cards_per_entry_ratio_seq->add( | |
243 fully_young_cards_per_entry_ratio_defaults[index]); | |
244 _cost_per_entry_ms_seq->add(cost_per_entry_ms_defaults[index]); | |
245 _cost_per_byte_ms_seq->add(cost_per_byte_ms_defaults[index]); | |
246 _constant_other_time_ms_seq->add(constant_other_time_ms_defaults[index]); | |
247 _young_other_cost_per_region_ms_seq->add( | |
248 young_other_cost_per_region_ms_defaults[index]); | |
249 _non_young_other_cost_per_region_ms_seq->add( | |
250 non_young_other_cost_per_region_ms_defaults[index]); | |
251 | |
252 // </NEW PREDICTION> | |
253 | |
751 | 254 double time_slice = (double) GCPauseIntervalMillis / 1000.0; |
255 double max_gc_time = (double) MaxGCPauseMillis / 1000.0; | |
342 | 256 guarantee(max_gc_time < time_slice, |
257 "Max GC time should not be greater than the time slice"); | |
258 _mmu_tracker = new G1MMUTrackerQueue(time_slice, max_gc_time); | |
751 | 259 _sigma = (double) G1ConfidencePercent / 100.0; |
342 | 260 |
261 // start conservatively (around 50ms is about right) | |
262 _concurrent_mark_init_times_ms->add(0.05); | |
263 _concurrent_mark_remark_times_ms->add(0.05); | |
264 _concurrent_mark_cleanup_times_ms->add(0.20); | |
265 _tenuring_threshold = MaxTenuringThreshold; | |
266 | |
751 | 267 if (G1UseSurvivorSpaces) { |
545 | 268 // if G1FixedSurvivorSpaceSize is 0 which means the size is not |
269 // fixed, then _max_survivor_regions will be calculated at | |
547
1e458753107d
6802413: G1: G1FixedSurvivorSpaceSize should be converted into regions in calculate_survivors_policy()
apetrusenko
parents:
545
diff
changeset
|
270 // calculate_young_list_target_config during initialization |
545 | 271 _max_survivor_regions = G1FixedSurvivorSpaceSize / HeapRegion::GrainBytes; |
272 } else { | |
273 _max_survivor_regions = 0; | |
274 } | |
275 | |
342 | 276 initialize_all(); |
277 } | |
278 | |
279 // Increment "i", mod "len" | |
280 static void inc_mod(int& i, int len) { | |
281 i++; if (i == len) i = 0; | |
282 } | |
283 | |
284 void G1CollectorPolicy::initialize_flags() { | |
285 set_min_alignment(HeapRegion::GrainBytes); | |
286 set_max_alignment(GenRemSet::max_alignment_constraint(rem_set_name())); | |
547
1e458753107d
6802413: G1: G1FixedSurvivorSpaceSize should be converted into regions in calculate_survivors_policy()
apetrusenko
parents:
545
diff
changeset
|
287 if (SurvivorRatio < 1) { |
1e458753107d
6802413: G1: G1FixedSurvivorSpaceSize should be converted into regions in calculate_survivors_policy()
apetrusenko
parents:
545
diff
changeset
|
288 vm_exit_during_initialization("Invalid survivor ratio specified"); |
1e458753107d
6802413: G1: G1FixedSurvivorSpaceSize should be converted into regions in calculate_survivors_policy()
apetrusenko
parents:
545
diff
changeset
|
289 } |
342 | 290 CollectorPolicy::initialize_flags(); |
291 } | |
292 | |
293 void G1CollectorPolicy::init() { | |
294 // Set aside an initial future to_space. | |
295 _g1 = G1CollectedHeap::heap(); | |
296 size_t regions = Universe::heap()->capacity() / HeapRegion::GrainBytes; | |
297 | |
298 assert(Heap_lock->owned_by_self(), "Locking discipline."); | |
299 | |
300 if (G1SteadyStateUsed < 50) { | |
301 vm_exit_during_initialization("G1SteadyStateUsed must be at least 50%."); | |
302 } | |
303 | |
545 | 304 initialize_gc_policy_counters(); |
305 | |
342 | 306 if (G1Gen) { |
307 _in_young_gc_mode = true; | |
308 | |
309 if (G1YoungGenSize == 0) { | |
310 set_adaptive_young_list_length(true); | |
311 _young_list_fixed_length = 0; | |
312 } else { | |
313 set_adaptive_young_list_length(false); | |
314 _young_list_fixed_length = (G1YoungGenSize / HeapRegion::GrainBytes); | |
315 } | |
316 _free_regions_at_end_of_collection = _g1->free_regions(); | |
317 _scan_only_regions_at_end_of_collection = 0; | |
318 calculate_young_list_min_length(); | |
319 guarantee( _young_list_min_length == 0, "invariant, not enough info" ); | |
320 calculate_young_list_target_config(); | |
321 } else { | |
322 _young_list_fixed_length = 0; | |
323 _in_young_gc_mode = false; | |
324 } | |
325 } | |
326 | |
545 | 327 // Create the jstat counters for the policy. |
328 void G1CollectorPolicy::initialize_gc_policy_counters() | |
329 { | |
330 _gc_policy_counters = new GCPolicyCounters("GarbageFirst", 1, 2 + G1Gen); | |
331 } | |
332 | |
342 | 333 void G1CollectorPolicy::calculate_young_list_min_length() { |
334 _young_list_min_length = 0; | |
335 | |
336 if (!adaptive_young_list_length()) | |
337 return; | |
338 | |
339 if (_alloc_rate_ms_seq->num() > 3) { | |
340 double now_sec = os::elapsedTime(); | |
341 double when_ms = _mmu_tracker->when_max_gc_sec(now_sec) * 1000.0; | |
342 double alloc_rate_ms = predict_alloc_rate_ms(); | |
343 int min_regions = (int) ceil(alloc_rate_ms * when_ms); | |
344 int current_region_num = (int) _g1->young_list_length(); | |
345 _young_list_min_length = min_regions + current_region_num; | |
346 } | |
347 } | |
348 | |
349 void G1CollectorPolicy::calculate_young_list_target_config() { | |
350 if (adaptive_young_list_length()) { | |
351 size_t rs_lengths = (size_t) get_new_prediction(_rs_lengths_seq); | |
352 calculate_young_list_target_config(rs_lengths); | |
353 } else { | |
354 if (full_young_gcs()) | |
355 _young_list_target_length = _young_list_fixed_length; | |
356 else | |
357 _young_list_target_length = _young_list_fixed_length / 2; | |
358 _young_list_target_length = MAX2(_young_list_target_length, (size_t)1); | |
359 size_t so_length = calculate_optimal_so_length(_young_list_target_length); | |
360 guarantee( so_length < _young_list_target_length, "invariant" ); | |
361 _young_list_so_prefix_length = so_length; | |
362 } | |
545 | 363 calculate_survivors_policy(); |
342 | 364 } |
365 | |
366 // This method calculate the optimal scan-only set for a fixed young | |
367 // gen size. I couldn't work out how to reuse the more elaborate one, | |
368 // i.e. calculate_young_list_target_config(rs_length), as the loops are | |
369 // fundamentally different (the other one finds a config for different | |
370 // S-O lengths, whereas here we need to do the opposite). | |
371 size_t G1CollectorPolicy::calculate_optimal_so_length( | |
372 size_t young_list_length) { | |
373 if (!G1UseScanOnlyPrefix) | |
374 return 0; | |
375 | |
376 if (_all_pause_times_ms->num() < 3) { | |
377 // we won't use a scan-only set at the beginning to allow the rest | |
378 // of the predictors to warm up | |
379 return 0; | |
380 } | |
381 | |
382 if (_cost_per_scan_only_region_ms_seq->num() < 3) { | |
383 // then, we'll only set the S-O set to 1 for a little bit of time, | |
384 // to get enough information on the scanning cost | |
385 return 1; | |
386 } | |
387 | |
388 size_t pending_cards = (size_t) get_new_prediction(_pending_cards_seq); | |
389 size_t rs_lengths = (size_t) get_new_prediction(_rs_lengths_seq); | |
390 size_t adj_rs_lengths = rs_lengths + predict_rs_length_diff(); | |
391 size_t scanned_cards; | |
392 if (full_young_gcs()) | |
393 scanned_cards = predict_young_card_num(adj_rs_lengths); | |
394 else | |
395 scanned_cards = predict_non_young_card_num(adj_rs_lengths); | |
396 double base_time_ms = predict_base_elapsed_time_ms(pending_cards, | |
397 scanned_cards); | |
398 | |
399 size_t so_length = 0; | |
400 double max_gc_eff = 0.0; | |
401 for (size_t i = 0; i < young_list_length; ++i) { | |
402 double gc_eff = 0.0; | |
403 double pause_time_ms = 0.0; | |
404 predict_gc_eff(young_list_length, i, base_time_ms, | |
405 &gc_eff, &pause_time_ms); | |
406 if (gc_eff > max_gc_eff) { | |
407 max_gc_eff = gc_eff; | |
408 so_length = i; | |
409 } | |
410 } | |
411 | |
412 // set it to 95% of the optimal to make sure we sample the "area" | |
413 // around the optimal length to get up-to-date survival rate data | |
414 return so_length * 950 / 1000; | |
415 } | |
416 | |
417 // This is a really cool piece of code! It finds the best | |
418 // target configuration (young length / scan-only prefix length) so | |
419 // that GC efficiency is maximized and that we also meet a pause | |
420 // time. It's a triple nested loop. These loops are explained below | |
421 // from the inside-out :-) | |
422 // | |
423 // (a) The innermost loop will try to find the optimal young length | |
424 // for a fixed S-O length. It uses a binary search to speed up the | |
425 // process. We assume that, for a fixed S-O length, as we add more | |
426 // young regions to the CSet, the GC efficiency will only go up (I'll | |
427 // skip the proof). So, using a binary search to optimize this process | |
428 // makes perfect sense. | |
429 // | |
430 // (b) The middle loop will fix the S-O length before calling the | |
431 // innermost one. It will vary it between two parameters, increasing | |
432 // it by a given increment. | |
433 // | |
434 // (c) The outermost loop will call the middle loop three times. | |
435 // (1) The first time it will explore all possible S-O length values | |
436 // from 0 to as large as it can get, using a coarse increment (to | |
437 // quickly "home in" to where the optimal seems to be). | |
438 // (2) The second time it will explore the values around the optimal | |
439 // that was found by the first iteration using a fine increment. | |
440 // (3) Once the optimal config has been determined by the second | |
441 // iteration, we'll redo the calculation, but setting the S-O length | |
442 // to 95% of the optimal to make sure we sample the "area" | |
443 // around the optimal length to get up-to-date survival rate data | |
444 // | |
445 // Termination conditions for the iterations are several: the pause | |
446 // time is over the limit, we do not have enough to-space, etc. | |
447 | |
448 void G1CollectorPolicy::calculate_young_list_target_config(size_t rs_lengths) { | |
449 guarantee( adaptive_young_list_length(), "pre-condition" ); | |
450 | |
451 double start_time_sec = os::elapsedTime(); | |
751 | 452 size_t min_reserve_perc = MAX2((size_t)2, (size_t)G1MinReservePercent); |
342 | 453 min_reserve_perc = MIN2((size_t) 50, min_reserve_perc); |
454 size_t reserve_regions = | |
455 (size_t) ((double) min_reserve_perc * (double) _g1->n_regions() / 100.0); | |
456 | |
457 if (full_young_gcs() && _free_regions_at_end_of_collection > 0) { | |
458 // we are in fully-young mode and there are free regions in the heap | |
459 | |
545 | 460 double survivor_regions_evac_time = |
461 predict_survivor_regions_evac_time(); | |
462 | |
342 | 463 size_t min_so_length = 0; |
464 size_t max_so_length = 0; | |
465 | |
466 if (G1UseScanOnlyPrefix) { | |
467 if (_all_pause_times_ms->num() < 3) { | |
468 // we won't use a scan-only set at the beginning to allow the rest | |
469 // of the predictors to warm up | |
470 min_so_length = 0; | |
471 max_so_length = 0; | |
472 } else if (_cost_per_scan_only_region_ms_seq->num() < 3) { | |
473 // then, we'll only set the S-O set to 1 for a little bit of time, | |
474 // to get enough information on the scanning cost | |
475 min_so_length = 1; | |
476 max_so_length = 1; | |
477 } else if (_in_marking_window || _last_full_young_gc) { | |
478 // no S-O prefix during a marking phase either, as at the end | |
479 // of the marking phase we'll have to use a very small young | |
480 // length target to fill up the rest of the CSet with | |
481 // non-young regions and, if we have lots of scan-only regions | |
482 // left-over, we will not be able to add any more non-young | |
483 // regions. | |
484 min_so_length = 0; | |
485 max_so_length = 0; | |
486 } else { | |
487 // this is the common case; we'll never reach the maximum, we | |
488 // one of the end conditions will fire well before that | |
489 // (hopefully!) | |
490 min_so_length = 0; | |
491 max_so_length = _free_regions_at_end_of_collection - 1; | |
492 } | |
493 } else { | |
494 // no S-O prefix, as the switch is not set, but we still need to | |
495 // do one iteration to calculate the best young target that | |
496 // meets the pause time; this way we reuse the same code instead | |
497 // of replicating it | |
498 min_so_length = 0; | |
499 max_so_length = 0; | |
500 } | |
501 | |
502 double target_pause_time_ms = _mmu_tracker->max_gc_time() * 1000.0; | |
503 size_t pending_cards = (size_t) get_new_prediction(_pending_cards_seq); | |
504 size_t adj_rs_lengths = rs_lengths + predict_rs_length_diff(); | |
505 size_t scanned_cards; | |
506 if (full_young_gcs()) | |
507 scanned_cards = predict_young_card_num(adj_rs_lengths); | |
508 else | |
509 scanned_cards = predict_non_young_card_num(adj_rs_lengths); | |
510 // calculate this once, so that we don't have to recalculate it in | |
511 // the innermost loop | |
545 | 512 double base_time_ms = predict_base_elapsed_time_ms(pending_cards, scanned_cards) |
513 + survivor_regions_evac_time; | |
342 | 514 // the result |
515 size_t final_young_length = 0; | |
516 size_t final_so_length = 0; | |
517 double final_gc_eff = 0.0; | |
518 // we'll also keep track of how many times we go into the inner loop | |
519 // this is for profiling reasons | |
520 size_t calculations = 0; | |
521 | |
522 // this determines which of the three iterations the outer loop is in | |
523 typedef enum { | |
524 pass_type_coarse, | |
525 pass_type_fine, | |
526 pass_type_final | |
527 } pass_type_t; | |
528 | |
529 // range of the outer loop's iteration | |
530 size_t from_so_length = min_so_length; | |
531 size_t to_so_length = max_so_length; | |
532 guarantee( from_so_length <= to_so_length, "invariant" ); | |
533 | |
534 // this will keep the S-O length that's found by the second | |
535 // iteration of the outer loop; we'll keep it just in case the third | |
536 // iteration fails to find something | |
537 size_t fine_so_length = 0; | |
538 | |
539 // the increment step for the coarse (first) iteration | |
540 size_t so_coarse_increments = 5; | |
541 | |
542 // the common case, we'll start with the coarse iteration | |
543 pass_type_t pass = pass_type_coarse; | |
544 size_t so_length_incr = so_coarse_increments; | |
545 | |
546 if (from_so_length == to_so_length) { | |
547 // not point in doing the coarse iteration, we'll go directly into | |
548 // the fine one (we essentially trying to find the optimal young | |
549 // length for a fixed S-O length). | |
550 so_length_incr = 1; | |
551 pass = pass_type_final; | |
552 } else if (to_so_length - from_so_length < 3 * so_coarse_increments) { | |
553 // again, the range is too short so no point in foind the coarse | |
554 // iteration either | |
555 so_length_incr = 1; | |
556 pass = pass_type_fine; | |
557 } | |
558 | |
559 bool done = false; | |
560 // this is the outermost loop | |
561 while (!done) { | |
545 | 562 #ifdef TRACE_CALC_YOUNG_CONFIG |
342 | 563 // leave this in for debugging, just in case |
564 gclog_or_tty->print_cr("searching between " SIZE_FORMAT " and " SIZE_FORMAT | |
565 ", incr " SIZE_FORMAT ", pass %s", | |
566 from_so_length, to_so_length, so_length_incr, | |
567 (pass == pass_type_coarse) ? "coarse" : | |
568 (pass == pass_type_fine) ? "fine" : "final"); | |
545 | 569 #endif // TRACE_CALC_YOUNG_CONFIG |
342 | 570 |
571 size_t so_length = from_so_length; | |
572 size_t init_free_regions = | |
573 MAX2((size_t)0, | |
574 _free_regions_at_end_of_collection + | |
575 _scan_only_regions_at_end_of_collection - reserve_regions); | |
576 | |
577 // this determines whether a configuration was found | |
578 bool gc_eff_set = false; | |
579 // this is the middle loop | |
580 while (so_length <= to_so_length) { | |
581 // base time, which excludes region-related time; again we | |
582 // calculate it once to avoid recalculating it in the | |
583 // innermost loop | |
584 double base_time_with_so_ms = | |
585 base_time_ms + predict_scan_only_time_ms(so_length); | |
586 // it's already over the pause target, go around | |
587 if (base_time_with_so_ms > target_pause_time_ms) | |
588 break; | |
589 | |
590 size_t starting_young_length = so_length+1; | |
591 | |
592 // we make sure that the short young length that makes sense | |
593 // (one more than the S-O length) is feasible | |
594 size_t min_young_length = starting_young_length; | |
595 double min_gc_eff; | |
596 bool min_ok; | |
597 ++calculations; | |
598 min_ok = predict_gc_eff(min_young_length, so_length, | |
599 base_time_with_so_ms, | |
600 init_free_regions, target_pause_time_ms, | |
601 &min_gc_eff); | |
602 | |
603 if (min_ok) { | |
604 // the shortest young length is indeed feasible; we'll know | |
605 // set up the max young length and we'll do a binary search | |
606 // between min_young_length and max_young_length | |
607 size_t max_young_length = _free_regions_at_end_of_collection - 1; | |
608 double max_gc_eff = 0.0; | |
609 bool max_ok = false; | |
610 | |
611 // the innermost loop! (finally!) | |
612 while (max_young_length > min_young_length) { | |
613 // we'll make sure that min_young_length is always at a | |
614 // feasible config | |
615 guarantee( min_ok, "invariant" ); | |
616 | |
617 ++calculations; | |
618 max_ok = predict_gc_eff(max_young_length, so_length, | |
619 base_time_with_so_ms, | |
620 init_free_regions, target_pause_time_ms, | |
621 &max_gc_eff); | |
622 | |
623 size_t diff = (max_young_length - min_young_length) / 2; | |
624 if (max_ok) { | |
625 min_young_length = max_young_length; | |
626 min_gc_eff = max_gc_eff; | |
627 min_ok = true; | |
628 } | |
629 max_young_length = min_young_length + diff; | |
630 } | |
631 | |
632 // the innermost loop found a config | |
633 guarantee( min_ok, "invariant" ); | |
634 if (min_gc_eff > final_gc_eff) { | |
635 // it's the best config so far, so we'll keep it | |
636 final_gc_eff = min_gc_eff; | |
637 final_young_length = min_young_length; | |
638 final_so_length = so_length; | |
639 gc_eff_set = true; | |
640 } | |
641 } | |
642 | |
643 // incremental the fixed S-O length and go around | |
644 so_length += so_length_incr; | |
645 } | |
646 | |
647 // this is the end of the outermost loop and we need to decide | |
648 // what to do during the next iteration | |
649 if (pass == pass_type_coarse) { | |
650 // we just did the coarse pass (first iteration) | |
651 | |
652 if (!gc_eff_set) | |
653 // we didn't find a feasible config so we'll just bail out; of | |
654 // course, it might be the case that we missed it; but I'd say | |
655 // it's a bit unlikely | |
656 done = true; | |
657 else { | |
658 // We did find a feasible config with optimal GC eff during | |
659 // the first pass. So the second pass we'll only consider the | |
660 // S-O lengths around that config with a fine increment. | |
661 | |
662 guarantee( so_length_incr == so_coarse_increments, "invariant" ); | |
663 guarantee( final_so_length >= min_so_length, "invariant" ); | |
664 | |
545 | 665 #ifdef TRACE_CALC_YOUNG_CONFIG |
342 | 666 // leave this in for debugging, just in case |
667 gclog_or_tty->print_cr(" coarse pass: SO length " SIZE_FORMAT, | |
668 final_so_length); | |
545 | 669 #endif // TRACE_CALC_YOUNG_CONFIG |
342 | 670 |
671 from_so_length = | |
672 (final_so_length - min_so_length > so_coarse_increments) ? | |
673 final_so_length - so_coarse_increments + 1 : min_so_length; | |
674 to_so_length = | |
675 (max_so_length - final_so_length > so_coarse_increments) ? | |
676 final_so_length + so_coarse_increments - 1 : max_so_length; | |
677 | |
678 pass = pass_type_fine; | |
679 so_length_incr = 1; | |
680 } | |
681 } else if (pass == pass_type_fine) { | |
682 // we just finished the second pass | |
683 | |
684 if (!gc_eff_set) { | |
685 // we didn't find a feasible config (yes, it's possible; | |
686 // notice that, sometimes, we go directly into the fine | |
687 // iteration and skip the coarse one) so we bail out | |
688 done = true; | |
689 } else { | |
690 // We did find a feasible config with optimal GC eff | |
691 guarantee( so_length_incr == 1, "invariant" ); | |
692 | |
693 if (final_so_length == 0) { | |
694 // The config is of an empty S-O set, so we'll just bail out | |
695 done = true; | |
696 } else { | |
697 // we'll go around once more, setting the S-O length to 95% | |
698 // of the optimal | |
699 size_t new_so_length = 950 * final_so_length / 1000; | |
700 | |
545 | 701 #ifdef TRACE_CALC_YOUNG_CONFIG |
342 | 702 // leave this in for debugging, just in case |
703 gclog_or_tty->print_cr(" fine pass: SO length " SIZE_FORMAT | |
704 ", setting it to " SIZE_FORMAT, | |
705 final_so_length, new_so_length); | |
545 | 706 #endif // TRACE_CALC_YOUNG_CONFIG |
342 | 707 |
708 from_so_length = new_so_length; | |
709 to_so_length = new_so_length; | |
710 fine_so_length = final_so_length; | |
711 | |
712 pass = pass_type_final; | |
713 } | |
714 } | |
715 } else if (pass == pass_type_final) { | |
716 // we just finished the final (third) pass | |
717 | |
718 if (!gc_eff_set) | |
719 // we didn't find a feasible config, so we'll just use the one | |
720 // we found during the second pass, which we saved | |
721 final_so_length = fine_so_length; | |
722 | |
723 // and we're done! | |
724 done = true; | |
725 } else { | |
726 guarantee( false, "should never reach here" ); | |
727 } | |
728 | |
729 // we now go around the outermost loop | |
730 } | |
731 | |
732 // we should have at least one region in the target young length | |
545 | 733 _young_list_target_length = |
734 MAX2((size_t) 1, final_young_length + _recorded_survivor_regions); | |
342 | 735 if (final_so_length >= final_young_length) |
736 // and we need to ensure that the S-O length is not greater than | |
737 // the target young length (this is being a bit careful) | |
738 final_so_length = 0; | |
739 _young_list_so_prefix_length = final_so_length; | |
740 guarantee( !_in_marking_window || !_last_full_young_gc || | |
741 _young_list_so_prefix_length == 0, "invariant" ); | |
742 | |
743 // let's keep an eye of how long we spend on this calculation | |
744 // right now, I assume that we'll print it when we need it; we | |
745 // should really adde it to the breakdown of a pause | |
746 double end_time_sec = os::elapsedTime(); | |
747 double elapsed_time_ms = (end_time_sec - start_time_sec) * 1000.0; | |
748 | |
545 | 749 #ifdef TRACE_CALC_YOUNG_CONFIG |
342 | 750 // leave this in for debugging, just in case |
751 gclog_or_tty->print_cr("target = %1.1lf ms, young = " SIZE_FORMAT | |
752 ", SO = " SIZE_FORMAT ", " | |
753 "elapsed %1.2lf ms, calcs: " SIZE_FORMAT " (%s%s) " | |
754 SIZE_FORMAT SIZE_FORMAT, | |
755 target_pause_time_ms, | |
756 _young_list_target_length - _young_list_so_prefix_length, | |
757 _young_list_so_prefix_length, | |
758 elapsed_time_ms, | |
759 calculations, | |
760 full_young_gcs() ? "full" : "partial", | |
761 should_initiate_conc_mark() ? " i-m" : "", | |
545 | 762 _in_marking_window, |
763 _in_marking_window_im); | |
764 #endif // TRACE_CALC_YOUNG_CONFIG | |
342 | 765 |
766 if (_young_list_target_length < _young_list_min_length) { | |
767 // bummer; this means that, if we do a pause when the optimal | |
768 // config dictates, we'll violate the pause spacing target (the | |
769 // min length was calculate based on the application's current | |
770 // alloc rate); | |
771 | |
772 // so, we have to bite the bullet, and allocate the minimum | |
773 // number. We'll violate our target, but we just can't meet it. | |
774 | |
775 size_t so_length = 0; | |
776 // a note further up explains why we do not want an S-O length | |
777 // during marking | |
778 if (!_in_marking_window && !_last_full_young_gc) | |
779 // but we can still try to see whether we can find an optimal | |
780 // S-O length | |
781 so_length = calculate_optimal_so_length(_young_list_min_length); | |
782 | |
545 | 783 #ifdef TRACE_CALC_YOUNG_CONFIG |
342 | 784 // leave this in for debugging, just in case |
785 gclog_or_tty->print_cr("adjusted target length from " | |
786 SIZE_FORMAT " to " SIZE_FORMAT | |
787 ", SO " SIZE_FORMAT, | |
788 _young_list_target_length, _young_list_min_length, | |
789 so_length); | |
545 | 790 #endif // TRACE_CALC_YOUNG_CONFIG |
342 | 791 |
792 _young_list_target_length = | |
793 MAX2(_young_list_min_length, (size_t)1); | |
794 _young_list_so_prefix_length = so_length; | |
795 } | |
796 } else { | |
797 // we are in a partially-young mode or we've run out of regions (due | |
798 // to evacuation failure) | |
799 | |
545 | 800 #ifdef TRACE_CALC_YOUNG_CONFIG |
342 | 801 // leave this in for debugging, just in case |
802 gclog_or_tty->print_cr("(partial) setting target to " SIZE_FORMAT | |
803 ", SO " SIZE_FORMAT, | |
804 _young_list_min_length, 0); | |
545 | 805 #endif // TRACE_CALC_YOUNG_CONFIG |
342 | 806 |
807 // we'll do the pause as soon as possible and with no S-O prefix | |
808 // (see above for the reasons behind the latter) | |
809 _young_list_target_length = | |
810 MAX2(_young_list_min_length, (size_t) 1); | |
811 _young_list_so_prefix_length = 0; | |
812 } | |
813 | |
814 _rs_lengths_prediction = rs_lengths; | |
815 } | |
816 | |
817 // This is used by: calculate_optimal_so_length(length). It returns | |
818 // the GC eff and predicted pause time for a particular config | |
819 void | |
820 G1CollectorPolicy::predict_gc_eff(size_t young_length, | |
821 size_t so_length, | |
822 double base_time_ms, | |
823 double* ret_gc_eff, | |
824 double* ret_pause_time_ms) { | |
825 double so_time_ms = predict_scan_only_time_ms(so_length); | |
826 double accum_surv_rate_adj = 0.0; | |
827 if (so_length > 0) | |
828 accum_surv_rate_adj = accum_yg_surv_rate_pred((int)(so_length - 1)); | |
829 double accum_surv_rate = | |
830 accum_yg_surv_rate_pred((int)(young_length - 1)) - accum_surv_rate_adj; | |
831 size_t bytes_to_copy = | |
832 (size_t) (accum_surv_rate * (double) HeapRegion::GrainBytes); | |
833 double copy_time_ms = predict_object_copy_time_ms(bytes_to_copy); | |
834 double young_other_time_ms = | |
835 predict_young_other_time_ms(young_length - so_length); | |
836 double pause_time_ms = | |
837 base_time_ms + so_time_ms + copy_time_ms + young_other_time_ms; | |
838 size_t reclaimed_bytes = | |
839 (young_length - so_length) * HeapRegion::GrainBytes - bytes_to_copy; | |
840 double gc_eff = (double) reclaimed_bytes / pause_time_ms; | |
841 | |
842 *ret_gc_eff = gc_eff; | |
843 *ret_pause_time_ms = pause_time_ms; | |
844 } | |
845 | |
846 // This is used by: calculate_young_list_target_config(rs_length). It | |
847 // returns the GC eff of a particular config. It returns false if that | |
848 // config violates any of the end conditions of the search in the | |
849 // calling method, or true upon success. The end conditions were put | |
850 // here since it's called twice and it was best not to replicate them | |
851 // in the caller. Also, passing the parameteres avoids having to | |
852 // recalculate them in the innermost loop. | |
853 bool | |
854 G1CollectorPolicy::predict_gc_eff(size_t young_length, | |
855 size_t so_length, | |
856 double base_time_with_so_ms, | |
857 size_t init_free_regions, | |
858 double target_pause_time_ms, | |
859 double* ret_gc_eff) { | |
860 *ret_gc_eff = 0.0; | |
861 | |
862 if (young_length >= init_free_regions) | |
863 // end condition 1: not enough space for the young regions | |
864 return false; | |
865 | |
866 double accum_surv_rate_adj = 0.0; | |
867 if (so_length > 0) | |
868 accum_surv_rate_adj = accum_yg_surv_rate_pred((int)(so_length - 1)); | |
869 double accum_surv_rate = | |
870 accum_yg_surv_rate_pred((int)(young_length - 1)) - accum_surv_rate_adj; | |
871 size_t bytes_to_copy = | |
872 (size_t) (accum_surv_rate * (double) HeapRegion::GrainBytes); | |
873 double copy_time_ms = predict_object_copy_time_ms(bytes_to_copy); | |
874 double young_other_time_ms = | |
875 predict_young_other_time_ms(young_length - so_length); | |
876 double pause_time_ms = | |
877 base_time_with_so_ms + copy_time_ms + young_other_time_ms; | |
878 | |
879 if (pause_time_ms > target_pause_time_ms) | |
880 // end condition 2: over the target pause time | |
881 return false; | |
882 | |
883 size_t reclaimed_bytes = | |
884 (young_length - so_length) * HeapRegion::GrainBytes - bytes_to_copy; | |
885 size_t free_bytes = | |
886 (init_free_regions - young_length) * HeapRegion::GrainBytes; | |
887 | |
888 if ((2.0 + sigma()) * (double) bytes_to_copy > (double) free_bytes) | |
889 // end condition 3: out of to-space (conservatively) | |
890 return false; | |
891 | |
892 // success! | |
893 double gc_eff = (double) reclaimed_bytes / pause_time_ms; | |
894 *ret_gc_eff = gc_eff; | |
895 | |
896 return true; | |
897 } | |
898 | |
545 | 899 double G1CollectorPolicy::predict_survivor_regions_evac_time() { |
900 double survivor_regions_evac_time = 0.0; | |
901 for (HeapRegion * r = _recorded_survivor_head; | |
902 r != NULL && r != _recorded_survivor_tail->get_next_young_region(); | |
903 r = r->get_next_young_region()) { | |
904 survivor_regions_evac_time += predict_region_elapsed_time_ms(r, true); | |
905 } | |
906 return survivor_regions_evac_time; | |
907 } | |
908 | |
342 | 909 void G1CollectorPolicy::check_prediction_validity() { |
910 guarantee( adaptive_young_list_length(), "should not call this otherwise" ); | |
911 | |
912 size_t rs_lengths = _g1->young_list_sampled_rs_lengths(); | |
913 if (rs_lengths > _rs_lengths_prediction) { | |
914 // add 10% to avoid having to recalculate often | |
915 size_t rs_lengths_prediction = rs_lengths * 1100 / 1000; | |
916 calculate_young_list_target_config(rs_lengths_prediction); | |
917 } | |
918 } | |
919 | |
920 HeapWord* G1CollectorPolicy::mem_allocate_work(size_t size, | |
921 bool is_tlab, | |
922 bool* gc_overhead_limit_was_exceeded) { | |
923 guarantee(false, "Not using this policy feature yet."); | |
924 return NULL; | |
925 } | |
926 | |
927 // This method controls how a collector handles one or more | |
928 // of its generations being fully allocated. | |
929 HeapWord* G1CollectorPolicy::satisfy_failed_allocation(size_t size, | |
930 bool is_tlab) { | |
931 guarantee(false, "Not using this policy feature yet."); | |
932 return NULL; | |
933 } | |
934 | |
935 | |
936 #ifndef PRODUCT | |
937 bool G1CollectorPolicy::verify_young_ages() { | |
938 HeapRegion* head = _g1->young_list_first_region(); | |
939 return | |
940 verify_young_ages(head, _short_lived_surv_rate_group); | |
941 // also call verify_young_ages on any additional surv rate groups | |
942 } | |
943 | |
944 bool | |
945 G1CollectorPolicy::verify_young_ages(HeapRegion* head, | |
946 SurvRateGroup *surv_rate_group) { | |
947 guarantee( surv_rate_group != NULL, "pre-condition" ); | |
948 | |
949 const char* name = surv_rate_group->name(); | |
950 bool ret = true; | |
951 int prev_age = -1; | |
952 | |
953 for (HeapRegion* curr = head; | |
954 curr != NULL; | |
955 curr = curr->get_next_young_region()) { | |
956 SurvRateGroup* group = curr->surv_rate_group(); | |
957 if (group == NULL && !curr->is_survivor()) { | |
958 gclog_or_tty->print_cr("## %s: encountered NULL surv_rate_group", name); | |
959 ret = false; | |
960 } | |
961 | |
962 if (surv_rate_group == group) { | |
963 int age = curr->age_in_surv_rate_group(); | |
964 | |
965 if (age < 0) { | |
966 gclog_or_tty->print_cr("## %s: encountered negative age", name); | |
967 ret = false; | |
968 } | |
969 | |
970 if (age <= prev_age) { | |
971 gclog_or_tty->print_cr("## %s: region ages are not strictly increasing " | |
972 "(%d, %d)", name, age, prev_age); | |
973 ret = false; | |
974 } | |
975 prev_age = age; | |
976 } | |
977 } | |
978 | |
979 return ret; | |
980 } | |
981 #endif // PRODUCT | |
982 | |
983 void G1CollectorPolicy::record_full_collection_start() { | |
984 _cur_collection_start_sec = os::elapsedTime(); | |
985 // Release the future to-space so that it is available for compaction into. | |
986 _g1->set_full_collection(); | |
987 } | |
988 | |
989 void G1CollectorPolicy::record_full_collection_end() { | |
990 // Consider this like a collection pause for the purposes of allocation | |
991 // since last pause. | |
992 double end_sec = os::elapsedTime(); | |
993 double full_gc_time_sec = end_sec - _cur_collection_start_sec; | |
994 double full_gc_time_ms = full_gc_time_sec * 1000.0; | |
995 | |
996 _all_full_gc_times_ms->add(full_gc_time_ms); | |
997 | |
595
3698e8f47799
6804746: G1: guarantee(variance() > -1.0,"variance should be >= 0") (due to evacuation failure)
tonyp
parents:
547
diff
changeset
|
998 update_recent_gc_times(end_sec, full_gc_time_ms); |
342 | 999 |
1000 _g1->clear_full_collection(); | |
1001 | |
1002 // "Nuke" the heuristics that control the fully/partially young GC | |
1003 // transitions and make sure we start with fully young GCs after the | |
1004 // Full GC. | |
1005 set_full_young_gcs(true); | |
1006 _last_full_young_gc = false; | |
1007 _should_revert_to_full_young_gcs = false; | |
1008 _should_initiate_conc_mark = false; | |
1009 _known_garbage_bytes = 0; | |
1010 _known_garbage_ratio = 0.0; | |
1011 _in_marking_window = false; | |
1012 _in_marking_window_im = false; | |
1013 | |
1014 _short_lived_surv_rate_group->record_scan_only_prefix(0); | |
1015 _short_lived_surv_rate_group->start_adding_regions(); | |
1016 // also call this on any additional surv rate groups | |
1017 | |
545 | 1018 record_survivor_regions(0, NULL, NULL); |
1019 | |
342 | 1020 _prev_region_num_young = _region_num_young; |
1021 _prev_region_num_tenured = _region_num_tenured; | |
1022 | |
1023 _free_regions_at_end_of_collection = _g1->free_regions(); | |
1024 _scan_only_regions_at_end_of_collection = 0; | |
545 | 1025 // Reset survivors SurvRateGroup. |
1026 _survivor_surv_rate_group->reset(); | |
342 | 1027 calculate_young_list_min_length(); |
1028 calculate_young_list_target_config(); | |
1029 } | |
1030 | |
1031 void G1CollectorPolicy::record_before_bytes(size_t bytes) { | |
1032 _bytes_in_to_space_before_gc += bytes; | |
1033 } | |
1034 | |
1035 void G1CollectorPolicy::record_after_bytes(size_t bytes) { | |
1036 _bytes_in_to_space_after_gc += bytes; | |
1037 } | |
1038 | |
1039 void G1CollectorPolicy::record_stop_world_start() { | |
1040 _stop_world_start = os::elapsedTime(); | |
1041 } | |
1042 | |
1043 void G1CollectorPolicy::record_collection_pause_start(double start_time_sec, | |
1044 size_t start_used) { | |
1045 if (PrintGCDetails) { | |
1046 gclog_or_tty->stamp(PrintGCTimeStamps); | |
1047 gclog_or_tty->print("[GC pause"); | |
1048 if (in_young_gc_mode()) | |
1049 gclog_or_tty->print(" (%s)", full_young_gcs() ? "young" : "partial"); | |
1050 } | |
1051 | |
1052 assert(_g1->used_regions() == _g1->recalculate_used_regions(), | |
1053 "sanity"); | |
636 | 1054 assert(_g1->used() == _g1->recalculate_used(), "sanity"); |
342 | 1055 |
1056 double s_w_t_ms = (start_time_sec - _stop_world_start) * 1000.0; | |
1057 _all_stop_world_times_ms->add(s_w_t_ms); | |
1058 _stop_world_start = 0.0; | |
1059 | |
1060 _cur_collection_start_sec = start_time_sec; | |
1061 _cur_collection_pause_used_at_start_bytes = start_used; | |
1062 _cur_collection_pause_used_regions_at_start = _g1->used_regions(); | |
1063 _pending_cards = _g1->pending_card_num(); | |
1064 _max_pending_cards = _g1->max_pending_card_num(); | |
1065 | |
1066 _bytes_in_to_space_before_gc = 0; | |
1067 _bytes_in_to_space_after_gc = 0; | |
1068 _bytes_in_collection_set_before_gc = 0; | |
1069 | |
1070 #ifdef DEBUG | |
1071 // initialise these to something well known so that we can spot | |
1072 // if they are not set properly | |
1073 | |
1074 for (int i = 0; i < _parallel_gc_threads; ++i) { | |
1075 _par_last_ext_root_scan_times_ms[i] = -666.0; | |
1076 _par_last_mark_stack_scan_times_ms[i] = -666.0; | |
1077 _par_last_scan_only_times_ms[i] = -666.0; | |
1078 _par_last_scan_only_regions_scanned[i] = -666.0; | |
1079 _par_last_update_rs_start_times_ms[i] = -666.0; | |
1080 _par_last_update_rs_times_ms[i] = -666.0; | |
1081 _par_last_update_rs_processed_buffers[i] = -666.0; | |
1082 _par_last_scan_rs_start_times_ms[i] = -666.0; | |
1083 _par_last_scan_rs_times_ms[i] = -666.0; | |
1084 _par_last_scan_new_refs_times_ms[i] = -666.0; | |
1085 _par_last_obj_copy_times_ms[i] = -666.0; | |
1086 _par_last_termination_times_ms[i] = -666.0; | |
1087 } | |
1088 #endif | |
1089 | |
1090 for (int i = 0; i < _aux_num; ++i) { | |
1091 _cur_aux_times_ms[i] = 0.0; | |
1092 _cur_aux_times_set[i] = false; | |
1093 } | |
1094 | |
1095 _satb_drain_time_set = false; | |
1096 _last_satb_drain_processed_buffers = -1; | |
1097 | |
1098 if (in_young_gc_mode()) | |
1099 _last_young_gc_full = false; | |
1100 | |
1101 | |
1102 // do that for any other surv rate groups | |
1103 _short_lived_surv_rate_group->stop_adding_regions(); | |
1104 size_t short_lived_so_length = _young_list_so_prefix_length; | |
1105 _short_lived_surv_rate_group->record_scan_only_prefix(short_lived_so_length); | |
1106 tag_scan_only(short_lived_so_length); | |
1107 | |
751 | 1108 if (G1UseSurvivorSpaces) { |
545 | 1109 _survivors_age_table.clear(); |
1110 } | |
1111 | |
342 | 1112 assert( verify_young_ages(), "region age verification" ); |
1113 } | |
1114 | |
1115 void G1CollectorPolicy::tag_scan_only(size_t short_lived_scan_only_length) { | |
1116 // done in a way that it can be extended for other surv rate groups too... | |
1117 | |
1118 HeapRegion* head = _g1->young_list_first_region(); | |
1119 bool finished_short_lived = (short_lived_scan_only_length == 0); | |
1120 | |
1121 if (finished_short_lived) | |
1122 return; | |
1123 | |
1124 for (HeapRegion* curr = head; | |
1125 curr != NULL; | |
1126 curr = curr->get_next_young_region()) { | |
1127 SurvRateGroup* surv_rate_group = curr->surv_rate_group(); | |
1128 int age = curr->age_in_surv_rate_group(); | |
1129 | |
1130 if (surv_rate_group == _short_lived_surv_rate_group) { | |
1131 if ((size_t)age < short_lived_scan_only_length) | |
1132 curr->set_scan_only(); | |
1133 else | |
1134 finished_short_lived = true; | |
1135 } | |
1136 | |
1137 | |
1138 if (finished_short_lived) | |
1139 return; | |
1140 } | |
1141 | |
1142 guarantee( false, "we should never reach here" ); | |
1143 } | |
1144 | |
1145 void G1CollectorPolicy::record_mark_closure_time(double mark_closure_time_ms) { | |
1146 _mark_closure_time_ms = mark_closure_time_ms; | |
1147 } | |
1148 | |
1149 void G1CollectorPolicy::record_concurrent_mark_init_start() { | |
1150 _mark_init_start_sec = os::elapsedTime(); | |
1151 guarantee(!in_young_gc_mode(), "should not do be here in young GC mode"); | |
1152 } | |
1153 | |
1154 void G1CollectorPolicy::record_concurrent_mark_init_end_pre(double | |
1155 mark_init_elapsed_time_ms) { | |
1156 _during_marking = true; | |
1157 _should_initiate_conc_mark = false; | |
1158 _cur_mark_stop_world_time_ms = mark_init_elapsed_time_ms; | |
1159 } | |
1160 | |
1161 void G1CollectorPolicy::record_concurrent_mark_init_end() { | |
1162 double end_time_sec = os::elapsedTime(); | |
1163 double elapsed_time_ms = (end_time_sec - _mark_init_start_sec) * 1000.0; | |
1164 _concurrent_mark_init_times_ms->add(elapsed_time_ms); | |
1165 record_concurrent_mark_init_end_pre(elapsed_time_ms); | |
1166 | |
1167 _mmu_tracker->add_pause(_mark_init_start_sec, end_time_sec, true); | |
1168 } | |
1169 | |
1170 void G1CollectorPolicy::record_concurrent_mark_remark_start() { | |
1171 _mark_remark_start_sec = os::elapsedTime(); | |
1172 _during_marking = false; | |
1173 } | |
1174 | |
1175 void G1CollectorPolicy::record_concurrent_mark_remark_end() { | |
1176 double end_time_sec = os::elapsedTime(); | |
1177 double elapsed_time_ms = (end_time_sec - _mark_remark_start_sec)*1000.0; | |
1178 _concurrent_mark_remark_times_ms->add(elapsed_time_ms); | |
1179 _cur_mark_stop_world_time_ms += elapsed_time_ms; | |
1180 _prev_collection_pause_end_ms += elapsed_time_ms; | |
1181 | |
1182 _mmu_tracker->add_pause(_mark_remark_start_sec, end_time_sec, true); | |
1183 } | |
1184 | |
1185 void G1CollectorPolicy::record_concurrent_mark_cleanup_start() { | |
1186 _mark_cleanup_start_sec = os::elapsedTime(); | |
1187 } | |
1188 | |
1189 void | |
1190 G1CollectorPolicy::record_concurrent_mark_cleanup_end(size_t freed_bytes, | |
1191 size_t max_live_bytes) { | |
1192 record_concurrent_mark_cleanup_end_work1(freed_bytes, max_live_bytes); | |
1193 record_concurrent_mark_cleanup_end_work2(); | |
1194 } | |
1195 | |
1196 void | |
1197 G1CollectorPolicy:: | |
1198 record_concurrent_mark_cleanup_end_work1(size_t freed_bytes, | |
1199 size_t max_live_bytes) { | |
1200 if (_n_marks < 2) _n_marks++; | |
1201 if (G1PolicyVerbose > 0) | |
1202 gclog_or_tty->print_cr("At end of marking, max_live is " SIZE_FORMAT " MB " | |
1203 " (of " SIZE_FORMAT " MB heap).", | |
1204 max_live_bytes/M, _g1->capacity()/M); | |
1205 } | |
1206 | |
1207 // The important thing about this is that it includes "os::elapsedTime". | |
1208 void G1CollectorPolicy::record_concurrent_mark_cleanup_end_work2() { | |
1209 double end_time_sec = os::elapsedTime(); | |
1210 double elapsed_time_ms = (end_time_sec - _mark_cleanup_start_sec)*1000.0; | |
1211 _concurrent_mark_cleanup_times_ms->add(elapsed_time_ms); | |
1212 _cur_mark_stop_world_time_ms += elapsed_time_ms; | |
1213 _prev_collection_pause_end_ms += elapsed_time_ms; | |
1214 | |
1215 _mmu_tracker->add_pause(_mark_cleanup_start_sec, end_time_sec, true); | |
1216 | |
1217 _num_markings++; | |
1218 | |
1219 // We did a marking, so reset the "since_last_mark" variables. | |
1220 double considerConcMarkCost = 1.0; | |
1221 // If there are available processors, concurrent activity is free... | |
1222 if (Threads::number_of_non_daemon_threads() * 2 < | |
1223 os::active_processor_count()) { | |
1224 considerConcMarkCost = 0.0; | |
1225 } | |
1226 _n_pauses_at_mark_end = _n_pauses; | |
1227 _n_marks_since_last_pause++; | |
1228 _conc_mark_initiated = false; | |
1229 } | |
1230 | |
1231 void | |
1232 G1CollectorPolicy::record_concurrent_mark_cleanup_completed() { | |
1233 if (in_young_gc_mode()) { | |
1234 _should_revert_to_full_young_gcs = false; | |
1235 _last_full_young_gc = true; | |
1236 _in_marking_window = false; | |
1237 if (adaptive_young_list_length()) | |
1238 calculate_young_list_target_config(); | |
1239 } | |
1240 } | |
1241 | |
1242 void G1CollectorPolicy::record_concurrent_pause() { | |
1243 if (_stop_world_start > 0.0) { | |
1244 double yield_ms = (os::elapsedTime() - _stop_world_start) * 1000.0; | |
1245 _all_yield_times_ms->add(yield_ms); | |
1246 } | |
1247 } | |
1248 | |
1249 void G1CollectorPolicy::record_concurrent_pause_end() { | |
1250 } | |
1251 | |
1252 void G1CollectorPolicy::record_collection_pause_end_CH_strong_roots() { | |
1253 _cur_CH_strong_roots_end_sec = os::elapsedTime(); | |
1254 _cur_CH_strong_roots_dur_ms = | |
1255 (_cur_CH_strong_roots_end_sec - _cur_collection_start_sec) * 1000.0; | |
1256 } | |
1257 | |
1258 void G1CollectorPolicy::record_collection_pause_end_G1_strong_roots() { | |
1259 _cur_G1_strong_roots_end_sec = os::elapsedTime(); | |
1260 _cur_G1_strong_roots_dur_ms = | |
1261 (_cur_G1_strong_roots_end_sec - _cur_CH_strong_roots_end_sec) * 1000.0; | |
1262 } | |
1263 | |
1264 template<class T> | |
1265 T sum_of(T* sum_arr, int start, int n, int N) { | |
1266 T sum = (T)0; | |
1267 for (int i = 0; i < n; i++) { | |
1268 int j = (start + i) % N; | |
1269 sum += sum_arr[j]; | |
1270 } | |
1271 return sum; | |
1272 } | |
1273 | |
1274 void G1CollectorPolicy::print_par_stats (int level, | |
1275 const char* str, | |
1276 double* data, | |
1277 bool summary) { | |
1278 double min = data[0], max = data[0]; | |
1279 double total = 0.0; | |
1280 int j; | |
1281 for (j = 0; j < level; ++j) | |
1282 gclog_or_tty->print(" "); | |
1283 gclog_or_tty->print("[%s (ms):", str); | |
1284 for (uint i = 0; i < ParallelGCThreads; ++i) { | |
1285 double val = data[i]; | |
1286 if (val < min) | |
1287 min = val; | |
1288 if (val > max) | |
1289 max = val; | |
1290 total += val; | |
1291 gclog_or_tty->print(" %3.1lf", val); | |
1292 } | |
1293 if (summary) { | |
1294 gclog_or_tty->print_cr(""); | |
1295 double avg = total / (double) ParallelGCThreads; | |
1296 gclog_or_tty->print(" "); | |
1297 for (j = 0; j < level; ++j) | |
1298 gclog_or_tty->print(" "); | |
1299 gclog_or_tty->print("Avg: %5.1lf, Min: %5.1lf, Max: %5.1lf", | |
1300 avg, min, max); | |
1301 } | |
1302 gclog_or_tty->print_cr("]"); | |
1303 } | |
1304 | |
1305 void G1CollectorPolicy::print_par_buffers (int level, | |
1306 const char* str, | |
1307 double* data, | |
1308 bool summary) { | |
1309 double min = data[0], max = data[0]; | |
1310 double total = 0.0; | |
1311 int j; | |
1312 for (j = 0; j < level; ++j) | |
1313 gclog_or_tty->print(" "); | |
1314 gclog_or_tty->print("[%s :", str); | |
1315 for (uint i = 0; i < ParallelGCThreads; ++i) { | |
1316 double val = data[i]; | |
1317 if (val < min) | |
1318 min = val; | |
1319 if (val > max) | |
1320 max = val; | |
1321 total += val; | |
1322 gclog_or_tty->print(" %d", (int) val); | |
1323 } | |
1324 if (summary) { | |
1325 gclog_or_tty->print_cr(""); | |
1326 double avg = total / (double) ParallelGCThreads; | |
1327 gclog_or_tty->print(" "); | |
1328 for (j = 0; j < level; ++j) | |
1329 gclog_or_tty->print(" "); | |
1330 gclog_or_tty->print("Sum: %d, Avg: %d, Min: %d, Max: %d", | |
1331 (int)total, (int)avg, (int)min, (int)max); | |
1332 } | |
1333 gclog_or_tty->print_cr("]"); | |
1334 } | |
1335 | |
1336 void G1CollectorPolicy::print_stats (int level, | |
1337 const char* str, | |
1338 double value) { | |
1339 for (int j = 0; j < level; ++j) | |
1340 gclog_or_tty->print(" "); | |
1341 gclog_or_tty->print_cr("[%s: %5.1lf ms]", str, value); | |
1342 } | |
1343 | |
1344 void G1CollectorPolicy::print_stats (int level, | |
1345 const char* str, | |
1346 int value) { | |
1347 for (int j = 0; j < level; ++j) | |
1348 gclog_or_tty->print(" "); | |
1349 gclog_or_tty->print_cr("[%s: %d]", str, value); | |
1350 } | |
1351 | |
1352 double G1CollectorPolicy::avg_value (double* data) { | |
1353 if (ParallelGCThreads > 0) { | |
1354 double ret = 0.0; | |
1355 for (uint i = 0; i < ParallelGCThreads; ++i) | |
1356 ret += data[i]; | |
1357 return ret / (double) ParallelGCThreads; | |
1358 } else { | |
1359 return data[0]; | |
1360 } | |
1361 } | |
1362 | |
1363 double G1CollectorPolicy::max_value (double* data) { | |
1364 if (ParallelGCThreads > 0) { | |
1365 double ret = data[0]; | |
1366 for (uint i = 1; i < ParallelGCThreads; ++i) | |
1367 if (data[i] > ret) | |
1368 ret = data[i]; | |
1369 return ret; | |
1370 } else { | |
1371 return data[0]; | |
1372 } | |
1373 } | |
1374 | |
1375 double G1CollectorPolicy::sum_of_values (double* data) { | |
1376 if (ParallelGCThreads > 0) { | |
1377 double sum = 0.0; | |
1378 for (uint i = 0; i < ParallelGCThreads; i++) | |
1379 sum += data[i]; | |
1380 return sum; | |
1381 } else { | |
1382 return data[0]; | |
1383 } | |
1384 } | |
1385 | |
1386 double G1CollectorPolicy::max_sum (double* data1, | |
1387 double* data2) { | |
1388 double ret = data1[0] + data2[0]; | |
1389 | |
1390 if (ParallelGCThreads > 0) { | |
1391 for (uint i = 1; i < ParallelGCThreads; ++i) { | |
1392 double data = data1[i] + data2[i]; | |
1393 if (data > ret) | |
1394 ret = data; | |
1395 } | |
1396 } | |
1397 return ret; | |
1398 } | |
1399 | |
1400 // Anything below that is considered to be zero | |
1401 #define MIN_TIMER_GRANULARITY 0.0000001 | |
1402 | |
677 | 1403 void G1CollectorPolicy::record_collection_pause_end(bool abandoned) { |
342 | 1404 double end_time_sec = os::elapsedTime(); |
1405 double elapsed_ms = _last_pause_time_ms; | |
1406 bool parallel = ParallelGCThreads > 0; | |
1407 double evac_ms = (end_time_sec - _cur_G1_strong_roots_end_sec) * 1000.0; | |
1408 size_t rs_size = | |
1409 _cur_collection_pause_used_regions_at_start - collection_set_size(); | |
1410 size_t cur_used_bytes = _g1->used(); | |
1411 assert(cur_used_bytes == _g1->recalculate_used(), "It should!"); | |
1412 bool last_pause_included_initial_mark = false; | |
595
3698e8f47799
6804746: G1: guarantee(variance() > -1.0,"variance should be >= 0") (due to evacuation failure)
tonyp
parents:
547
diff
changeset
|
1413 bool update_stats = !abandoned && !_g1->evacuation_failed(); |
342 | 1414 |
1415 #ifndef PRODUCT | |
1416 if (G1YoungSurvRateVerbose) { | |
1417 gclog_or_tty->print_cr(""); | |
1418 _short_lived_surv_rate_group->print(); | |
1419 // do that for any other surv rate groups too | |
1420 } | |
1421 #endif // PRODUCT | |
1422 | |
1423 if (in_young_gc_mode()) { | |
1424 last_pause_included_initial_mark = _should_initiate_conc_mark; | |
1425 if (last_pause_included_initial_mark) | |
1426 record_concurrent_mark_init_end_pre(0.0); | |
1427 | |
1428 size_t min_used_targ = | |
1429 (_g1->capacity() / 100) * (G1SteadyStateUsed - G1SteadyStateUsedDelta); | |
1430 | |
1431 if (cur_used_bytes > min_used_targ) { | |
1432 if (cur_used_bytes <= _prev_collection_pause_used_at_end_bytes) { | |
1433 } else if (!_g1->mark_in_progress() && !_last_full_young_gc) { | |
1434 _should_initiate_conc_mark = true; | |
1435 } | |
1436 } | |
1437 | |
1438 _prev_collection_pause_used_at_end_bytes = cur_used_bytes; | |
1439 } | |
1440 | |
1441 _mmu_tracker->add_pause(end_time_sec - elapsed_ms/1000.0, | |
1442 end_time_sec, false); | |
1443 | |
1444 guarantee(_cur_collection_pause_used_regions_at_start >= | |
1445 collection_set_size(), | |
1446 "Negative RS size?"); | |
1447 | |
1448 // This assert is exempted when we're doing parallel collection pauses, | |
1449 // because the fragmentation caused by the parallel GC allocation buffers | |
1450 // can lead to more memory being used during collection than was used | |
1451 // before. Best leave this out until the fragmentation problem is fixed. | |
1452 // Pauses in which evacuation failed can also lead to negative | |
1453 // collections, since no space is reclaimed from a region containing an | |
1454 // object whose evacuation failed. | |
1455 // Further, we're now always doing parallel collection. But I'm still | |
1456 // leaving this here as a placeholder for a more precise assertion later. | |
1457 // (DLD, 10/05.) | |
1458 assert((true || parallel) // Always using GC LABs now. | |
1459 || _g1->evacuation_failed() | |
1460 || _cur_collection_pause_used_at_start_bytes >= cur_used_bytes, | |
1461 "Negative collection"); | |
1462 | |
1463 size_t freed_bytes = | |
1464 _cur_collection_pause_used_at_start_bytes - cur_used_bytes; | |
1465 size_t surviving_bytes = _collection_set_bytes_used_before - freed_bytes; | |
1466 double survival_fraction = | |
1467 (double)surviving_bytes/ | |
1468 (double)_collection_set_bytes_used_before; | |
1469 | |
1470 _n_pauses++; | |
1471 | |
595
3698e8f47799
6804746: G1: guarantee(variance() > -1.0,"variance should be >= 0") (due to evacuation failure)
tonyp
parents:
547
diff
changeset
|
1472 if (update_stats) { |
342 | 1473 _recent_CH_strong_roots_times_ms->add(_cur_CH_strong_roots_dur_ms); |
1474 _recent_G1_strong_roots_times_ms->add(_cur_G1_strong_roots_dur_ms); | |
1475 _recent_evac_times_ms->add(evac_ms); | |
1476 _recent_pause_times_ms->add(elapsed_ms); | |
1477 | |
1478 _recent_rs_sizes->add(rs_size); | |
1479 | |
1480 // We exempt parallel collection from this check because Alloc Buffer | |
1481 // fragmentation can produce negative collections. Same with evac | |
1482 // failure. | |
1483 // Further, we're now always doing parallel collection. But I'm still | |
1484 // leaving this here as a placeholder for a more precise assertion later. | |
1485 // (DLD, 10/05. | |
1486 assert((true || parallel) | |
1487 || _g1->evacuation_failed() | |
1488 || surviving_bytes <= _collection_set_bytes_used_before, | |
1489 "Or else negative collection!"); | |
1490 _recent_CS_bytes_used_before->add(_collection_set_bytes_used_before); | |
1491 _recent_CS_bytes_surviving->add(surviving_bytes); | |
1492 | |
1493 // this is where we update the allocation rate of the application | |
1494 double app_time_ms = | |
1495 (_cur_collection_start_sec * 1000.0 - _prev_collection_pause_end_ms); | |
1496 if (app_time_ms < MIN_TIMER_GRANULARITY) { | |
1497 // This usually happens due to the timer not having the required | |
1498 // granularity. Some Linuxes are the usual culprits. | |
1499 // We'll just set it to something (arbitrarily) small. | |
1500 app_time_ms = 1.0; | |
1501 } | |
1502 size_t regions_allocated = | |
1503 (_region_num_young - _prev_region_num_young) + | |
1504 (_region_num_tenured - _prev_region_num_tenured); | |
1505 double alloc_rate_ms = (double) regions_allocated / app_time_ms; | |
1506 _alloc_rate_ms_seq->add(alloc_rate_ms); | |
1507 _prev_region_num_young = _region_num_young; | |
1508 _prev_region_num_tenured = _region_num_tenured; | |
1509 | |
1510 double interval_ms = | |
1511 (end_time_sec - _recent_prev_end_times_for_all_gcs_sec->oldest()) * 1000.0; | |
1512 update_recent_gc_times(end_time_sec, elapsed_ms); | |
1513 _recent_avg_pause_time_ratio = _recent_gc_times_ms->sum()/interval_ms; | |
1514 assert(recent_avg_pause_time_ratio() < 1.00, "All GC?"); | |
1515 } | |
1516 | |
1517 if (G1PolicyVerbose > 1) { | |
1518 gclog_or_tty->print_cr(" Recording collection pause(%d)", _n_pauses); | |
1519 } | |
1520 | |
1521 PauseSummary* summary; | |
677 | 1522 if (abandoned) { |
1523 summary = _abandoned_summary; | |
1524 } else { | |
1525 summary = _summary; | |
342 | 1526 } |
1527 | |
1528 double ext_root_scan_time = avg_value(_par_last_ext_root_scan_times_ms); | |
1529 double mark_stack_scan_time = avg_value(_par_last_mark_stack_scan_times_ms); | |
1530 double scan_only_time = avg_value(_par_last_scan_only_times_ms); | |
1531 double scan_only_regions_scanned = | |
1532 sum_of_values(_par_last_scan_only_regions_scanned); | |
1533 double update_rs_time = avg_value(_par_last_update_rs_times_ms); | |
1534 double update_rs_processed_buffers = | |
1535 sum_of_values(_par_last_update_rs_processed_buffers); | |
1536 double scan_rs_time = avg_value(_par_last_scan_rs_times_ms); | |
1537 double obj_copy_time = avg_value(_par_last_obj_copy_times_ms); | |
1538 double termination_time = avg_value(_par_last_termination_times_ms); | |
1539 | |
648
2314b7336582
6820321: G1: Error: guarantee(check_nums(total, n, parts), "all seq lengths should match")
tonyp
parents:
640
diff
changeset
|
1540 double parallel_other_time = _cur_collection_par_time_ms - |
2314b7336582
6820321: G1: Error: guarantee(check_nums(total, n, parts), "all seq lengths should match")
tonyp
parents:
640
diff
changeset
|
1541 (update_rs_time + ext_root_scan_time + mark_stack_scan_time + |
2314b7336582
6820321: G1: Error: guarantee(check_nums(total, n, parts), "all seq lengths should match")
tonyp
parents:
640
diff
changeset
|
1542 scan_only_time + scan_rs_time + obj_copy_time + termination_time); |
595
3698e8f47799
6804746: G1: guarantee(variance() > -1.0,"variance should be >= 0") (due to evacuation failure)
tonyp
parents:
547
diff
changeset
|
1543 if (update_stats) { |
342 | 1544 MainBodySummary* body_summary = summary->main_body_summary(); |
1545 guarantee(body_summary != NULL, "should not be null!"); | |
1546 | |
1547 if (_satb_drain_time_set) | |
1548 body_summary->record_satb_drain_time_ms(_cur_satb_drain_time_ms); | |
1549 else | |
1550 body_summary->record_satb_drain_time_ms(0.0); | |
1551 body_summary->record_ext_root_scan_time_ms(ext_root_scan_time); | |
1552 body_summary->record_mark_stack_scan_time_ms(mark_stack_scan_time); | |
1553 body_summary->record_scan_only_time_ms(scan_only_time); | |
1554 body_summary->record_update_rs_time_ms(update_rs_time); | |
1555 body_summary->record_scan_rs_time_ms(scan_rs_time); | |
1556 body_summary->record_obj_copy_time_ms(obj_copy_time); | |
1557 if (parallel) { | |
1558 body_summary->record_parallel_time_ms(_cur_collection_par_time_ms); | |
1559 body_summary->record_clear_ct_time_ms(_cur_clear_ct_time_ms); | |
1560 body_summary->record_termination_time_ms(termination_time); | |
1561 body_summary->record_parallel_other_time_ms(parallel_other_time); | |
1562 } | |
1563 body_summary->record_mark_closure_time_ms(_mark_closure_time_ms); | |
1564 } | |
1565 | |
1566 if (G1PolicyVerbose > 1) { | |
1567 gclog_or_tty->print_cr(" ET: %10.6f ms (avg: %10.6f ms)\n" | |
1568 " CH Strong: %10.6f ms (avg: %10.6f ms)\n" | |
1569 " G1 Strong: %10.6f ms (avg: %10.6f ms)\n" | |
1570 " Evac: %10.6f ms (avg: %10.6f ms)\n" | |
1571 " ET-RS: %10.6f ms (avg: %10.6f ms)\n" | |
1572 " |RS|: " SIZE_FORMAT, | |
1573 elapsed_ms, recent_avg_time_for_pauses_ms(), | |
1574 _cur_CH_strong_roots_dur_ms, recent_avg_time_for_CH_strong_ms(), | |
1575 _cur_G1_strong_roots_dur_ms, recent_avg_time_for_G1_strong_ms(), | |
1576 evac_ms, recent_avg_time_for_evac_ms(), | |
1577 scan_rs_time, | |
1578 recent_avg_time_for_pauses_ms() - | |
1579 recent_avg_time_for_G1_strong_ms(), | |
1580 rs_size); | |
1581 | |
1582 gclog_or_tty->print_cr(" Used at start: " SIZE_FORMAT"K" | |
1583 " At end " SIZE_FORMAT "K\n" | |
1584 " garbage : " SIZE_FORMAT "K" | |
1585 " of " SIZE_FORMAT "K\n" | |
1586 " survival : %6.2f%% (%6.2f%% avg)", | |
1587 _cur_collection_pause_used_at_start_bytes/K, | |
1588 _g1->used()/K, freed_bytes/K, | |
1589 _collection_set_bytes_used_before/K, | |
1590 survival_fraction*100.0, | |
1591 recent_avg_survival_fraction()*100.0); | |
1592 gclog_or_tty->print_cr(" Recent %% gc pause time: %6.2f", | |
1593 recent_avg_pause_time_ratio() * 100.0); | |
1594 } | |
1595 | |
1596 double other_time_ms = elapsed_ms; | |
1597 | |
1598 if (!abandoned) { | |
1599 if (_satb_drain_time_set) | |
1600 other_time_ms -= _cur_satb_drain_time_ms; | |
1601 | |
1602 if (parallel) | |
1603 other_time_ms -= _cur_collection_par_time_ms + _cur_clear_ct_time_ms; | |
1604 else | |
1605 other_time_ms -= | |
1606 update_rs_time + | |
1607 ext_root_scan_time + mark_stack_scan_time + scan_only_time + | |
1608 scan_rs_time + obj_copy_time; | |
1609 } | |
1610 | |
1611 if (PrintGCDetails) { | |
1612 gclog_or_tty->print_cr("%s%s, %1.8lf secs]", | |
677 | 1613 abandoned ? " (abandoned)" : "", |
342 | 1614 (last_pause_included_initial_mark) ? " (initial-mark)" : "", |
1615 elapsed_ms / 1000.0); | |
1616 | |
1617 if (!abandoned) { | |
677 | 1618 if (_satb_drain_time_set) { |
342 | 1619 print_stats(1, "SATB Drain Time", _cur_satb_drain_time_ms); |
677 | 1620 } |
1621 if (_last_satb_drain_processed_buffers >= 0) { | |
342 | 1622 print_stats(2, "Processed Buffers", _last_satb_drain_processed_buffers); |
677 | 1623 } |
1624 if (parallel) { | |
1625 print_stats(1, "Parallel Time", _cur_collection_par_time_ms); | |
1626 print_par_stats(2, "Update RS (Start)", _par_last_update_rs_start_times_ms, false); | |
1627 print_par_stats(2, "Update RS", _par_last_update_rs_times_ms); | |
794 | 1628 print_par_buffers(3, "Processed Buffers", |
1629 _par_last_update_rs_processed_buffers, true); | |
342 | 1630 print_par_stats(2, "Ext Root Scanning", _par_last_ext_root_scan_times_ms); |
1631 print_par_stats(2, "Mark Stack Scanning", _par_last_mark_stack_scan_times_ms); | |
1632 print_par_stats(2, "Scan-Only Scanning", _par_last_scan_only_times_ms); | |
1633 print_par_buffers(3, "Scan-Only Regions", | |
1634 _par_last_scan_only_regions_scanned, true); | |
1635 print_par_stats(2, "Scan RS", _par_last_scan_rs_times_ms); | |
1636 print_par_stats(2, "Object Copy", _par_last_obj_copy_times_ms); | |
1637 print_par_stats(2, "Termination", _par_last_termination_times_ms); | |
1638 print_stats(2, "Other", parallel_other_time); | |
1639 print_stats(1, "Clear CT", _cur_clear_ct_time_ms); | |
677 | 1640 } else { |
1641 print_stats(1, "Update RS", update_rs_time); | |
794 | 1642 print_stats(2, "Processed Buffers", |
1643 (int)update_rs_processed_buffers); | |
342 | 1644 print_stats(1, "Ext Root Scanning", ext_root_scan_time); |
1645 print_stats(1, "Mark Stack Scanning", mark_stack_scan_time); | |
1646 print_stats(1, "Scan-Only Scanning", scan_only_time); | |
1647 print_stats(1, "Scan RS", scan_rs_time); | |
1648 print_stats(1, "Object Copying", obj_copy_time); | |
1649 } | |
1650 } | |
890
6cb8e9df7174
6819077: G1: first GC thread coming late into the GC.
johnc
parents:
845
diff
changeset
|
1651 #ifndef PRODUCT |
6cb8e9df7174
6819077: G1: first GC thread coming late into the GC.
johnc
parents:
845
diff
changeset
|
1652 print_stats(1, "Cur Clear CC", _cur_clear_cc_time_ms); |
6cb8e9df7174
6819077: G1: first GC thread coming late into the GC.
johnc
parents:
845
diff
changeset
|
1653 print_stats(1, "Cum Clear CC", _cum_clear_cc_time_ms); |
6cb8e9df7174
6819077: G1: first GC thread coming late into the GC.
johnc
parents:
845
diff
changeset
|
1654 print_stats(1, "Min Clear CC", _min_clear_cc_time_ms); |
6cb8e9df7174
6819077: G1: first GC thread coming late into the GC.
johnc
parents:
845
diff
changeset
|
1655 print_stats(1, "Max Clear CC", _max_clear_cc_time_ms); |
6cb8e9df7174
6819077: G1: first GC thread coming late into the GC.
johnc
parents:
845
diff
changeset
|
1656 if (_num_cc_clears > 0) { |
6cb8e9df7174
6819077: G1: first GC thread coming late into the GC.
johnc
parents:
845
diff
changeset
|
1657 print_stats(1, "Avg Clear CC", _cum_clear_cc_time_ms / ((double)_num_cc_clears)); |
6cb8e9df7174
6819077: G1: first GC thread coming late into the GC.
johnc
parents:
845
diff
changeset
|
1658 } |
6cb8e9df7174
6819077: G1: first GC thread coming late into the GC.
johnc
parents:
845
diff
changeset
|
1659 #endif |
342 | 1660 print_stats(1, "Other", other_time_ms); |
1661 for (int i = 0; i < _aux_num; ++i) { | |
1662 if (_cur_aux_times_set[i]) { | |
1663 char buffer[96]; | |
1664 sprintf(buffer, "Aux%d", i); | |
1665 print_stats(1, buffer, _cur_aux_times_ms[i]); | |
1666 } | |
1667 } | |
1668 } | |
1669 if (PrintGCDetails) | |
1670 gclog_or_tty->print(" ["); | |
1671 if (PrintGC || PrintGCDetails) | |
1672 _g1->print_size_transition(gclog_or_tty, | |
1673 _cur_collection_pause_used_at_start_bytes, | |
1674 _g1->used(), _g1->capacity()); | |
1675 if (PrintGCDetails) | |
1676 gclog_or_tty->print_cr("]"); | |
1677 | |
1678 _all_pause_times_ms->add(elapsed_ms); | |
648
2314b7336582
6820321: G1: Error: guarantee(check_nums(total, n, parts), "all seq lengths should match")
tonyp
parents:
640
diff
changeset
|
1679 if (update_stats) { |
2314b7336582
6820321: G1: Error: guarantee(check_nums(total, n, parts), "all seq lengths should match")
tonyp
parents:
640
diff
changeset
|
1680 summary->record_total_time_ms(elapsed_ms); |
2314b7336582
6820321: G1: Error: guarantee(check_nums(total, n, parts), "all seq lengths should match")
tonyp
parents:
640
diff
changeset
|
1681 summary->record_other_time_ms(other_time_ms); |
2314b7336582
6820321: G1: Error: guarantee(check_nums(total, n, parts), "all seq lengths should match")
tonyp
parents:
640
diff
changeset
|
1682 } |
342 | 1683 for (int i = 0; i < _aux_num; ++i) |
1684 if (_cur_aux_times_set[i]) | |
1685 _all_aux_times_ms[i].add(_cur_aux_times_ms[i]); | |
1686 | |
1687 // Reset marks-between-pauses counter. | |
1688 _n_marks_since_last_pause = 0; | |
1689 | |
1690 // Update the efficiency-since-mark vars. | |
1691 double proc_ms = elapsed_ms * (double) _parallel_gc_threads; | |
1692 if (elapsed_ms < MIN_TIMER_GRANULARITY) { | |
1693 // This usually happens due to the timer not having the required | |
1694 // granularity. Some Linuxes are the usual culprits. | |
1695 // We'll just set it to something (arbitrarily) small. | |
1696 proc_ms = 1.0; | |
1697 } | |
1698 double cur_efficiency = (double) freed_bytes / proc_ms; | |
1699 | |
1700 bool new_in_marking_window = _in_marking_window; | |
1701 bool new_in_marking_window_im = false; | |
1702 if (_should_initiate_conc_mark) { | |
1703 new_in_marking_window = true; | |
1704 new_in_marking_window_im = true; | |
1705 } | |
1706 | |
1707 if (in_young_gc_mode()) { | |
1708 if (_last_full_young_gc) { | |
1709 set_full_young_gcs(false); | |
1710 _last_full_young_gc = false; | |
1711 } | |
1712 | |
1713 if ( !_last_young_gc_full ) { | |
1714 if ( _should_revert_to_full_young_gcs || | |
1715 _known_garbage_ratio < 0.05 || | |
1716 (adaptive_young_list_length() && | |
1717 (get_gc_eff_factor() * cur_efficiency < predict_young_gc_eff())) ) { | |
1718 set_full_young_gcs(true); | |
1719 } | |
1720 } | |
1721 _should_revert_to_full_young_gcs = false; | |
1722 | |
1723 if (_last_young_gc_full && !_during_marking) | |
1724 _young_gc_eff_seq->add(cur_efficiency); | |
1725 } | |
1726 | |
1727 _short_lived_surv_rate_group->start_adding_regions(); | |
1728 // do that for any other surv rate groupsx | |
1729 | |
1730 // <NEW PREDICTION> | |
1731 | |
677 | 1732 if (update_stats) { |
342 | 1733 double pause_time_ms = elapsed_ms; |
1734 | |
1735 size_t diff = 0; | |
1736 if (_max_pending_cards >= _pending_cards) | |
1737 diff = _max_pending_cards - _pending_cards; | |
1738 _pending_card_diff_seq->add((double) diff); | |
1739 | |
1740 double cost_per_card_ms = 0.0; | |
1741 if (_pending_cards > 0) { | |
1742 cost_per_card_ms = update_rs_time / (double) _pending_cards; | |
1743 _cost_per_card_ms_seq->add(cost_per_card_ms); | |
1744 } | |
1745 | |
1746 double cost_per_scan_only_region_ms = 0.0; | |
1747 if (scan_only_regions_scanned > 0.0) { | |
1748 cost_per_scan_only_region_ms = | |
1749 scan_only_time / scan_only_regions_scanned; | |
1750 if (_in_marking_window_im) | |
1751 _cost_per_scan_only_region_ms_during_cm_seq->add(cost_per_scan_only_region_ms); | |
1752 else | |
1753 _cost_per_scan_only_region_ms_seq->add(cost_per_scan_only_region_ms); | |
1754 } | |
1755 | |
1756 size_t cards_scanned = _g1->cards_scanned(); | |
1757 | |
1758 double cost_per_entry_ms = 0.0; | |
1759 if (cards_scanned > 10) { | |
1760 cost_per_entry_ms = scan_rs_time / (double) cards_scanned; | |
1761 if (_last_young_gc_full) | |
1762 _cost_per_entry_ms_seq->add(cost_per_entry_ms); | |
1763 else | |
1764 _partially_young_cost_per_entry_ms_seq->add(cost_per_entry_ms); | |
1765 } | |
1766 | |
1767 if (_max_rs_lengths > 0) { | |
1768 double cards_per_entry_ratio = | |
1769 (double) cards_scanned / (double) _max_rs_lengths; | |
1770 if (_last_young_gc_full) | |
1771 _fully_young_cards_per_entry_ratio_seq->add(cards_per_entry_ratio); | |
1772 else | |
1773 _partially_young_cards_per_entry_ratio_seq->add(cards_per_entry_ratio); | |
1774 } | |
1775 | |
1776 size_t rs_length_diff = _max_rs_lengths - _recorded_rs_lengths; | |
1777 if (rs_length_diff >= 0) | |
1778 _rs_length_diff_seq->add((double) rs_length_diff); | |
1779 | |
1780 size_t copied_bytes = surviving_bytes; | |
1781 double cost_per_byte_ms = 0.0; | |
1782 if (copied_bytes > 0) { | |
1783 cost_per_byte_ms = obj_copy_time / (double) copied_bytes; | |
1784 if (_in_marking_window) | |
1785 _cost_per_byte_ms_during_cm_seq->add(cost_per_byte_ms); | |
1786 else | |
1787 _cost_per_byte_ms_seq->add(cost_per_byte_ms); | |
1788 } | |
1789 | |
1790 double all_other_time_ms = pause_time_ms - | |
1791 (update_rs_time + scan_only_time + scan_rs_time + obj_copy_time + | |
1792 _mark_closure_time_ms + termination_time); | |
1793 | |
1794 double young_other_time_ms = 0.0; | |
1795 if (_recorded_young_regions > 0) { | |
1796 young_other_time_ms = | |
1797 _recorded_young_cset_choice_time_ms + | |
1798 _recorded_young_free_cset_time_ms; | |
1799 _young_other_cost_per_region_ms_seq->add(young_other_time_ms / | |
1800 (double) _recorded_young_regions); | |
1801 } | |
1802 double non_young_other_time_ms = 0.0; | |
1803 if (_recorded_non_young_regions > 0) { | |
1804 non_young_other_time_ms = | |
1805 _recorded_non_young_cset_choice_time_ms + | |
1806 _recorded_non_young_free_cset_time_ms; | |
1807 | |
1808 _non_young_other_cost_per_region_ms_seq->add(non_young_other_time_ms / | |
1809 (double) _recorded_non_young_regions); | |
1810 } | |
1811 | |
1812 double constant_other_time_ms = all_other_time_ms - | |
1813 (young_other_time_ms + non_young_other_time_ms); | |
1814 _constant_other_time_ms_seq->add(constant_other_time_ms); | |
1815 | |
1816 double survival_ratio = 0.0; | |
1817 if (_bytes_in_collection_set_before_gc > 0) { | |
1818 survival_ratio = (double) bytes_in_to_space_during_gc() / | |
1819 (double) _bytes_in_collection_set_before_gc; | |
1820 } | |
1821 | |
1822 _pending_cards_seq->add((double) _pending_cards); | |
1823 _scanned_cards_seq->add((double) cards_scanned); | |
1824 _rs_lengths_seq->add((double) _max_rs_lengths); | |
1825 | |
1826 double expensive_region_limit_ms = | |
751 | 1827 (double) MaxGCPauseMillis - predict_constant_other_time_ms(); |
342 | 1828 if (expensive_region_limit_ms < 0.0) { |
1829 // this means that the other time was predicted to be longer than | |
1830 // than the max pause time | |
751 | 1831 expensive_region_limit_ms = (double) MaxGCPauseMillis; |
342 | 1832 } |
1833 _expensive_region_limit_ms = expensive_region_limit_ms; | |
1834 | |
1835 if (PREDICTIONS_VERBOSE) { | |
1836 gclog_or_tty->print_cr(""); | |
1837 gclog_or_tty->print_cr("PREDICTIONS %1.4lf %d " | |
1838 "REGIONS %d %d %d %d " | |
1839 "PENDING_CARDS %d %d " | |
1840 "CARDS_SCANNED %d %d " | |
1841 "RS_LENGTHS %d %d " | |
1842 "SCAN_ONLY_SCAN %1.6lf %1.6lf " | |
1843 "RS_UPDATE %1.6lf %1.6lf RS_SCAN %1.6lf %1.6lf " | |
1844 "SURVIVAL_RATIO %1.6lf %1.6lf " | |
1845 "OBJECT_COPY %1.6lf %1.6lf OTHER_CONSTANT %1.6lf %1.6lf " | |
1846 "OTHER_YOUNG %1.6lf %1.6lf " | |
1847 "OTHER_NON_YOUNG %1.6lf %1.6lf " | |
1848 "VTIME_DIFF %1.6lf TERMINATION %1.6lf " | |
1849 "ELAPSED %1.6lf %1.6lf ", | |
1850 _cur_collection_start_sec, | |
1851 (!_last_young_gc_full) ? 2 : | |
1852 (last_pause_included_initial_mark) ? 1 : 0, | |
1853 _recorded_region_num, | |
1854 _recorded_young_regions, | |
1855 _recorded_scan_only_regions, | |
1856 _recorded_non_young_regions, | |
1857 _predicted_pending_cards, _pending_cards, | |
1858 _predicted_cards_scanned, cards_scanned, | |
1859 _predicted_rs_lengths, _max_rs_lengths, | |
1860 _predicted_scan_only_scan_time_ms, scan_only_time, | |
1861 _predicted_rs_update_time_ms, update_rs_time, | |
1862 _predicted_rs_scan_time_ms, scan_rs_time, | |
1863 _predicted_survival_ratio, survival_ratio, | |
1864 _predicted_object_copy_time_ms, obj_copy_time, | |
1865 _predicted_constant_other_time_ms, constant_other_time_ms, | |
1866 _predicted_young_other_time_ms, young_other_time_ms, | |
1867 _predicted_non_young_other_time_ms, | |
1868 non_young_other_time_ms, | |
1869 _vtime_diff_ms, termination_time, | |
1870 _predicted_pause_time_ms, elapsed_ms); | |
1871 } | |
1872 | |
1873 if (G1PolicyVerbose > 0) { | |
1874 gclog_or_tty->print_cr("Pause Time, predicted: %1.4lfms (predicted %s), actual: %1.4lfms", | |
1875 _predicted_pause_time_ms, | |
1876 (_within_target) ? "within" : "outside", | |
1877 elapsed_ms); | |
1878 } | |
1879 | |
1880 } | |
1881 | |
1882 _in_marking_window = new_in_marking_window; | |
1883 _in_marking_window_im = new_in_marking_window_im; | |
1884 _free_regions_at_end_of_collection = _g1->free_regions(); | |
1885 _scan_only_regions_at_end_of_collection = _g1->young_list_length(); | |
1886 calculate_young_list_min_length(); | |
1887 calculate_young_list_target_config(); | |
1888 | |
1889 // </NEW PREDICTION> | |
1890 | |
1891 _target_pause_time_ms = -1.0; | |
1892 } | |
1893 | |
1894 // <NEW PREDICTION> | |
1895 | |
1896 double | |
1897 G1CollectorPolicy:: | |
1898 predict_young_collection_elapsed_time_ms(size_t adjustment) { | |
1899 guarantee( adjustment == 0 || adjustment == 1, "invariant" ); | |
1900 | |
1901 G1CollectedHeap* g1h = G1CollectedHeap::heap(); | |
1902 size_t young_num = g1h->young_list_length(); | |
1903 if (young_num == 0) | |
1904 return 0.0; | |
1905 | |
1906 young_num += adjustment; | |
1907 size_t pending_cards = predict_pending_cards(); | |
1908 size_t rs_lengths = g1h->young_list_sampled_rs_lengths() + | |
1909 predict_rs_length_diff(); | |
1910 size_t card_num; | |
1911 if (full_young_gcs()) | |
1912 card_num = predict_young_card_num(rs_lengths); | |
1913 else | |
1914 card_num = predict_non_young_card_num(rs_lengths); | |
1915 size_t young_byte_size = young_num * HeapRegion::GrainBytes; | |
1916 double accum_yg_surv_rate = | |
1917 _short_lived_surv_rate_group->accum_surv_rate(adjustment); | |
1918 | |
1919 size_t bytes_to_copy = | |
1920 (size_t) (accum_yg_surv_rate * (double) HeapRegion::GrainBytes); | |
1921 | |
1922 return | |
1923 predict_rs_update_time_ms(pending_cards) + | |
1924 predict_rs_scan_time_ms(card_num) + | |
1925 predict_object_copy_time_ms(bytes_to_copy) + | |
1926 predict_young_other_time_ms(young_num) + | |
1927 predict_constant_other_time_ms(); | |
1928 } | |
1929 | |
1930 double | |
1931 G1CollectorPolicy::predict_base_elapsed_time_ms(size_t pending_cards) { | |
1932 size_t rs_length = predict_rs_length_diff(); | |
1933 size_t card_num; | |
1934 if (full_young_gcs()) | |
1935 card_num = predict_young_card_num(rs_length); | |
1936 else | |
1937 card_num = predict_non_young_card_num(rs_length); | |
1938 return predict_base_elapsed_time_ms(pending_cards, card_num); | |
1939 } | |
1940 | |
1941 double | |
1942 G1CollectorPolicy::predict_base_elapsed_time_ms(size_t pending_cards, | |
1943 size_t scanned_cards) { | |
1944 return | |
1945 predict_rs_update_time_ms(pending_cards) + | |
1946 predict_rs_scan_time_ms(scanned_cards) + | |
1947 predict_constant_other_time_ms(); | |
1948 } | |
1949 | |
1950 double | |
1951 G1CollectorPolicy::predict_region_elapsed_time_ms(HeapRegion* hr, | |
1952 bool young) { | |
1953 size_t rs_length = hr->rem_set()->occupied(); | |
1954 size_t card_num; | |
1955 if (full_young_gcs()) | |
1956 card_num = predict_young_card_num(rs_length); | |
1957 else | |
1958 card_num = predict_non_young_card_num(rs_length); | |
1959 size_t bytes_to_copy = predict_bytes_to_copy(hr); | |
1960 | |
1961 double region_elapsed_time_ms = | |
1962 predict_rs_scan_time_ms(card_num) + | |
1963 predict_object_copy_time_ms(bytes_to_copy); | |
1964 | |
1965 if (young) | |
1966 region_elapsed_time_ms += predict_young_other_time_ms(1); | |
1967 else | |
1968 region_elapsed_time_ms += predict_non_young_other_time_ms(1); | |
1969 | |
1970 return region_elapsed_time_ms; | |
1971 } | |
1972 | |
1973 size_t | |
1974 G1CollectorPolicy::predict_bytes_to_copy(HeapRegion* hr) { | |
1975 size_t bytes_to_copy; | |
1976 if (hr->is_marked()) | |
1977 bytes_to_copy = hr->max_live_bytes(); | |
1978 else { | |
1979 guarantee( hr->is_young() && hr->age_in_surv_rate_group() != -1, | |
1980 "invariant" ); | |
1981 int age = hr->age_in_surv_rate_group(); | |
545 | 1982 double yg_surv_rate = predict_yg_surv_rate(age, hr->surv_rate_group()); |
342 | 1983 bytes_to_copy = (size_t) ((double) hr->used() * yg_surv_rate); |
1984 } | |
1985 | |
1986 return bytes_to_copy; | |
1987 } | |
1988 | |
1989 void | |
1990 G1CollectorPolicy::start_recording_regions() { | |
1991 _recorded_rs_lengths = 0; | |
1992 _recorded_scan_only_regions = 0; | |
1993 _recorded_young_regions = 0; | |
1994 _recorded_non_young_regions = 0; | |
1995 | |
1996 #if PREDICTIONS_VERBOSE | |
1997 _predicted_rs_lengths = 0; | |
1998 _predicted_cards_scanned = 0; | |
1999 | |
2000 _recorded_marked_bytes = 0; | |
2001 _recorded_young_bytes = 0; | |
2002 _predicted_bytes_to_copy = 0; | |
2003 #endif // PREDICTIONS_VERBOSE | |
2004 } | |
2005 | |
2006 void | |
2007 G1CollectorPolicy::record_cset_region(HeapRegion* hr, bool young) { | |
2008 if (young) { | |
2009 ++_recorded_young_regions; | |
2010 } else { | |
2011 ++_recorded_non_young_regions; | |
2012 } | |
2013 #if PREDICTIONS_VERBOSE | |
2014 if (young) { | |
545 | 2015 _recorded_young_bytes += hr->used(); |
342 | 2016 } else { |
2017 _recorded_marked_bytes += hr->max_live_bytes(); | |
2018 } | |
2019 _predicted_bytes_to_copy += predict_bytes_to_copy(hr); | |
2020 #endif // PREDICTIONS_VERBOSE | |
2021 | |
2022 size_t rs_length = hr->rem_set()->occupied(); | |
2023 _recorded_rs_lengths += rs_length; | |
2024 } | |
2025 | |
2026 void | |
2027 G1CollectorPolicy::record_scan_only_regions(size_t scan_only_length) { | |
2028 _recorded_scan_only_regions = scan_only_length; | |
2029 } | |
2030 | |
2031 void | |
2032 G1CollectorPolicy::end_recording_regions() { | |
2033 #if PREDICTIONS_VERBOSE | |
2034 _predicted_pending_cards = predict_pending_cards(); | |
2035 _predicted_rs_lengths = _recorded_rs_lengths + predict_rs_length_diff(); | |
2036 if (full_young_gcs()) | |
2037 _predicted_cards_scanned += predict_young_card_num(_predicted_rs_lengths); | |
2038 else | |
2039 _predicted_cards_scanned += | |
2040 predict_non_young_card_num(_predicted_rs_lengths); | |
2041 _recorded_region_num = _recorded_young_regions + _recorded_non_young_regions; | |
2042 | |
2043 _predicted_scan_only_scan_time_ms = | |
2044 predict_scan_only_time_ms(_recorded_scan_only_regions); | |
2045 _predicted_rs_update_time_ms = | |
2046 predict_rs_update_time_ms(_g1->pending_card_num()); | |
2047 _predicted_rs_scan_time_ms = | |
2048 predict_rs_scan_time_ms(_predicted_cards_scanned); | |
2049 _predicted_object_copy_time_ms = | |
2050 predict_object_copy_time_ms(_predicted_bytes_to_copy); | |
2051 _predicted_constant_other_time_ms = | |
2052 predict_constant_other_time_ms(); | |
2053 _predicted_young_other_time_ms = | |
2054 predict_young_other_time_ms(_recorded_young_regions); | |
2055 _predicted_non_young_other_time_ms = | |
2056 predict_non_young_other_time_ms(_recorded_non_young_regions); | |
2057 | |
2058 _predicted_pause_time_ms = | |
2059 _predicted_scan_only_scan_time_ms + | |
2060 _predicted_rs_update_time_ms + | |
2061 _predicted_rs_scan_time_ms + | |
2062 _predicted_object_copy_time_ms + | |
2063 _predicted_constant_other_time_ms + | |
2064 _predicted_young_other_time_ms + | |
2065 _predicted_non_young_other_time_ms; | |
2066 #endif // PREDICTIONS_VERBOSE | |
2067 } | |
2068 | |
2069 void G1CollectorPolicy::check_if_region_is_too_expensive(double | |
2070 predicted_time_ms) { | |
2071 // I don't think we need to do this when in young GC mode since | |
2072 // marking will be initiated next time we hit the soft limit anyway... | |
2073 if (predicted_time_ms > _expensive_region_limit_ms) { | |
2074 if (!in_young_gc_mode()) { | |
2075 set_full_young_gcs(true); | |
2076 _should_initiate_conc_mark = true; | |
2077 } else | |
2078 // no point in doing another partial one | |
2079 _should_revert_to_full_young_gcs = true; | |
2080 } | |
2081 } | |
2082 | |
2083 // </NEW PREDICTION> | |
2084 | |
2085 | |
2086 void G1CollectorPolicy::update_recent_gc_times(double end_time_sec, | |
2087 double elapsed_ms) { | |
2088 _recent_gc_times_ms->add(elapsed_ms); | |
2089 _recent_prev_end_times_for_all_gcs_sec->add(end_time_sec); | |
2090 _prev_collection_pause_end_ms = end_time_sec * 1000.0; | |
2091 } | |
2092 | |
2093 double G1CollectorPolicy::recent_avg_time_for_pauses_ms() { | |
751 | 2094 if (_recent_pause_times_ms->num() == 0) return (double) MaxGCPauseMillis; |
342 | 2095 else return _recent_pause_times_ms->avg(); |
2096 } | |
2097 | |
2098 double G1CollectorPolicy::recent_avg_time_for_CH_strong_ms() { | |
2099 if (_recent_CH_strong_roots_times_ms->num() == 0) | |
751 | 2100 return (double)MaxGCPauseMillis/3.0; |
342 | 2101 else return _recent_CH_strong_roots_times_ms->avg(); |
2102 } | |
2103 | |
2104 double G1CollectorPolicy::recent_avg_time_for_G1_strong_ms() { | |
2105 if (_recent_G1_strong_roots_times_ms->num() == 0) | |
751 | 2106 return (double)MaxGCPauseMillis/3.0; |
342 | 2107 else return _recent_G1_strong_roots_times_ms->avg(); |
2108 } | |
2109 | |
2110 double G1CollectorPolicy::recent_avg_time_for_evac_ms() { | |
751 | 2111 if (_recent_evac_times_ms->num() == 0) return (double)MaxGCPauseMillis/3.0; |
342 | 2112 else return _recent_evac_times_ms->avg(); |
2113 } | |
2114 | |
2115 int G1CollectorPolicy::number_of_recent_gcs() { | |
2116 assert(_recent_CH_strong_roots_times_ms->num() == | |
2117 _recent_G1_strong_roots_times_ms->num(), "Sequence out of sync"); | |
2118 assert(_recent_G1_strong_roots_times_ms->num() == | |
2119 _recent_evac_times_ms->num(), "Sequence out of sync"); | |
2120 assert(_recent_evac_times_ms->num() == | |
2121 _recent_pause_times_ms->num(), "Sequence out of sync"); | |
2122 assert(_recent_pause_times_ms->num() == | |
2123 _recent_CS_bytes_used_before->num(), "Sequence out of sync"); | |
2124 assert(_recent_CS_bytes_used_before->num() == | |
2125 _recent_CS_bytes_surviving->num(), "Sequence out of sync"); | |
2126 return _recent_pause_times_ms->num(); | |
2127 } | |
2128 | |
2129 double G1CollectorPolicy::recent_avg_survival_fraction() { | |
2130 return recent_avg_survival_fraction_work(_recent_CS_bytes_surviving, | |
2131 _recent_CS_bytes_used_before); | |
2132 } | |
2133 | |
2134 double G1CollectorPolicy::last_survival_fraction() { | |
2135 return last_survival_fraction_work(_recent_CS_bytes_surviving, | |
2136 _recent_CS_bytes_used_before); | |
2137 } | |
2138 | |
2139 double | |
2140 G1CollectorPolicy::recent_avg_survival_fraction_work(TruncatedSeq* surviving, | |
2141 TruncatedSeq* before) { | |
2142 assert(surviving->num() == before->num(), "Sequence out of sync"); | |
2143 if (before->sum() > 0.0) { | |
2144 double recent_survival_rate = surviving->sum() / before->sum(); | |
2145 // We exempt parallel collection from this check because Alloc Buffer | |
2146 // fragmentation can produce negative collections. | |
2147 // Further, we're now always doing parallel collection. But I'm still | |
2148 // leaving this here as a placeholder for a more precise assertion later. | |
2149 // (DLD, 10/05.) | |
2150 assert((true || ParallelGCThreads > 0) || | |
2151 _g1->evacuation_failed() || | |
2152 recent_survival_rate <= 1.0, "Or bad frac"); | |
2153 return recent_survival_rate; | |
2154 } else { | |
2155 return 1.0; // Be conservative. | |
2156 } | |
2157 } | |
2158 | |
2159 double | |
2160 G1CollectorPolicy::last_survival_fraction_work(TruncatedSeq* surviving, | |
2161 TruncatedSeq* before) { | |
2162 assert(surviving->num() == before->num(), "Sequence out of sync"); | |
2163 if (surviving->num() > 0 && before->last() > 0.0) { | |
2164 double last_survival_rate = surviving->last() / before->last(); | |
2165 // We exempt parallel collection from this check because Alloc Buffer | |
2166 // fragmentation can produce negative collections. | |
2167 // Further, we're now always doing parallel collection. But I'm still | |
2168 // leaving this here as a placeholder for a more precise assertion later. | |
2169 // (DLD, 10/05.) | |
2170 assert((true || ParallelGCThreads > 0) || | |
2171 last_survival_rate <= 1.0, "Or bad frac"); | |
2172 return last_survival_rate; | |
2173 } else { | |
2174 return 1.0; | |
2175 } | |
2176 } | |
2177 | |
2178 static const int survival_min_obs = 5; | |
2179 static double survival_min_obs_limits[] = { 0.9, 0.7, 0.5, 0.3, 0.1 }; | |
2180 static const double min_survival_rate = 0.1; | |
2181 | |
2182 double | |
2183 G1CollectorPolicy::conservative_avg_survival_fraction_work(double avg, | |
2184 double latest) { | |
2185 double res = avg; | |
2186 if (number_of_recent_gcs() < survival_min_obs) { | |
2187 res = MAX2(res, survival_min_obs_limits[number_of_recent_gcs()]); | |
2188 } | |
2189 res = MAX2(res, latest); | |
2190 res = MAX2(res, min_survival_rate); | |
2191 // In the parallel case, LAB fragmentation can produce "negative | |
2192 // collections"; so can evac failure. Cap at 1.0 | |
2193 res = MIN2(res, 1.0); | |
2194 return res; | |
2195 } | |
2196 | |
2197 size_t G1CollectorPolicy::expansion_amount() { | |
751 | 2198 if ((int)(recent_avg_pause_time_ratio() * 100.0) > G1GCPercent) { |
2199 // We will double the existing space, or take | |
2200 // G1ExpandByPercentOfAvailable % of the available expansion | |
2201 // space, whichever is smaller, bounded below by a minimum | |
2202 // expansion (unless that's all that's left.) | |
342 | 2203 const size_t min_expand_bytes = 1*M; |
2204 size_t reserved_bytes = _g1->g1_reserved_obj_bytes(); | |
2205 size_t committed_bytes = _g1->capacity(); | |
2206 size_t uncommitted_bytes = reserved_bytes - committed_bytes; | |
2207 size_t expand_bytes; | |
2208 size_t expand_bytes_via_pct = | |
751 | 2209 uncommitted_bytes * G1ExpandByPercentOfAvailable / 100; |
342 | 2210 expand_bytes = MIN2(expand_bytes_via_pct, committed_bytes); |
2211 expand_bytes = MAX2(expand_bytes, min_expand_bytes); | |
2212 expand_bytes = MIN2(expand_bytes, uncommitted_bytes); | |
2213 if (G1PolicyVerbose > 1) { | |
2214 gclog_or_tty->print("Decided to expand: ratio = %5.2f, " | |
2215 "committed = %d%s, uncommited = %d%s, via pct = %d%s.\n" | |
2216 " Answer = %d.\n", | |
2217 recent_avg_pause_time_ratio(), | |
2218 byte_size_in_proper_unit(committed_bytes), | |
2219 proper_unit_for_byte_size(committed_bytes), | |
2220 byte_size_in_proper_unit(uncommitted_bytes), | |
2221 proper_unit_for_byte_size(uncommitted_bytes), | |
2222 byte_size_in_proper_unit(expand_bytes_via_pct), | |
2223 proper_unit_for_byte_size(expand_bytes_via_pct), | |
2224 byte_size_in_proper_unit(expand_bytes), | |
2225 proper_unit_for_byte_size(expand_bytes)); | |
2226 } | |
2227 return expand_bytes; | |
2228 } else { | |
2229 return 0; | |
2230 } | |
2231 } | |
2232 | |
2233 void G1CollectorPolicy::note_start_of_mark_thread() { | |
2234 _mark_thread_startup_sec = os::elapsedTime(); | |
2235 } | |
2236 | |
2237 class CountCSClosure: public HeapRegionClosure { | |
2238 G1CollectorPolicy* _g1_policy; | |
2239 public: | |
2240 CountCSClosure(G1CollectorPolicy* g1_policy) : | |
2241 _g1_policy(g1_policy) {} | |
2242 bool doHeapRegion(HeapRegion* r) { | |
2243 _g1_policy->_bytes_in_collection_set_before_gc += r->used(); | |
2244 return false; | |
2245 } | |
2246 }; | |
2247 | |
2248 void G1CollectorPolicy::count_CS_bytes_used() { | |
2249 CountCSClosure cs_closure(this); | |
2250 _g1->collection_set_iterate(&cs_closure); | |
2251 } | |
2252 | |
2253 static void print_indent(int level) { | |
2254 for (int j = 0; j < level+1; ++j) | |
2255 gclog_or_tty->print(" "); | |
2256 } | |
2257 | |
2258 void G1CollectorPolicy::print_summary (int level, | |
2259 const char* str, | |
2260 NumberSeq* seq) const { | |
2261 double sum = seq->sum(); | |
2262 print_indent(level); | |
2263 gclog_or_tty->print_cr("%-24s = %8.2lf s (avg = %8.2lf ms)", | |
2264 str, sum / 1000.0, seq->avg()); | |
2265 } | |
2266 | |
2267 void G1CollectorPolicy::print_summary_sd (int level, | |
2268 const char* str, | |
2269 NumberSeq* seq) const { | |
2270 print_summary(level, str, seq); | |
2271 print_indent(level + 5); | |
2272 gclog_or_tty->print_cr("(num = %5d, std dev = %8.2lf ms, max = %8.2lf ms)", | |
2273 seq->num(), seq->sd(), seq->maximum()); | |
2274 } | |
2275 | |
2276 void G1CollectorPolicy::check_other_times(int level, | |
2277 NumberSeq* other_times_ms, | |
2278 NumberSeq* calc_other_times_ms) const { | |
2279 bool should_print = false; | |
2280 | |
2281 double max_sum = MAX2(fabs(other_times_ms->sum()), | |
2282 fabs(calc_other_times_ms->sum())); | |
2283 double min_sum = MIN2(fabs(other_times_ms->sum()), | |
2284 fabs(calc_other_times_ms->sum())); | |
2285 double sum_ratio = max_sum / min_sum; | |
2286 if (sum_ratio > 1.1) { | |
2287 should_print = true; | |
2288 print_indent(level + 1); | |
2289 gclog_or_tty->print_cr("## CALCULATED OTHER SUM DOESN'T MATCH RECORDED ###"); | |
2290 } | |
2291 | |
2292 double max_avg = MAX2(fabs(other_times_ms->avg()), | |
2293 fabs(calc_other_times_ms->avg())); | |
2294 double min_avg = MIN2(fabs(other_times_ms->avg()), | |
2295 fabs(calc_other_times_ms->avg())); | |
2296 double avg_ratio = max_avg / min_avg; | |
2297 if (avg_ratio > 1.1) { | |
2298 should_print = true; | |
2299 print_indent(level + 1); | |
2300 gclog_or_tty->print_cr("## CALCULATED OTHER AVG DOESN'T MATCH RECORDED ###"); | |
2301 } | |
2302 | |
2303 if (other_times_ms->sum() < -0.01) { | |
2304 print_indent(level + 1); | |
2305 gclog_or_tty->print_cr("## RECORDED OTHER SUM IS NEGATIVE ###"); | |
2306 } | |
2307 | |
2308 if (other_times_ms->avg() < -0.01) { | |
2309 print_indent(level + 1); | |
2310 gclog_or_tty->print_cr("## RECORDED OTHER AVG IS NEGATIVE ###"); | |
2311 } | |
2312 | |
2313 if (calc_other_times_ms->sum() < -0.01) { | |
2314 should_print = true; | |
2315 print_indent(level + 1); | |
2316 gclog_or_tty->print_cr("## CALCULATED OTHER SUM IS NEGATIVE ###"); | |
2317 } | |
2318 | |
2319 if (calc_other_times_ms->avg() < -0.01) { | |
2320 should_print = true; | |
2321 print_indent(level + 1); | |
2322 gclog_or_tty->print_cr("## CALCULATED OTHER AVG IS NEGATIVE ###"); | |
2323 } | |
2324 | |
2325 if (should_print) | |
2326 print_summary(level, "Other(Calc)", calc_other_times_ms); | |
2327 } | |
2328 | |
2329 void G1CollectorPolicy::print_summary(PauseSummary* summary) const { | |
2330 bool parallel = ParallelGCThreads > 0; | |
2331 MainBodySummary* body_summary = summary->main_body_summary(); | |
2332 if (summary->get_total_seq()->num() > 0) { | |
677 | 2333 print_summary_sd(0, "Evacuation Pauses", summary->get_total_seq()); |
342 | 2334 if (body_summary != NULL) { |
2335 print_summary(1, "SATB Drain", body_summary->get_satb_drain_seq()); | |
2336 if (parallel) { | |
2337 print_summary(1, "Parallel Time", body_summary->get_parallel_seq()); | |
2338 print_summary(2, "Update RS", body_summary->get_update_rs_seq()); | |
2339 print_summary(2, "Ext Root Scanning", | |
2340 body_summary->get_ext_root_scan_seq()); | |
2341 print_summary(2, "Mark Stack Scanning", | |
2342 body_summary->get_mark_stack_scan_seq()); | |
2343 print_summary(2, "Scan-Only Scanning", | |
2344 body_summary->get_scan_only_seq()); | |
2345 print_summary(2, "Scan RS", body_summary->get_scan_rs_seq()); | |
2346 print_summary(2, "Object Copy", body_summary->get_obj_copy_seq()); | |
2347 print_summary(2, "Termination", body_summary->get_termination_seq()); | |
2348 print_summary(2, "Other", body_summary->get_parallel_other_seq()); | |
2349 { | |
2350 NumberSeq* other_parts[] = { | |
2351 body_summary->get_update_rs_seq(), | |
2352 body_summary->get_ext_root_scan_seq(), | |
2353 body_summary->get_mark_stack_scan_seq(), | |
2354 body_summary->get_scan_only_seq(), | |
2355 body_summary->get_scan_rs_seq(), | |
2356 body_summary->get_obj_copy_seq(), | |
2357 body_summary->get_termination_seq() | |
2358 }; | |
2359 NumberSeq calc_other_times_ms(body_summary->get_parallel_seq(), | |
2360 7, other_parts); | |
2361 check_other_times(2, body_summary->get_parallel_other_seq(), | |
2362 &calc_other_times_ms); | |
2363 } | |
2364 print_summary(1, "Mark Closure", body_summary->get_mark_closure_seq()); | |
2365 print_summary(1, "Clear CT", body_summary->get_clear_ct_seq()); | |
2366 } else { | |
2367 print_summary(1, "Update RS", body_summary->get_update_rs_seq()); | |
2368 print_summary(1, "Ext Root Scanning", | |
2369 body_summary->get_ext_root_scan_seq()); | |
2370 print_summary(1, "Mark Stack Scanning", | |
2371 body_summary->get_mark_stack_scan_seq()); | |
2372 print_summary(1, "Scan-Only Scanning", | |
2373 body_summary->get_scan_only_seq()); | |
2374 print_summary(1, "Scan RS", body_summary->get_scan_rs_seq()); | |
2375 print_summary(1, "Object Copy", body_summary->get_obj_copy_seq()); | |
2376 } | |
2377 } | |
2378 print_summary(1, "Other", summary->get_other_seq()); | |
2379 { | |
2380 NumberSeq calc_other_times_ms; | |
2381 if (body_summary != NULL) { | |
2382 // not abandoned | |
2383 if (parallel) { | |
2384 // parallel | |
2385 NumberSeq* other_parts[] = { | |
2386 body_summary->get_satb_drain_seq(), | |
2387 body_summary->get_parallel_seq(), | |
2388 body_summary->get_clear_ct_seq() | |
2389 }; | |
677 | 2390 calc_other_times_ms = NumberSeq(summary->get_total_seq(), |
2391 3, other_parts); | |
342 | 2392 } else { |
2393 // serial | |
2394 NumberSeq* other_parts[] = { | |
2395 body_summary->get_satb_drain_seq(), | |
2396 body_summary->get_update_rs_seq(), | |
2397 body_summary->get_ext_root_scan_seq(), | |
2398 body_summary->get_mark_stack_scan_seq(), | |
2399 body_summary->get_scan_only_seq(), | |
2400 body_summary->get_scan_rs_seq(), | |
2401 body_summary->get_obj_copy_seq() | |
2402 }; | |
2403 calc_other_times_ms = NumberSeq(summary->get_total_seq(), | |
677 | 2404 7, other_parts); |
342 | 2405 } |
2406 } else { | |
2407 // abandoned | |
677 | 2408 calc_other_times_ms = NumberSeq(); |
342 | 2409 } |
2410 check_other_times(1, summary->get_other_seq(), &calc_other_times_ms); | |
2411 } | |
2412 } else { | |
2413 print_indent(0); | |
2414 gclog_or_tty->print_cr("none"); | |
2415 } | |
2416 gclog_or_tty->print_cr(""); | |
2417 } | |
2418 | |
2419 void | |
677 | 2420 G1CollectorPolicy::print_abandoned_summary(PauseSummary* summary) const { |
342 | 2421 bool printed = false; |
677 | 2422 if (summary->get_total_seq()->num() > 0) { |
342 | 2423 printed = true; |
677 | 2424 print_summary(summary); |
342 | 2425 } |
2426 if (!printed) { | |
2427 print_indent(0); | |
2428 gclog_or_tty->print_cr("none"); | |
2429 gclog_or_tty->print_cr(""); | |
2430 } | |
2431 } | |
2432 | |
2433 void G1CollectorPolicy::print_tracing_info() const { | |
2434 if (TraceGen0Time) { | |
2435 gclog_or_tty->print_cr("ALL PAUSES"); | |
2436 print_summary_sd(0, "Total", _all_pause_times_ms); | |
2437 gclog_or_tty->print_cr(""); | |
2438 gclog_or_tty->print_cr(""); | |
2439 gclog_or_tty->print_cr(" Full Young GC Pauses: %8d", _full_young_pause_num); | |
2440 gclog_or_tty->print_cr(" Partial Young GC Pauses: %8d", _partial_young_pause_num); | |
2441 gclog_or_tty->print_cr(""); | |
2442 | |
677 | 2443 gclog_or_tty->print_cr("EVACUATION PAUSES"); |
2444 print_summary(_summary); | |
342 | 2445 |
2446 gclog_or_tty->print_cr("ABANDONED PAUSES"); | |
677 | 2447 print_abandoned_summary(_abandoned_summary); |
342 | 2448 |
2449 gclog_or_tty->print_cr("MISC"); | |
2450 print_summary_sd(0, "Stop World", _all_stop_world_times_ms); | |
2451 print_summary_sd(0, "Yields", _all_yield_times_ms); | |
2452 for (int i = 0; i < _aux_num; ++i) { | |
2453 if (_all_aux_times_ms[i].num() > 0) { | |
2454 char buffer[96]; | |
2455 sprintf(buffer, "Aux%d", i); | |
2456 print_summary_sd(0, buffer, &_all_aux_times_ms[i]); | |
2457 } | |
2458 } | |
2459 | |
2460 size_t all_region_num = _region_num_young + _region_num_tenured; | |
2461 gclog_or_tty->print_cr(" New Regions %8d, Young %8d (%6.2lf%%), " | |
2462 "Tenured %8d (%6.2lf%%)", | |
2463 all_region_num, | |
2464 _region_num_young, | |
2465 (double) _region_num_young / (double) all_region_num * 100.0, | |
2466 _region_num_tenured, | |
2467 (double) _region_num_tenured / (double) all_region_num * 100.0); | |
2468 } | |
2469 if (TraceGen1Time) { | |
2470 if (_all_full_gc_times_ms->num() > 0) { | |
2471 gclog_or_tty->print("\n%4d full_gcs: total time = %8.2f s", | |
2472 _all_full_gc_times_ms->num(), | |
2473 _all_full_gc_times_ms->sum() / 1000.0); | |
2474 gclog_or_tty->print_cr(" (avg = %8.2fms).", _all_full_gc_times_ms->avg()); | |
2475 gclog_or_tty->print_cr(" [std. dev = %8.2f ms, max = %8.2f ms]", | |
2476 _all_full_gc_times_ms->sd(), | |
2477 _all_full_gc_times_ms->maximum()); | |
2478 } | |
2479 } | |
2480 } | |
2481 | |
2482 void G1CollectorPolicy::print_yg_surv_rate_info() const { | |
2483 #ifndef PRODUCT | |
2484 _short_lived_surv_rate_group->print_surv_rate_summary(); | |
2485 // add this call for any other surv rate groups | |
2486 #endif // PRODUCT | |
2487 } | |
2488 | |
2489 bool | |
2490 G1CollectorPolicy::should_add_next_region_to_young_list() { | |
2491 assert(in_young_gc_mode(), "should be in young GC mode"); | |
2492 bool ret; | |
2493 size_t young_list_length = _g1->young_list_length(); | |
545 | 2494 size_t young_list_max_length = _young_list_target_length; |
2495 if (G1FixedEdenSize) { | |
2496 young_list_max_length -= _max_survivor_regions; | |
2497 } | |
2498 if (young_list_length < young_list_max_length) { | |
342 | 2499 ret = true; |
2500 ++_region_num_young; | |
2501 } else { | |
2502 ret = false; | |
2503 ++_region_num_tenured; | |
2504 } | |
2505 | |
2506 return ret; | |
2507 } | |
2508 | |
2509 #ifndef PRODUCT | |
2510 // for debugging, bit of a hack... | |
2511 static char* | |
2512 region_num_to_mbs(int length) { | |
2513 static char buffer[64]; | |
2514 double bytes = (double) (length * HeapRegion::GrainBytes); | |
2515 double mbs = bytes / (double) (1024 * 1024); | |
2516 sprintf(buffer, "%7.2lfMB", mbs); | |
2517 return buffer; | |
2518 } | |
2519 #endif // PRODUCT | |
2520 | |
545 | 2521 size_t G1CollectorPolicy::max_regions(int purpose) { |
342 | 2522 switch (purpose) { |
2523 case GCAllocForSurvived: | |
545 | 2524 return _max_survivor_regions; |
342 | 2525 case GCAllocForTenured: |
545 | 2526 return REGIONS_UNLIMITED; |
342 | 2527 default: |
545 | 2528 ShouldNotReachHere(); |
2529 return REGIONS_UNLIMITED; | |
342 | 2530 }; |
2531 } | |
2532 | |
545 | 2533 // Calculates survivor space parameters. |
2534 void G1CollectorPolicy::calculate_survivors_policy() | |
2535 { | |
751 | 2536 if (!G1UseSurvivorSpaces) { |
545 | 2537 return; |
2538 } | |
2539 if (G1FixedSurvivorSpaceSize == 0) { | |
2540 _max_survivor_regions = _young_list_target_length / SurvivorRatio; | |
2541 } else { | |
547
1e458753107d
6802413: G1: G1FixedSurvivorSpaceSize should be converted into regions in calculate_survivors_policy()
apetrusenko
parents:
545
diff
changeset
|
2542 _max_survivor_regions = G1FixedSurvivorSpaceSize / HeapRegion::GrainBytes; |
545 | 2543 } |
2544 | |
2545 if (G1FixedTenuringThreshold) { | |
2546 _tenuring_threshold = MaxTenuringThreshold; | |
2547 } else { | |
2548 _tenuring_threshold = _survivors_age_table.compute_tenuring_threshold( | |
2549 HeapRegion::GrainWords * _max_survivor_regions); | |
2550 } | |
2551 } | |
2552 | |
342 | 2553 bool |
2554 G1CollectorPolicy_BestRegionsFirst::should_do_collection_pause(size_t | |
2555 word_size) { | |
2556 assert(_g1->regions_accounted_for(), "Region leakage!"); | |
2557 // Initiate a pause when we reach the steady-state "used" target. | |
2558 size_t used_hard = (_g1->capacity() / 100) * G1SteadyStateUsed; | |
2559 size_t used_soft = | |
2560 MAX2((_g1->capacity() / 100) * (G1SteadyStateUsed - G1SteadyStateUsedDelta), | |
2561 used_hard/2); | |
2562 size_t used = _g1->used(); | |
2563 | |
2564 double max_pause_time_ms = _mmu_tracker->max_gc_time() * 1000.0; | |
2565 | |
2566 size_t young_list_length = _g1->young_list_length(); | |
545 | 2567 size_t young_list_max_length = _young_list_target_length; |
2568 if (G1FixedEdenSize) { | |
2569 young_list_max_length -= _max_survivor_regions; | |
2570 } | |
2571 bool reached_target_length = young_list_length >= young_list_max_length; | |
342 | 2572 |
2573 if (in_young_gc_mode()) { | |
2574 if (reached_target_length) { | |
2575 assert( young_list_length > 0 && _g1->young_list_length() > 0, | |
2576 "invariant" ); | |
2577 _target_pause_time_ms = max_pause_time_ms; | |
2578 return true; | |
2579 } | |
2580 } else { | |
2581 guarantee( false, "should not reach here" ); | |
2582 } | |
2583 | |
2584 return false; | |
2585 } | |
2586 | |
2587 #ifndef PRODUCT | |
2588 class HRSortIndexIsOKClosure: public HeapRegionClosure { | |
2589 CollectionSetChooser* _chooser; | |
2590 public: | |
2591 HRSortIndexIsOKClosure(CollectionSetChooser* chooser) : | |
2592 _chooser(chooser) {} | |
2593 | |
2594 bool doHeapRegion(HeapRegion* r) { | |
2595 if (!r->continuesHumongous()) { | |
2596 assert(_chooser->regionProperlyOrdered(r), "Ought to be."); | |
2597 } | |
2598 return false; | |
2599 } | |
2600 }; | |
2601 | |
2602 bool G1CollectorPolicy_BestRegionsFirst::assertMarkedBytesDataOK() { | |
2603 HRSortIndexIsOKClosure cl(_collectionSetChooser); | |
2604 _g1->heap_region_iterate(&cl); | |
2605 return true; | |
2606 } | |
2607 #endif | |
2608 | |
2609 void | |
2610 G1CollectorPolicy_BestRegionsFirst:: | |
2611 record_collection_pause_start(double start_time_sec, size_t start_used) { | |
2612 G1CollectorPolicy::record_collection_pause_start(start_time_sec, start_used); | |
2613 } | |
2614 | |
2615 class NextNonCSElemFinder: public HeapRegionClosure { | |
2616 HeapRegion* _res; | |
2617 public: | |
2618 NextNonCSElemFinder(): _res(NULL) {} | |
2619 bool doHeapRegion(HeapRegion* r) { | |
2620 if (!r->in_collection_set()) { | |
2621 _res = r; | |
2622 return true; | |
2623 } else { | |
2624 return false; | |
2625 } | |
2626 } | |
2627 HeapRegion* res() { return _res; } | |
2628 }; | |
2629 | |
2630 class KnownGarbageClosure: public HeapRegionClosure { | |
2631 CollectionSetChooser* _hrSorted; | |
2632 | |
2633 public: | |
2634 KnownGarbageClosure(CollectionSetChooser* hrSorted) : | |
2635 _hrSorted(hrSorted) | |
2636 {} | |
2637 | |
2638 bool doHeapRegion(HeapRegion* r) { | |
2639 // We only include humongous regions in collection | |
2640 // sets when concurrent mark shows that their contained object is | |
2641 // unreachable. | |
2642 | |
2643 // Do we have any marking information for this region? | |
2644 if (r->is_marked()) { | |
2645 // We don't include humongous regions in collection | |
2646 // sets because we collect them immediately at the end of a marking | |
2647 // cycle. We also don't include young regions because we *must* | |
2648 // include them in the next collection pause. | |
2649 if (!r->isHumongous() && !r->is_young()) { | |
2650 _hrSorted->addMarkedHeapRegion(r); | |
2651 } | |
2652 } | |
2653 return false; | |
2654 } | |
2655 }; | |
2656 | |
2657 class ParKnownGarbageHRClosure: public HeapRegionClosure { | |
2658 CollectionSetChooser* _hrSorted; | |
2659 jint _marked_regions_added; | |
2660 jint _chunk_size; | |
2661 jint _cur_chunk_idx; | |
2662 jint _cur_chunk_end; // Cur chunk [_cur_chunk_idx, _cur_chunk_end) | |
2663 int _worker; | |
2664 int _invokes; | |
2665 | |
2666 void get_new_chunk() { | |
2667 _cur_chunk_idx = _hrSorted->getParMarkedHeapRegionChunk(_chunk_size); | |
2668 _cur_chunk_end = _cur_chunk_idx + _chunk_size; | |
2669 } | |
2670 void add_region(HeapRegion* r) { | |
2671 if (_cur_chunk_idx == _cur_chunk_end) { | |
2672 get_new_chunk(); | |
2673 } | |
2674 assert(_cur_chunk_idx < _cur_chunk_end, "postcondition"); | |
2675 _hrSorted->setMarkedHeapRegion(_cur_chunk_idx, r); | |
2676 _marked_regions_added++; | |
2677 _cur_chunk_idx++; | |
2678 } | |
2679 | |
2680 public: | |
2681 ParKnownGarbageHRClosure(CollectionSetChooser* hrSorted, | |
2682 jint chunk_size, | |
2683 int worker) : | |
2684 _hrSorted(hrSorted), _chunk_size(chunk_size), _worker(worker), | |
2685 _marked_regions_added(0), _cur_chunk_idx(0), _cur_chunk_end(0), | |
2686 _invokes(0) | |
2687 {} | |
2688 | |
2689 bool doHeapRegion(HeapRegion* r) { | |
2690 // We only include humongous regions in collection | |
2691 // sets when concurrent mark shows that their contained object is | |
2692 // unreachable. | |
2693 _invokes++; | |
2694 | |
2695 // Do we have any marking information for this region? | |
2696 if (r->is_marked()) { | |
2697 // We don't include humongous regions in collection | |
2698 // sets because we collect them immediately at the end of a marking | |
2699 // cycle. | |
2700 // We also do not include young regions in collection sets | |
2701 if (!r->isHumongous() && !r->is_young()) { | |
2702 add_region(r); | |
2703 } | |
2704 } | |
2705 return false; | |
2706 } | |
2707 jint marked_regions_added() { return _marked_regions_added; } | |
2708 int invokes() { return _invokes; } | |
2709 }; | |
2710 | |
2711 class ParKnownGarbageTask: public AbstractGangTask { | |
2712 CollectionSetChooser* _hrSorted; | |
2713 jint _chunk_size; | |
2714 G1CollectedHeap* _g1; | |
2715 public: | |
2716 ParKnownGarbageTask(CollectionSetChooser* hrSorted, jint chunk_size) : | |
2717 AbstractGangTask("ParKnownGarbageTask"), | |
2718 _hrSorted(hrSorted), _chunk_size(chunk_size), | |
2719 _g1(G1CollectedHeap::heap()) | |
2720 {} | |
2721 | |
2722 void work(int i) { | |
2723 ParKnownGarbageHRClosure parKnownGarbageCl(_hrSorted, _chunk_size, i); | |
2724 // Back to zero for the claim value. | |
355 | 2725 _g1->heap_region_par_iterate_chunked(&parKnownGarbageCl, i, |
2726 HeapRegion::InitialClaimValue); | |
342 | 2727 jint regions_added = parKnownGarbageCl.marked_regions_added(); |
2728 _hrSorted->incNumMarkedHeapRegions(regions_added); | |
2729 if (G1PrintParCleanupStats) { | |
2730 gclog_or_tty->print(" Thread %d called %d times, added %d regions to list.\n", | |
2731 i, parKnownGarbageCl.invokes(), regions_added); | |
2732 } | |
2733 } | |
2734 }; | |
2735 | |
2736 void | |
2737 G1CollectorPolicy_BestRegionsFirst:: | |
2738 record_concurrent_mark_cleanup_end(size_t freed_bytes, | |
2739 size_t max_live_bytes) { | |
2740 double start; | |
2741 if (G1PrintParCleanupStats) start = os::elapsedTime(); | |
2742 record_concurrent_mark_cleanup_end_work1(freed_bytes, max_live_bytes); | |
2743 | |
2744 _collectionSetChooser->clearMarkedHeapRegions(); | |
2745 double clear_marked_end; | |
2746 if (G1PrintParCleanupStats) { | |
2747 clear_marked_end = os::elapsedTime(); | |
2748 gclog_or_tty->print_cr(" clear marked regions + work1: %8.3f ms.", | |
2749 (clear_marked_end - start)*1000.0); | |
2750 } | |
2751 if (ParallelGCThreads > 0) { | |
2752 const size_t OverpartitionFactor = 4; | |
2753 const size_t MinChunkSize = 8; | |
2754 const size_t ChunkSize = | |
2755 MAX2(_g1->n_regions() / (ParallelGCThreads * OverpartitionFactor), | |
2756 MinChunkSize); | |
2757 _collectionSetChooser->prepareForAddMarkedHeapRegionsPar(_g1->n_regions(), | |
2758 ChunkSize); | |
2759 ParKnownGarbageTask parKnownGarbageTask(_collectionSetChooser, | |
2760 (int) ChunkSize); | |
2761 _g1->workers()->run_task(&parKnownGarbageTask); | |
355 | 2762 |
2763 assert(_g1->check_heap_region_claim_values(HeapRegion::InitialClaimValue), | |
2764 "sanity check"); | |
342 | 2765 } else { |
2766 KnownGarbageClosure knownGarbagecl(_collectionSetChooser); | |
2767 _g1->heap_region_iterate(&knownGarbagecl); | |
2768 } | |
2769 double known_garbage_end; | |
2770 if (G1PrintParCleanupStats) { | |
2771 known_garbage_end = os::elapsedTime(); | |
2772 gclog_or_tty->print_cr(" compute known garbage: %8.3f ms.", | |
2773 (known_garbage_end - clear_marked_end)*1000.0); | |
2774 } | |
2775 _collectionSetChooser->sortMarkedHeapRegions(); | |
2776 double sort_end; | |
2777 if (G1PrintParCleanupStats) { | |
2778 sort_end = os::elapsedTime(); | |
2779 gclog_or_tty->print_cr(" sorting: %8.3f ms.", | |
2780 (sort_end - known_garbage_end)*1000.0); | |
2781 } | |
2782 | |
2783 record_concurrent_mark_cleanup_end_work2(); | |
2784 double work2_end; | |
2785 if (G1PrintParCleanupStats) { | |
2786 work2_end = os::elapsedTime(); | |
2787 gclog_or_tty->print_cr(" work2: %8.3f ms.", | |
2788 (work2_end - sort_end)*1000.0); | |
2789 } | |
2790 } | |
2791 | |
2792 // Add the heap region to the collection set and return the conservative | |
2793 // estimate of the number of live bytes. | |
2794 void G1CollectorPolicy:: | |
2795 add_to_collection_set(HeapRegion* hr) { | |
751 | 2796 if (G1PrintRegions) { |
342 | 2797 gclog_or_tty->print_cr("added region to cset %d:["PTR_FORMAT", "PTR_FORMAT"], " |
2798 "top "PTR_FORMAT", young %s", | |
2799 hr->hrs_index(), hr->bottom(), hr->end(), | |
2800 hr->top(), (hr->is_young()) ? "YES" : "NO"); | |
2801 } | |
2802 | |
2803 if (_g1->mark_in_progress()) | |
2804 _g1->concurrent_mark()->registerCSetRegion(hr); | |
2805 | |
2806 assert(!hr->in_collection_set(), | |
2807 "should not already be in the CSet"); | |
2808 hr->set_in_collection_set(true); | |
2809 hr->set_next_in_collection_set(_collection_set); | |
2810 _collection_set = hr; | |
2811 _collection_set_size++; | |
2812 _collection_set_bytes_used_before += hr->used(); | |
526 | 2813 _g1->register_region_with_in_cset_fast_test(hr); |
342 | 2814 } |
2815 | |
2816 void | |
2817 G1CollectorPolicy_BestRegionsFirst:: | |
677 | 2818 choose_collection_set() { |
342 | 2819 double non_young_start_time_sec; |
2820 start_recording_regions(); | |
2821 | |
677 | 2822 guarantee(_target_pause_time_ms > -1.0, |
2823 "_target_pause_time_ms should have been set!"); | |
2824 assert(_collection_set == NULL, "Precondition"); | |
342 | 2825 |
2826 double base_time_ms = predict_base_elapsed_time_ms(_pending_cards); | |
2827 double predicted_pause_time_ms = base_time_ms; | |
2828 | |
2829 double target_time_ms = _target_pause_time_ms; | |
2830 double time_remaining_ms = target_time_ms - base_time_ms; | |
2831 | |
2832 // the 10% and 50% values are arbitrary... | |
2833 if (time_remaining_ms < 0.10*target_time_ms) { | |
2834 time_remaining_ms = 0.50 * target_time_ms; | |
2835 _within_target = false; | |
2836 } else { | |
2837 _within_target = true; | |
2838 } | |
2839 | |
2840 // We figure out the number of bytes available for future to-space. | |
2841 // For new regions without marking information, we must assume the | |
2842 // worst-case of complete survival. If we have marking information for a | |
2843 // region, we can bound the amount of live data. We can add a number of | |
2844 // such regions, as long as the sum of the live data bounds does not | |
2845 // exceed the available evacuation space. | |
2846 size_t max_live_bytes = _g1->free_regions() * HeapRegion::GrainBytes; | |
2847 | |
2848 size_t expansion_bytes = | |
2849 _g1->expansion_regions() * HeapRegion::GrainBytes; | |
2850 | |
677 | 2851 _collection_set_bytes_used_before = 0; |
2852 _collection_set_size = 0; | |
342 | 2853 |
2854 // Adjust for expansion and slop. | |
2855 max_live_bytes = max_live_bytes + expansion_bytes; | |
2856 | |
677 | 2857 assert(_g1->regions_accounted_for(), "Region leakage!"); |
342 | 2858 |
2859 HeapRegion* hr; | |
2860 if (in_young_gc_mode()) { | |
2861 double young_start_time_sec = os::elapsedTime(); | |
2862 | |
2863 if (G1PolicyVerbose > 0) { | |
2864 gclog_or_tty->print_cr("Adding %d young regions to the CSet", | |
2865 _g1->young_list_length()); | |
2866 } | |
2867 _young_cset_length = 0; | |
2868 _last_young_gc_full = full_young_gcs() ? true : false; | |
2869 if (_last_young_gc_full) | |
2870 ++_full_young_pause_num; | |
2871 else | |
2872 ++_partial_young_pause_num; | |
2873 hr = _g1->pop_region_from_young_list(); | |
2874 while (hr != NULL) { | |
2875 | |
2876 assert( hr->young_index_in_cset() == -1, "invariant" ); | |
2877 assert( hr->age_in_surv_rate_group() != -1, "invariant" ); | |
2878 hr->set_young_index_in_cset((int) _young_cset_length); | |
2879 | |
2880 ++_young_cset_length; | |
2881 double predicted_time_ms = predict_region_elapsed_time_ms(hr, true); | |
2882 time_remaining_ms -= predicted_time_ms; | |
2883 predicted_pause_time_ms += predicted_time_ms; | |
677 | 2884 assert(!hr->in_collection_set(), "invariant"); |
2885 add_to_collection_set(hr); | |
2886 record_cset_region(hr, true); | |
342 | 2887 max_live_bytes -= MIN2(hr->max_live_bytes(), max_live_bytes); |
2888 if (G1PolicyVerbose > 0) { | |
2889 gclog_or_tty->print_cr(" Added [" PTR_FORMAT ", " PTR_FORMAT") to CS.", | |
2890 hr->bottom(), hr->end()); | |
2891 gclog_or_tty->print_cr(" (" SIZE_FORMAT " KB left in heap.)", | |
2892 max_live_bytes/K); | |
2893 } | |
2894 hr = _g1->pop_region_from_young_list(); | |
2895 } | |
2896 | |
2897 record_scan_only_regions(_g1->young_list_scan_only_length()); | |
2898 | |
2899 double young_end_time_sec = os::elapsedTime(); | |
2900 _recorded_young_cset_choice_time_ms = | |
2901 (young_end_time_sec - young_start_time_sec) * 1000.0; | |
2902 | |
2903 non_young_start_time_sec = os::elapsedTime(); | |
2904 | |
2905 if (_young_cset_length > 0 && _last_young_gc_full) { | |
2906 // don't bother adding more regions... | |
2907 goto choose_collection_set_end; | |
2908 } | |
2909 } | |
2910 | |
2911 if (!in_young_gc_mode() || !full_young_gcs()) { | |
2912 bool should_continue = true; | |
2913 NumberSeq seq; | |
2914 double avg_prediction = 100000000000000000.0; // something very large | |
2915 do { | |
2916 hr = _collectionSetChooser->getNextMarkedRegion(time_remaining_ms, | |
2917 avg_prediction); | |
677 | 2918 if (hr != NULL) { |
342 | 2919 double predicted_time_ms = predict_region_elapsed_time_ms(hr, false); |
2920 time_remaining_ms -= predicted_time_ms; | |
2921 predicted_pause_time_ms += predicted_time_ms; | |
2922 add_to_collection_set(hr); | |
2923 record_cset_region(hr, false); | |
2924 max_live_bytes -= MIN2(hr->max_live_bytes(), max_live_bytes); | |
2925 if (G1PolicyVerbose > 0) { | |
2926 gclog_or_tty->print_cr(" (" SIZE_FORMAT " KB left in heap.)", | |
2927 max_live_bytes/K); | |
2928 } | |
2929 seq.add(predicted_time_ms); | |
2930 avg_prediction = seq.avg() + seq.sd(); | |
2931 } | |
2932 should_continue = | |
2933 ( hr != NULL) && | |
2934 ( (adaptive_young_list_length()) ? time_remaining_ms > 0.0 | |
2935 : _collection_set_size < _young_list_fixed_length ); | |
2936 } while (should_continue); | |
2937 | |
2938 if (!adaptive_young_list_length() && | |
2939 _collection_set_size < _young_list_fixed_length) | |
2940 _should_revert_to_full_young_gcs = true; | |
2941 } | |
2942 | |
2943 choose_collection_set_end: | |
2944 count_CS_bytes_used(); | |
2945 | |
2946 end_recording_regions(); | |
2947 | |
2948 double non_young_end_time_sec = os::elapsedTime(); | |
2949 _recorded_non_young_cset_choice_time_ms = | |
2950 (non_young_end_time_sec - non_young_start_time_sec) * 1000.0; | |
2951 } | |
2952 | |
2953 void G1CollectorPolicy_BestRegionsFirst::record_full_collection_end() { | |
2954 G1CollectorPolicy::record_full_collection_end(); | |
2955 _collectionSetChooser->updateAfterFullCollection(); | |
2956 } | |
2957 | |
2958 void G1CollectorPolicy_BestRegionsFirst:: | |
2959 expand_if_possible(size_t numRegions) { | |
2960 size_t expansion_bytes = numRegions * HeapRegion::GrainBytes; | |
2961 _g1->expand(expansion_bytes); | |
2962 } | |
2963 | |
2964 void G1CollectorPolicy_BestRegionsFirst:: | |
677 | 2965 record_collection_pause_end(bool abandoned) { |
2966 G1CollectorPolicy::record_collection_pause_end(abandoned); | |
342 | 2967 assert(assertMarkedBytesDataOK(), "Marked regions not OK at pause end."); |
2968 } | |
2969 | |
2970 // Local Variables: *** | |
2971 // c-indentation-style: gnu *** | |
2972 // End: *** |