10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc/g1/g1CollectedHeap.inline.hpp"
27 #include "gc/g1/g1Predictions.hpp"
28 #include "gc/g1/heapRegion.hpp"
29 #include "gc/g1/survRateGroup.hpp"
30 #include "memory/allocation.hpp"
31
32 SurvRateGroup::SurvRateGroup(G1Predictions* predictor,
33 const char* name,
34 size_t summary_surv_rates_len) :
35 _predictor(predictor), _name(name),
36 _summary_surv_rates_len(summary_surv_rates_len),
37 _summary_surv_rates_max_len(0),
38 _summary_surv_rates(NULL),
39 _surv_rate(NULL),
40 _accum_surv_rate_pred(NULL),
41 _surv_rate_pred(NULL),
42 _stats_arrays_length(0) {
43 reset();
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, mtGC);
47 for (size_t i = 0; i < length; ++i) {
48 _summary_surv_rates[i] = new NumberSeq();
49 }
146 for (size_t i = _region_num; i < _stats_arrays_length; ++i) {
147 guarantee( _surv_rate[i] <= 0.00001,
148 "the slot should not have been updated" );
149 _surv_rate_pred[i]->add(surv_rate);
150 }
151 }
152
153 double accum = 0.0;
154 double pred = 0.0;
155 for (size_t i = 0; i < _stats_arrays_length; ++i) {
156 pred = get_new_prediction(_surv_rate_pred[i]);
157 if (pred > 1.0) pred = 1.0;
158 accum += pred;
159 _accum_surv_rate_pred[i] = accum;
160 }
161 _last_pred = pred;
162 }
163
164 #ifndef PRODUCT
165 void SurvRateGroup::print() {
166 gclog_or_tty->print_cr("Surv Rate Group: %s (" SIZE_FORMAT " entries)",
167 _name, _region_num);
168 for (size_t i = 0; i < _region_num; ++i) {
169 gclog_or_tty->print_cr(" age " SIZE_FORMAT_W(4) " surv rate %6.2lf %% pred %6.2lf %%",
170 i, _surv_rate[i] * 100.0,
171 _predictor->get_new_prediction(_surv_rate_pred[i]) * 100.0);
172 }
173 }
174
175 void
176 SurvRateGroup::print_surv_rate_summary() {
177 size_t length = _summary_surv_rates_max_len;
178 if (length == 0)
179 return;
180
181 gclog_or_tty->cr();
182 gclog_or_tty->print_cr("%s Rate Summary (for up to age " SIZE_FORMAT ")", _name, length-1);
183 gclog_or_tty->print_cr(" age range survival rate (avg) samples (avg)");
184 gclog_or_tty->print_cr(" ---------------------------------------------------------");
185
186 size_t index = 0;
187 size_t limit = MIN2((int) length, 10);
188 while (index < limit) {
189 gclog_or_tty->print_cr(" " SIZE_FORMAT_W(4)
190 " %6.2lf%% %6.2lf",
191 index, _summary_surv_rates[index]->avg() * 100.0,
192 (double) _summary_surv_rates[index]->num());
193 ++index;
194 }
195
196 gclog_or_tty->print_cr(" ---------------------------------------------------------");
197
198 int num = 0;
199 double sum = 0.0;
200 int samples = 0;
201 while (index < length) {
202 ++num;
203 sum += _summary_surv_rates[index]->avg() * 100.0;
204 samples += _summary_surv_rates[index]->num();
205 ++index;
206
207 if (index == length || num % 10 == 0) {
208 gclog_or_tty->print_cr(" " SIZE_FORMAT_W(4) " .. " SIZE_FORMAT_W(4)
209 " %6.2lf%% %6.2lf",
210 (index-1) / 10 * 10, index-1, sum / (double) num,
211 (double) samples / (double) num);
212 sum = 0.0;
213 num = 0;
214 samples = 0;
215 }
216 }
217
218 gclog_or_tty->print_cr(" ---------------------------------------------------------");
219 }
220 #endif // PRODUCT
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc/g1/g1CollectedHeap.inline.hpp"
27 #include "gc/g1/g1Predictions.hpp"
28 #include "gc/g1/heapRegion.hpp"
29 #include "gc/g1/survRateGroup.hpp"
30 #include "logging/log.hpp"
31 #include "memory/allocation.hpp"
32
33 SurvRateGroup::SurvRateGroup(G1Predictions* predictor,
34 const char* name,
35 size_t summary_surv_rates_len) :
36 _predictor(predictor), _name(name),
37 _summary_surv_rates_len(summary_surv_rates_len),
38 _summary_surv_rates_max_len(0),
39 _summary_surv_rates(NULL),
40 _surv_rate(NULL),
41 _accum_surv_rate_pred(NULL),
42 _surv_rate_pred(NULL),
43 _stats_arrays_length(0) {
44 reset();
45 if (summary_surv_rates_len > 0) {
46 size_t length = summary_surv_rates_len;
47 _summary_surv_rates = NEW_C_HEAP_ARRAY(NumberSeq*, length, mtGC);
48 for (size_t i = 0; i < length; ++i) {
49 _summary_surv_rates[i] = new NumberSeq();
50 }
147 for (size_t i = _region_num; i < _stats_arrays_length; ++i) {
148 guarantee( _surv_rate[i] <= 0.00001,
149 "the slot should not have been updated" );
150 _surv_rate_pred[i]->add(surv_rate);
151 }
152 }
153
154 double accum = 0.0;
155 double pred = 0.0;
156 for (size_t i = 0; i < _stats_arrays_length; ++i) {
157 pred = get_new_prediction(_surv_rate_pred[i]);
158 if (pred > 1.0) pred = 1.0;
159 accum += pred;
160 _accum_surv_rate_pred[i] = accum;
161 }
162 _last_pred = pred;
163 }
164
165 #ifndef PRODUCT
166 void SurvRateGroup::print() {
167 log_develop(gc, survivor)("Surv Rate Group: %s (" SIZE_FORMAT " entries)", _name, _region_num);
168 for (size_t i = 0; i < _region_num; ++i) {
169 log_develop(gc, survivor)(" age " SIZE_FORMAT_W(4) " surv rate %6.2lf %% pred %6.2lf %%",
170 i, _surv_rate[i] * 100.0,
171 _predictor->get_new_prediction(_surv_rate_pred[i]) * 100.0);
172 }
173 }
174
175 void
176 SurvRateGroup::print_surv_rate_summary() {
177 size_t length = _summary_surv_rates_max_len;
178 if (length == 0)
179 return;
180
181 log_debug(gc, survivor, stats)("%s Rate Summary (for up to age " SIZE_FORMAT ")", _name, length-1);
182 log_debug(gc, survivor, stats)(" age range survival rate (avg) samples (avg)");
183 log_debug(gc, survivor, stats)(" ---------------------------------------------------------");
184
185 size_t index = 0;
186 size_t limit = MIN2((int) length, 10);
187 while (index < limit) {
188 log_debug(gc, survivor, stats)(" " SIZE_FORMAT_W(4)
189 " %6.2lf%% %6.2lf",
190 index, _summary_surv_rates[index]->avg() * 100.0,
191 (double) _summary_surv_rates[index]->num());
192 ++index;
193 }
194
195 log_debug(gc, survivor, stats)(" ---------------------------------------------------------");
196
197 int num = 0;
198 double sum = 0.0;
199 int samples = 0;
200 while (index < length) {
201 ++num;
202 sum += _summary_surv_rates[index]->avg() * 100.0;
203 samples += _summary_surv_rates[index]->num();
204 ++index;
205
206 if (index == length || num % 10 == 0) {
207 log_debug(gc, survivor, stats)(" " SIZE_FORMAT_W(4) " .. " SIZE_FORMAT_W(4)
208 " %6.2lf%% %6.2lf",
209 (index-1) / 10 * 10, index-1, sum / (double) num,
210 (double) samples / (double) num);
211 sum = 0.0;
212 num = 0;
213 samples = 0;
214 }
215 }
216
217 log_debug(gc, survivor, stats)(" ---------------------------------------------------------");
218 }
219 #endif // PRODUCT
|