Mercurial > hg > graal-jvmci-8
annotate src/share/vm/gc_implementation/g1/survRateGroup.cpp @ 4097:dc467e8b2c5e
7112743: G1: Reduce overhead of marking closure during evacuation pauses
Summary: Parallelize the serial code that was used to mark objects reachable from survivor objects in the collection set. Some minor improvments in the timers used to track the freeing of the collection set along with some tweaks to PrintGCDetails.
Reviewed-by: tonyp, brutisso
author | johnc |
---|---|
date | Thu, 17 Nov 2011 12:40:15 -0800 |
parents | f95d63e2154a |
children | 2c0751569716 |
rev | line source |
---|---|
342 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1394
diff
changeset
|
2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1394
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1394
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1394
diff
changeset
|
21 * questions. |
342 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" | |
27 #include "gc_implementation/g1/g1CollectorPolicy.hpp" | |
28 #include "gc_implementation/g1/heapRegion.hpp" | |
29 #include "gc_implementation/g1/survRateGroup.hpp" | |
30 #include "memory/allocation.hpp" | |
342 | 31 |
32 SurvRateGroup::SurvRateGroup(G1CollectorPolicy* g1p, | |
33 const char* name, | |
34 size_t summary_surv_rates_len) : | |
35 _g1p(g1p), _name(name), | |
36 _summary_surv_rates_len(summary_surv_rates_len), | |
37 _summary_surv_rates_max_len(0), | |
545 | 38 _summary_surv_rates(NULL), |
39 _surv_rate(NULL), | |
40 _accum_surv_rate_pred(NULL), | |
41 _surv_rate_pred(NULL) | |
42 { | |
43 reset(); | |
342 | 44 if (summary_surv_rates_len > 0) { |
45 size_t length = summary_surv_rates_len; | |
46 _summary_surv_rates = NEW_C_HEAP_ARRAY(NumberSeq*, length); | |
47 if (_summary_surv_rates == NULL) { | |
48 vm_exit_out_of_memory(sizeof(NumberSeq*) * length, | |
49 "Not enough space for surv rate summary"); | |
50 } | |
51 for (size_t i = 0; i < length; ++i) | |
52 _summary_surv_rates[i] = new NumberSeq(); | |
53 } | |
54 | |
55 start_adding_regions(); | |
56 } | |
57 | |
545 | 58 |
59 void SurvRateGroup::reset() | |
60 { | |
61 _all_regions_allocated = 0; | |
62 _setup_seq_num = 0; | |
63 _stats_arrays_length = 0; | |
64 _accum_surv_rate = 0.0; | |
65 _last_pred = 0.0; | |
66 // the following will set up the arrays with length 1 | |
67 _region_num = 1; | |
68 stop_adding_regions(); | |
69 guarantee( _stats_arrays_length == 1, "invariant" ); | |
70 guarantee( _surv_rate_pred[0] != NULL, "invariant" ); | |
71 _surv_rate_pred[0]->add(0.4); | |
72 all_surviving_words_recorded(false); | |
73 _region_num = 0; | |
74 } | |
75 | |
76 | |
342 | 77 void |
78 SurvRateGroup::start_adding_regions() { | |
545 | 79 _setup_seq_num = _stats_arrays_length; |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
579
diff
changeset
|
80 _region_num = 0; |
342 | 81 _accum_surv_rate = 0.0; |
82 | |
83 #if 0 | |
545 | 84 gclog_or_tty->print_cr("[%s] start adding regions, seq num %d, length %d", |
85 _name, _setup_seq_num, _region_num); | |
342 | 86 #endif // 0 |
87 } | |
88 | |
89 void | |
90 SurvRateGroup::stop_adding_regions() { | |
91 | |
92 #if 0 | |
545 | 93 gclog_or_tty->print_cr("[%s] stop adding regions, length %d", _name, _region_num); |
342 | 94 #endif // 0 |
95 | |
545 | 96 if (_region_num > _stats_arrays_length) { |
342 | 97 double* old_surv_rate = _surv_rate; |
98 double* old_accum_surv_rate_pred = _accum_surv_rate_pred; | |
99 TruncatedSeq** old_surv_rate_pred = _surv_rate_pred; | |
100 | |
545 | 101 _surv_rate = NEW_C_HEAP_ARRAY(double, _region_num); |
342 | 102 if (_surv_rate == NULL) { |
545 | 103 vm_exit_out_of_memory(sizeof(double) * _region_num, |
342 | 104 "Not enough space for surv rate array."); |
105 } | |
545 | 106 _accum_surv_rate_pred = NEW_C_HEAP_ARRAY(double, _region_num); |
342 | 107 if (_accum_surv_rate_pred == NULL) { |
545 | 108 vm_exit_out_of_memory(sizeof(double) * _region_num, |
342 | 109 "Not enough space for accum surv rate pred array."); |
110 } | |
545 | 111 _surv_rate_pred = NEW_C_HEAP_ARRAY(TruncatedSeq*, _region_num); |
342 | 112 if (_surv_rate == NULL) { |
545 | 113 vm_exit_out_of_memory(sizeof(TruncatedSeq*) * _region_num, |
342 | 114 "Not enough space for surv rate pred array."); |
115 } | |
116 | |
545 | 117 for (size_t i = 0; i < _stats_arrays_length; ++i) |
342 | 118 _surv_rate_pred[i] = old_surv_rate_pred[i]; |
119 | |
120 #if 0 | |
545 | 121 gclog_or_tty->print_cr("[%s] stop adding regions, new seqs %d to %d", |
122 _name, _array_length, _region_num - 1); | |
342 | 123 #endif // 0 |
124 | |
545 | 125 for (size_t i = _stats_arrays_length; i < _region_num; ++i) { |
342 | 126 _surv_rate_pred[i] = new TruncatedSeq(10); |
127 // _surv_rate_pred[i]->add(last_pred); | |
128 } | |
129 | |
545 | 130 _stats_arrays_length = _region_num; |
342 | 131 |
132 if (old_surv_rate != NULL) | |
133 FREE_C_HEAP_ARRAY(double, old_surv_rate); | |
134 if (old_accum_surv_rate_pred != NULL) | |
135 FREE_C_HEAP_ARRAY(double, old_accum_surv_rate_pred); | |
136 if (old_surv_rate_pred != NULL) | |
137 FREE_C_HEAP_ARRAY(NumberSeq*, old_surv_rate_pred); | |
138 } | |
139 | |
545 | 140 for (size_t i = 0; i < _stats_arrays_length; ++i) |
342 | 141 _surv_rate[i] = 0.0; |
142 } | |
143 | |
144 double | |
145 SurvRateGroup::accum_surv_rate(size_t adjustment) { | |
146 // we might relax this one in the future... | |
147 guarantee( adjustment == 0 || adjustment == 1, "pre-condition" ); | |
148 | |
149 double ret = _accum_surv_rate; | |
150 if (adjustment > 0) { | |
545 | 151 TruncatedSeq* seq = get_seq(_region_num+1); |
342 | 152 double surv_rate = _g1p->get_new_prediction(seq); |
153 ret += surv_rate; | |
154 } | |
155 | |
156 return ret; | |
157 } | |
158 | |
159 int | |
160 SurvRateGroup::next_age_index() { | |
545 | 161 TruncatedSeq* seq = get_seq(_region_num); |
342 | 162 double surv_rate = _g1p->get_new_prediction(seq); |
163 _accum_surv_rate += surv_rate; | |
164 | |
545 | 165 ++_region_num; |
342 | 166 return (int) ++_all_regions_allocated; |
167 } | |
168 | |
169 void | |
170 SurvRateGroup::record_surviving_words(int age_in_group, size_t surv_words) { | |
545 | 171 guarantee( 0 <= age_in_group && (size_t) age_in_group < _region_num, |
342 | 172 "pre-condition" ); |
173 guarantee( _surv_rate[age_in_group] <= 0.00001, | |
174 "should only update each slot once" ); | |
175 | |
176 double surv_rate = (double) surv_words / (double) HeapRegion::GrainWords; | |
177 _surv_rate[age_in_group] = surv_rate; | |
178 _surv_rate_pred[age_in_group]->add(surv_rate); | |
179 if ((size_t)age_in_group < _summary_surv_rates_len) { | |
180 _summary_surv_rates[age_in_group]->add(surv_rate); | |
181 if ((size_t)(age_in_group+1) > _summary_surv_rates_max_len) | |
182 _summary_surv_rates_max_len = age_in_group+1; | |
183 } | |
184 } | |
185 | |
186 void | |
187 SurvRateGroup::all_surviving_words_recorded(bool propagate) { | |
545 | 188 if (propagate && _region_num > 0) { // conservative |
189 double surv_rate = _surv_rate_pred[_region_num-1]->last(); | |
342 | 190 |
191 #if 0 | |
192 gclog_or_tty->print_cr("propagating %1.2lf from %d to %d", | |
193 surv_rate, _curr_length, _array_length - 1); | |
194 #endif // 0 | |
195 | |
545 | 196 for (size_t i = _region_num; i < _stats_arrays_length; ++i) { |
342 | 197 guarantee( _surv_rate[i] <= 0.00001, |
198 "the slot should not have been updated" ); | |
199 _surv_rate_pred[i]->add(surv_rate); | |
200 } | |
201 } | |
202 | |
203 double accum = 0.0; | |
204 double pred = 0.0; | |
545 | 205 for (size_t i = 0; i < _stats_arrays_length; ++i) { |
342 | 206 pred = _g1p->get_new_prediction(_surv_rate_pred[i]); |
207 if (pred > 1.0) pred = 1.0; | |
208 accum += pred; | |
209 _accum_surv_rate_pred[i] = accum; | |
210 // gclog_or_tty->print_cr("age %3d, accum %10.2lf", i, accum); | |
211 } | |
212 _last_pred = pred; | |
213 } | |
214 | |
215 #ifndef PRODUCT | |
216 void | |
217 SurvRateGroup::print() { | |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
579
diff
changeset
|
218 gclog_or_tty->print_cr("Surv Rate Group: %s (%d entries)", |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
579
diff
changeset
|
219 _name, _region_num); |
545 | 220 for (size_t i = 0; i < _region_num; ++i) { |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
579
diff
changeset
|
221 gclog_or_tty->print_cr(" age %4d surv rate %6.2lf %% pred %6.2lf %%", |
342 | 222 i, _surv_rate[i] * 100.0, |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
579
diff
changeset
|
223 _g1p->get_new_prediction(_surv_rate_pred[i]) * 100.0); |
342 | 224 } |
225 } | |
226 | |
227 void | |
228 SurvRateGroup::print_surv_rate_summary() { | |
229 size_t length = _summary_surv_rates_max_len; | |
230 if (length == 0) | |
231 return; | |
232 | |
233 gclog_or_tty->print_cr(""); | |
234 gclog_or_tty->print_cr("%s Rate Summary (for up to age %d)", _name, length-1); | |
235 gclog_or_tty->print_cr(" age range survival rate (avg) samples (avg)"); | |
236 gclog_or_tty->print_cr(" ---------------------------------------------------------"); | |
237 | |
238 size_t index = 0; | |
239 size_t limit = MIN2((int) length, 10); | |
240 while (index < limit) { | |
241 gclog_or_tty->print_cr(" %4d %6.2lf%% %6.2lf", | |
242 index, _summary_surv_rates[index]->avg() * 100.0, | |
243 (double) _summary_surv_rates[index]->num()); | |
244 ++index; | |
245 } | |
246 | |
247 gclog_or_tty->print_cr(" ---------------------------------------------------------"); | |
248 | |
249 int num = 0; | |
250 double sum = 0.0; | |
251 int samples = 0; | |
252 while (index < length) { | |
253 ++num; | |
254 sum += _summary_surv_rates[index]->avg() * 100.0; | |
255 samples += _summary_surv_rates[index]->num(); | |
256 ++index; | |
257 | |
258 if (index == length || num % 10 == 0) { | |
259 gclog_or_tty->print_cr(" %4d .. %4d %6.2lf%% %6.2lf", | |
260 (index-1) / 10 * 10, index-1, sum / (double) num, | |
261 (double) samples / (double) num); | |
262 sum = 0.0; | |
263 num = 0; | |
264 samples = 0; | |
265 } | |
266 } | |
267 | |
268 gclog_or_tty->print_cr(" ---------------------------------------------------------"); | |
269 } | |
270 #endif // PRODUCT |