Mercurial > hg > graal-compiler
annotate src/share/vm/gc_implementation/g1/survRateGroup.cpp @ 20292:5d7a63aee595
8049051: Use of during_initial_mark_pause() in G1CollectorPolicy::record_collection_pause_end() prevents use of seperate object copy time prediction during marking
Summary: Replaced use of during_initial_mark_pause() with the variable last_pause_included_initial_mark that holds the real old value of _during_initial_mark_pause.
Reviewed-by: brutisso, ehelin
author | tschatzl |
---|---|
date | Mon, 21 Jul 2014 09:59:37 +0200 |
parents | 78bbf4d43a14 |
children |
rev | line source |
---|---|
342 | 1 /* |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
6197
diff
changeset
|
2 * Copyright (c) 2001, 2014, 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 |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
6197
diff
changeset
|
32 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
6197
diff
changeset
|
33 |
342 | 34 SurvRateGroup::SurvRateGroup(G1CollectorPolicy* g1p, |
35 const char* name, | |
36 size_t summary_surv_rates_len) : | |
37 _g1p(g1p), _name(name), | |
38 _summary_surv_rates_len(summary_surv_rates_len), | |
39 _summary_surv_rates_max_len(0), | |
545 | 40 _summary_surv_rates(NULL), |
41 _surv_rate(NULL), | |
42 _accum_surv_rate_pred(NULL), | |
5938 | 43 _surv_rate_pred(NULL), |
44 _stats_arrays_length(0) { | |
545 | 45 reset(); |
342 | 46 if (summary_surv_rates_len > 0) { |
47 size_t length = summary_surv_rates_len; | |
6197 | 48 _summary_surv_rates = NEW_C_HEAP_ARRAY(NumberSeq*, length, mtGC); |
5938 | 49 for (size_t i = 0; i < length; ++i) { |
50 _summary_surv_rates[i] = new NumberSeq(); | |
342 | 51 } |
52 } | |
53 | |
54 start_adding_regions(); | |
55 } | |
56 | |
5938 | 57 void SurvRateGroup::reset() { |
545 | 58 _all_regions_allocated = 0; |
59 _setup_seq_num = 0; | |
60 _accum_surv_rate = 0.0; | |
61 _last_pred = 0.0; | |
62 // the following will set up the arrays with length 1 | |
63 _region_num = 1; | |
5938 | 64 |
65 // The call to stop_adding_regions() will use "new" to refill | |
66 // the _surv_rate_pred array, so we need to make sure to call | |
67 // "delete". | |
68 for (size_t i = 0; i < _stats_arrays_length; ++i) { | |
69 delete _surv_rate_pred[i]; | |
70 } | |
71 _stats_arrays_length = 0; | |
72 | |
545 | 73 stop_adding_regions(); |
74 guarantee( _stats_arrays_length == 1, "invariant" ); | |
75 guarantee( _surv_rate_pred[0] != NULL, "invariant" ); | |
76 _surv_rate_pred[0]->add(0.4); | |
77 all_surviving_words_recorded(false); | |
78 _region_num = 0; | |
79 } | |
80 | |
342 | 81 void |
82 SurvRateGroup::start_adding_regions() { | |
545 | 83 _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
|
84 _region_num = 0; |
342 | 85 _accum_surv_rate = 0.0; |
86 } | |
87 | |
88 void | |
89 SurvRateGroup::stop_adding_regions() { | |
545 | 90 if (_region_num > _stats_arrays_length) { |
342 | 91 double* old_surv_rate = _surv_rate; |
92 double* old_accum_surv_rate_pred = _accum_surv_rate_pred; | |
93 TruncatedSeq** old_surv_rate_pred = _surv_rate_pred; | |
94 | |
6197 | 95 _surv_rate = NEW_C_HEAP_ARRAY(double, _region_num, mtGC); |
96 _accum_surv_rate_pred = NEW_C_HEAP_ARRAY(double, _region_num, mtGC); | |
97 _surv_rate_pred = NEW_C_HEAP_ARRAY(TruncatedSeq*, _region_num, mtGC); | |
342 | 98 |
5938 | 99 for (size_t i = 0; i < _stats_arrays_length; ++i) { |
342 | 100 _surv_rate_pred[i] = old_surv_rate_pred[i]; |
5938 | 101 } |
545 | 102 for (size_t i = _stats_arrays_length; i < _region_num; ++i) { |
342 | 103 _surv_rate_pred[i] = new TruncatedSeq(10); |
104 } | |
105 | |
545 | 106 _stats_arrays_length = _region_num; |
342 | 107 |
5938 | 108 if (old_surv_rate != NULL) { |
6197 | 109 FREE_C_HEAP_ARRAY(double, old_surv_rate, mtGC); |
5938 | 110 } |
111 if (old_accum_surv_rate_pred != NULL) { | |
6197 | 112 FREE_C_HEAP_ARRAY(double, old_accum_surv_rate_pred, mtGC); |
5938 | 113 } |
114 if (old_surv_rate_pred != NULL) { | |
6197 | 115 FREE_C_HEAP_ARRAY(TruncatedSeq*, old_surv_rate_pred, mtGC); |
5938 | 116 } |
342 | 117 } |
118 | |
5938 | 119 for (size_t i = 0; i < _stats_arrays_length; ++i) { |
342 | 120 _surv_rate[i] = 0.0; |
5938 | 121 } |
342 | 122 } |
123 | |
124 double | |
125 SurvRateGroup::accum_surv_rate(size_t adjustment) { | |
126 // we might relax this one in the future... | |
127 guarantee( adjustment == 0 || adjustment == 1, "pre-condition" ); | |
128 | |
129 double ret = _accum_surv_rate; | |
130 if (adjustment > 0) { | |
545 | 131 TruncatedSeq* seq = get_seq(_region_num+1); |
342 | 132 double surv_rate = _g1p->get_new_prediction(seq); |
133 ret += surv_rate; | |
134 } | |
135 | |
136 return ret; | |
137 } | |
138 | |
139 int | |
140 SurvRateGroup::next_age_index() { | |
545 | 141 TruncatedSeq* seq = get_seq(_region_num); |
342 | 142 double surv_rate = _g1p->get_new_prediction(seq); |
143 _accum_surv_rate += surv_rate; | |
144 | |
545 | 145 ++_region_num; |
342 | 146 return (int) ++_all_regions_allocated; |
147 } | |
148 | |
149 void | |
150 SurvRateGroup::record_surviving_words(int age_in_group, size_t surv_words) { | |
545 | 151 guarantee( 0 <= age_in_group && (size_t) age_in_group < _region_num, |
342 | 152 "pre-condition" ); |
153 guarantee( _surv_rate[age_in_group] <= 0.00001, | |
154 "should only update each slot once" ); | |
155 | |
156 double surv_rate = (double) surv_words / (double) HeapRegion::GrainWords; | |
157 _surv_rate[age_in_group] = surv_rate; | |
158 _surv_rate_pred[age_in_group]->add(surv_rate); | |
159 if ((size_t)age_in_group < _summary_surv_rates_len) { | |
160 _summary_surv_rates[age_in_group]->add(surv_rate); | |
161 if ((size_t)(age_in_group+1) > _summary_surv_rates_max_len) | |
162 _summary_surv_rates_max_len = age_in_group+1; | |
163 } | |
164 } | |
165 | |
166 void | |
167 SurvRateGroup::all_surviving_words_recorded(bool propagate) { | |
545 | 168 if (propagate && _region_num > 0) { // conservative |
169 double surv_rate = _surv_rate_pred[_region_num-1]->last(); | |
170 for (size_t i = _region_num; i < _stats_arrays_length; ++i) { | |
342 | 171 guarantee( _surv_rate[i] <= 0.00001, |
172 "the slot should not have been updated" ); | |
173 _surv_rate_pred[i]->add(surv_rate); | |
174 } | |
175 } | |
176 | |
177 double accum = 0.0; | |
178 double pred = 0.0; | |
545 | 179 for (size_t i = 0; i < _stats_arrays_length; ++i) { |
342 | 180 pred = _g1p->get_new_prediction(_surv_rate_pred[i]); |
181 if (pred > 1.0) pred = 1.0; | |
182 accum += pred; | |
183 _accum_surv_rate_pred[i] = accum; | |
184 // gclog_or_tty->print_cr("age %3d, accum %10.2lf", i, accum); | |
185 } | |
186 _last_pred = pred; | |
187 } | |
188 | |
189 #ifndef PRODUCT | |
190 void | |
191 SurvRateGroup::print() { | |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
579
diff
changeset
|
192 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
|
193 _name, _region_num); |
545 | 194 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
|
195 gclog_or_tty->print_cr(" age %4d surv rate %6.2lf %% pred %6.2lf %%", |
342 | 196 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
|
197 _g1p->get_new_prediction(_surv_rate_pred[i]) * 100.0); |
342 | 198 } |
199 } | |
200 | |
201 void | |
202 SurvRateGroup::print_surv_rate_summary() { | |
203 size_t length = _summary_surv_rates_max_len; | |
204 if (length == 0) | |
205 return; | |
206 | |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
6197
diff
changeset
|
207 gclog_or_tty->cr(); |
342 | 208 gclog_or_tty->print_cr("%s Rate Summary (for up to age %d)", _name, length-1); |
209 gclog_or_tty->print_cr(" age range survival rate (avg) samples (avg)"); | |
210 gclog_or_tty->print_cr(" ---------------------------------------------------------"); | |
211 | |
212 size_t index = 0; | |
213 size_t limit = MIN2((int) length, 10); | |
214 while (index < limit) { | |
215 gclog_or_tty->print_cr(" %4d %6.2lf%% %6.2lf", | |
216 index, _summary_surv_rates[index]->avg() * 100.0, | |
217 (double) _summary_surv_rates[index]->num()); | |
218 ++index; | |
219 } | |
220 | |
221 gclog_or_tty->print_cr(" ---------------------------------------------------------"); | |
222 | |
223 int num = 0; | |
224 double sum = 0.0; | |
225 int samples = 0; | |
226 while (index < length) { | |
227 ++num; | |
228 sum += _summary_surv_rates[index]->avg() * 100.0; | |
229 samples += _summary_surv_rates[index]->num(); | |
230 ++index; | |
231 | |
232 if (index == length || num % 10 == 0) { | |
233 gclog_or_tty->print_cr(" %4d .. %4d %6.2lf%% %6.2lf", | |
234 (index-1) / 10 * 10, index-1, sum / (double) num, | |
235 (double) samples / (double) num); | |
236 sum = 0.0; | |
237 num = 0; | |
238 samples = 0; | |
239 } | |
240 } | |
241 | |
242 gclog_or_tty->print_cr(" ---------------------------------------------------------"); | |
243 } | |
244 #endif // PRODUCT |