annotate src/share/vm/gc_implementation/g1/survRateGroup.cpp @ 545:58054a18d735

6484959: G1: introduce survivor spaces 6797754: G1: combined bugfix Summary: Implemented a policy to control G1 survivor space parameters. Reviewed-by: tonyp, iveresov
author apetrusenko
date Fri, 06 Feb 2009 01:38:50 +0300
parents 37f87013dfd8
children 0fbdb4381b99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
1 /*
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
2 * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
4 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
7 * published by the Free Software Foundation.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
8 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
13 * accompanied this code).
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
14 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
18 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
21 * have any questions.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
22 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
23 */
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
24
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
25 #include "incls/_precompiled.incl"
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
26 #include "incls/_survRateGroup.cpp.incl"
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
27
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
28 SurvRateGroup::SurvRateGroup(G1CollectorPolicy* g1p,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
29 const char* name,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
30 size_t summary_surv_rates_len) :
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
31 _g1p(g1p), _name(name),
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
32 _summary_surv_rates_len(summary_surv_rates_len),
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
33 _summary_surv_rates_max_len(0),
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
34 _summary_surv_rates(NULL),
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
35 _surv_rate(NULL),
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
36 _accum_surv_rate_pred(NULL),
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
37 _surv_rate_pred(NULL)
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
38 {
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
39 reset();
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
40 if (summary_surv_rates_len > 0) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
41 size_t length = summary_surv_rates_len;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
42 _summary_surv_rates = NEW_C_HEAP_ARRAY(NumberSeq*, length);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
43 if (_summary_surv_rates == NULL) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
44 vm_exit_out_of_memory(sizeof(NumberSeq*) * length,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
45 "Not enough space for surv rate summary");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
46 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
47 for (size_t i = 0; i < length; ++i)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
48 _summary_surv_rates[i] = new NumberSeq();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
49 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
50
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
51 start_adding_regions();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
52 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
53
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
54
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
55 void SurvRateGroup::reset()
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
56 {
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
57 _all_regions_allocated = 0;
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
58 _scan_only_prefix = 0;
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
59 _setup_seq_num = 0;
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
60 _stats_arrays_length = 0;
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
61 _accum_surv_rate = 0.0;
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
62 _last_pred = 0.0;
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
63 // the following will set up the arrays with length 1
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
64 _region_num = 1;
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
65 stop_adding_regions();
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
66 guarantee( _stats_arrays_length == 1, "invariant" );
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
67 guarantee( _surv_rate_pred[0] != NULL, "invariant" );
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
68 _surv_rate_pred[0]->add(0.4);
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
69 all_surviving_words_recorded(false);
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
70 _region_num = 0;
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
71 }
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
72
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
73
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
74 void
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
75 SurvRateGroup::start_adding_regions() {
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
76 _setup_seq_num = _stats_arrays_length;
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
77 _region_num = _scan_only_prefix;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
78 _accum_surv_rate = 0.0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
79
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
80 #if 0
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
81 gclog_or_tty->print_cr("[%s] start adding regions, seq num %d, length %d",
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
82 _name, _setup_seq_num, _region_num);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
83 #endif // 0
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
84 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
85
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
86 void
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
87 SurvRateGroup::stop_adding_regions() {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
88
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
89 #if 0
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
90 gclog_or_tty->print_cr("[%s] stop adding regions, length %d", _name, _region_num);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
91 #endif // 0
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
92
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
93 if (_region_num > _stats_arrays_length) {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
94 double* old_surv_rate = _surv_rate;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
95 double* old_accum_surv_rate_pred = _accum_surv_rate_pred;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
96 TruncatedSeq** old_surv_rate_pred = _surv_rate_pred;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
97
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
98 _surv_rate = NEW_C_HEAP_ARRAY(double, _region_num);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
99 if (_surv_rate == NULL) {
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
100 vm_exit_out_of_memory(sizeof(double) * _region_num,
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
101 "Not enough space for surv rate array.");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
102 }
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
103 _accum_surv_rate_pred = NEW_C_HEAP_ARRAY(double, _region_num);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
104 if (_accum_surv_rate_pred == NULL) {
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
105 vm_exit_out_of_memory(sizeof(double) * _region_num,
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
106 "Not enough space for accum surv rate pred array.");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
107 }
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
108 _surv_rate_pred = NEW_C_HEAP_ARRAY(TruncatedSeq*, _region_num);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
109 if (_surv_rate == NULL) {
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
110 vm_exit_out_of_memory(sizeof(TruncatedSeq*) * _region_num,
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
111 "Not enough space for surv rate pred array.");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
112 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
113
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
114 for (size_t i = 0; i < _stats_arrays_length; ++i)
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
115 _surv_rate_pred[i] = old_surv_rate_pred[i];
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
116
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
117 #if 0
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
118 gclog_or_tty->print_cr("[%s] stop adding regions, new seqs %d to %d",
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
119 _name, _array_length, _region_num - 1);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
120 #endif // 0
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
121
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
122 for (size_t i = _stats_arrays_length; i < _region_num; ++i) {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
123 _surv_rate_pred[i] = new TruncatedSeq(10);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
124 // _surv_rate_pred[i]->add(last_pred);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
125 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
126
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
127 _stats_arrays_length = _region_num;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
128
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
129 if (old_surv_rate != NULL)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
130 FREE_C_HEAP_ARRAY(double, old_surv_rate);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
131 if (old_accum_surv_rate_pred != NULL)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
132 FREE_C_HEAP_ARRAY(double, old_accum_surv_rate_pred);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
133 if (old_surv_rate_pred != NULL)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
134 FREE_C_HEAP_ARRAY(NumberSeq*, old_surv_rate_pred);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
135 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
136
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
137 for (size_t i = 0; i < _stats_arrays_length; ++i)
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
138 _surv_rate[i] = 0.0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
139 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
140
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
141 double
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
142 SurvRateGroup::accum_surv_rate(size_t adjustment) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
143 // we might relax this one in the future...
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
144 guarantee( adjustment == 0 || adjustment == 1, "pre-condition" );
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
145
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
146 double ret = _accum_surv_rate;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
147 if (adjustment > 0) {
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
148 TruncatedSeq* seq = get_seq(_region_num+1);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
149 double surv_rate = _g1p->get_new_prediction(seq);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
150 ret += surv_rate;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
151 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
152
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
153 return ret;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
154 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
155
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
156 int
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
157 SurvRateGroup::next_age_index() {
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
158 TruncatedSeq* seq = get_seq(_region_num);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
159 double surv_rate = _g1p->get_new_prediction(seq);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
160 _accum_surv_rate += surv_rate;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
161
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
162 ++_region_num;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
163 return (int) ++_all_regions_allocated;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
164 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
165
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
166 void
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
167 SurvRateGroup::record_scan_only_prefix(size_t scan_only_prefix) {
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
168 guarantee( scan_only_prefix <= _region_num, "pre-condition" );
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
169 _scan_only_prefix = scan_only_prefix;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
170 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
171
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
172 void
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
173 SurvRateGroup::record_surviving_words(int age_in_group, size_t surv_words) {
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
174 guarantee( 0 <= age_in_group && (size_t) age_in_group < _region_num,
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
175 "pre-condition" );
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
176 guarantee( _surv_rate[age_in_group] <= 0.00001,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
177 "should only update each slot once" );
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
178
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
179 double surv_rate = (double) surv_words / (double) HeapRegion::GrainWords;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
180 _surv_rate[age_in_group] = surv_rate;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
181 _surv_rate_pred[age_in_group]->add(surv_rate);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
182 if ((size_t)age_in_group < _summary_surv_rates_len) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
183 _summary_surv_rates[age_in_group]->add(surv_rate);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
184 if ((size_t)(age_in_group+1) > _summary_surv_rates_max_len)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
185 _summary_surv_rates_max_len = age_in_group+1;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
186 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
187 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
188
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
189 void
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
190 SurvRateGroup::all_surviving_words_recorded(bool propagate) {
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
191 if (propagate && _region_num > 0) { // conservative
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
192 double surv_rate = _surv_rate_pred[_region_num-1]->last();
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
193
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
194 #if 0
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
195 gclog_or_tty->print_cr("propagating %1.2lf from %d to %d",
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
196 surv_rate, _curr_length, _array_length - 1);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
197 #endif // 0
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
198
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
199 for (size_t i = _region_num; i < _stats_arrays_length; ++i) {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
200 guarantee( _surv_rate[i] <= 0.00001,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
201 "the slot should not have been updated" );
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
202 _surv_rate_pred[i]->add(surv_rate);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
203 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
204 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
205
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
206 double accum = 0.0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
207 double pred = 0.0;
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
208 for (size_t i = 0; i < _stats_arrays_length; ++i) {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
209 pred = _g1p->get_new_prediction(_surv_rate_pred[i]);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
210 if (pred > 1.0) pred = 1.0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
211 accum += pred;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
212 _accum_surv_rate_pred[i] = accum;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
213 // gclog_or_tty->print_cr("age %3d, accum %10.2lf", i, accum);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
214 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
215 _last_pred = pred;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
216 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
217
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
218 #ifndef PRODUCT
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
219 void
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
220 SurvRateGroup::print() {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
221 gclog_or_tty->print_cr("Surv Rate Group: %s (%d entries, %d scan-only)",
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
222 _name, _region_num, _scan_only_prefix);
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
223 for (size_t i = 0; i < _region_num; ++i) {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
224 gclog_or_tty->print_cr(" age %4d surv rate %6.2lf %% pred %6.2lf %%%s",
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
225 i, _surv_rate[i] * 100.0,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
226 _g1p->get_new_prediction(_surv_rate_pred[i]) * 100.0,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
227 (i < _scan_only_prefix) ? " S-O" : " ");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
228 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
229 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
230
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
231 void
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
232 SurvRateGroup::print_surv_rate_summary() {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
233 size_t length = _summary_surv_rates_max_len;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
234 if (length == 0)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
235 return;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
236
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
237 gclog_or_tty->print_cr("");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
238 gclog_or_tty->print_cr("%s Rate Summary (for up to age %d)", _name, length-1);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
239 gclog_or_tty->print_cr(" age range survival rate (avg) samples (avg)");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
240 gclog_or_tty->print_cr(" ---------------------------------------------------------");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
241
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
242 size_t index = 0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
243 size_t limit = MIN2((int) length, 10);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
244 while (index < limit) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
245 gclog_or_tty->print_cr(" %4d %6.2lf%% %6.2lf",
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
246 index, _summary_surv_rates[index]->avg() * 100.0,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
247 (double) _summary_surv_rates[index]->num());
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
248 ++index;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
249 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
250
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
251 gclog_or_tty->print_cr(" ---------------------------------------------------------");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
252
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
253 int num = 0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
254 double sum = 0.0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
255 int samples = 0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
256 while (index < length) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
257 ++num;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
258 sum += _summary_surv_rates[index]->avg() * 100.0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
259 samples += _summary_surv_rates[index]->num();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
260 ++index;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
261
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
262 if (index == length || num % 10 == 0) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
263 gclog_or_tty->print_cr(" %4d .. %4d %6.2lf%% %6.2lf",
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
264 (index-1) / 10 * 10, index-1, sum / (double) num,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
265 (double) samples / (double) num);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
266 sum = 0.0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
267 num = 0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
268 samples = 0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
269 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
270 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
271
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
272 gclog_or_tty->print_cr(" ---------------------------------------------------------");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
273 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
274 #endif // PRODUCT