1
|
1 |
/*
|
|
2 |
* Copyright 2004-2005 Sun Microsystems, Inc. All Rights Reserved.
|
|
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 |
// This class keeps statistical information and computes the
|
|
26 |
// size of the heap.
|
|
27 |
|
|
28 |
class GCAdaptivePolicyCounters : public GCPolicyCounters {
|
|
29 |
protected:
|
|
30 |
PerfVariable* _eden_size_counter;
|
|
31 |
PerfVariable* _promo_size_counter;
|
|
32 |
|
|
33 |
PerfVariable* _young_capacity_counter;
|
|
34 |
|
|
35 |
PerfVariable* _minor_gc_cost_counter;
|
|
36 |
PerfVariable* _major_gc_cost_counter;
|
|
37 |
PerfVariable* _mutator_cost_counter;
|
|
38 |
|
|
39 |
PerfVariable* _avg_young_live_counter;
|
|
40 |
PerfVariable* _avg_old_live_counter;
|
|
41 |
|
|
42 |
PerfVariable* _avg_minor_pause_counter;
|
|
43 |
PerfVariable* _avg_minor_interval_counter;
|
|
44 |
|
|
45 |
#ifdef NOT_PRODUCT
|
|
46 |
PerfVariable* _minor_pause_counter;
|
|
47 |
#endif
|
|
48 |
|
|
49 |
PerfVariable* _change_young_gen_for_min_pauses_counter;
|
|
50 |
PerfVariable* _change_young_gen_for_throughput_counter;
|
|
51 |
PerfVariable* _change_old_gen_for_maj_pauses_counter;
|
|
52 |
PerfVariable* _change_old_gen_for_throughput_counter;
|
|
53 |
PerfVariable* _decrease_for_footprint_counter;
|
|
54 |
|
|
55 |
PerfVariable* _minor_pause_young_slope_counter;
|
|
56 |
PerfVariable* _major_pause_old_slope_counter;
|
|
57 |
|
|
58 |
PerfVariable* _decide_at_full_gc_counter;
|
|
59 |
|
|
60 |
PerfVariable* _survived_counter;
|
|
61 |
PerfVariable* _promoted_counter;
|
|
62 |
|
|
63 |
PerfVariable* _avg_survived_avg_counter;
|
|
64 |
PerfVariable* _avg_survived_dev_counter;
|
|
65 |
PerfVariable* _avg_survived_padded_avg_counter;
|
|
66 |
|
|
67 |
PerfVariable* _survivor_overflowed_counter;
|
|
68 |
PerfVariable* _increment_tenuring_threshold_for_gc_cost_counter;
|
|
69 |
PerfVariable* _decrement_tenuring_threshold_for_gc_cost_counter;
|
|
70 |
PerfVariable* _decrement_tenuring_threshold_for_survivor_limit_counter;
|
|
71 |
|
|
72 |
PerfVariable* _minor_collection_slope_counter;
|
|
73 |
PerfVariable* _major_collection_slope_counter;
|
|
74 |
|
|
75 |
AdaptiveSizePolicy* _size_policy;
|
|
76 |
|
|
77 |
inline void update_eden_size() {
|
|
78 |
size_t eden_size_in_bytes = size_policy()->calculated_eden_size_in_bytes();
|
|
79 |
_eden_size_counter->set_value(eden_size_in_bytes);
|
|
80 |
}
|
|
81 |
|
|
82 |
inline void update_promo_size() {
|
|
83 |
_promo_size_counter->set_value(
|
|
84 |
size_policy()->calculated_promo_size_in_bytes());
|
|
85 |
}
|
|
86 |
|
|
87 |
inline void update_avg_minor_pause_counter() {
|
|
88 |
_avg_minor_pause_counter->set_value((jlong)
|
|
89 |
(size_policy()->avg_minor_pause()->average() * 1000.0));
|
|
90 |
}
|
|
91 |
inline void update_avg_minor_interval_counter() {
|
|
92 |
_avg_minor_interval_counter->set_value((jlong)
|
|
93 |
(size_policy()->avg_minor_interval()->average() * 1000.0));
|
|
94 |
}
|
|
95 |
|
|
96 |
#ifdef NOT_PRODUCT
|
|
97 |
inline void update_minor_pause_counter() {
|
|
98 |
_minor_pause_counter->set_value((jlong)
|
|
99 |
(size_policy()->avg_minor_pause()->last_sample() * 1000.0));
|
|
100 |
}
|
|
101 |
#endif
|
|
102 |
inline void update_minor_gc_cost_counter() {
|
|
103 |
_minor_gc_cost_counter->set_value((jlong)
|
|
104 |
(size_policy()->minor_gc_cost() * 100.0));
|
|
105 |
}
|
|
106 |
|
|
107 |
inline void update_avg_young_live_counter() {
|
|
108 |
_avg_young_live_counter->set_value(
|
|
109 |
(jlong)(size_policy()->avg_young_live()->average())
|
|
110 |
);
|
|
111 |
}
|
|
112 |
|
|
113 |
inline void update_avg_survived_avg_counters() {
|
|
114 |
_avg_survived_avg_counter->set_value(
|
|
115 |
(jlong)(size_policy()->_avg_survived->average())
|
|
116 |
);
|
|
117 |
}
|
|
118 |
inline void update_avg_survived_dev_counters() {
|
|
119 |
_avg_survived_dev_counter->set_value(
|
|
120 |
(jlong)(size_policy()->_avg_survived->deviation())
|
|
121 |
);
|
|
122 |
}
|
|
123 |
inline void update_avg_survived_padded_avg_counters() {
|
|
124 |
_avg_survived_padded_avg_counter->set_value(
|
|
125 |
(jlong)(size_policy()->_avg_survived->padded_average())
|
|
126 |
);
|
|
127 |
}
|
|
128 |
|
|
129 |
inline void update_change_old_gen_for_throughput() {
|
|
130 |
_change_old_gen_for_throughput_counter->set_value(
|
|
131 |
size_policy()->change_old_gen_for_throughput());
|
|
132 |
}
|
|
133 |
inline void update_change_young_gen_for_throughput() {
|
|
134 |
_change_young_gen_for_throughput_counter->set_value(
|
|
135 |
size_policy()->change_young_gen_for_throughput());
|
|
136 |
}
|
|
137 |
inline void update_decrease_for_footprint() {
|
|
138 |
_decrease_for_footprint_counter->set_value(
|
|
139 |
size_policy()->decrease_for_footprint());
|
|
140 |
}
|
|
141 |
|
|
142 |
inline void update_decide_at_full_gc_counter() {
|
|
143 |
_decide_at_full_gc_counter->set_value(
|
|
144 |
size_policy()->decide_at_full_gc());
|
|
145 |
}
|
|
146 |
|
|
147 |
inline void update_minor_pause_young_slope_counter() {
|
|
148 |
_minor_pause_young_slope_counter->set_value(
|
|
149 |
(jlong)(size_policy()->minor_pause_young_slope() * 1000)
|
|
150 |
);
|
|
151 |
}
|
|
152 |
|
|
153 |
virtual void update_counters_from_policy();
|
|
154 |
|
|
155 |
protected:
|
|
156 |
virtual AdaptiveSizePolicy* size_policy() { return _size_policy; }
|
|
157 |
|
|
158 |
public:
|
|
159 |
GCAdaptivePolicyCounters(const char* name,
|
|
160 |
int collectors,
|
|
161 |
int generations,
|
|
162 |
AdaptiveSizePolicy* size_policy);
|
|
163 |
|
|
164 |
inline void update_survived(size_t survived) {
|
|
165 |
_survived_counter->set_value(survived);
|
|
166 |
}
|
|
167 |
inline void update_promoted(size_t promoted) {
|
|
168 |
_promoted_counter->set_value(promoted);
|
|
169 |
}
|
|
170 |
inline void update_young_capacity(size_t size_in_bytes) {
|
|
171 |
_young_capacity_counter->set_value(size_in_bytes);
|
|
172 |
}
|
|
173 |
|
|
174 |
virtual void update_counters();
|
|
175 |
|
|
176 |
inline void update_survivor_size_counters() {
|
|
177 |
desired_survivor_size()->set_value(
|
|
178 |
size_policy()->calculated_survivor_size_in_bytes());
|
|
179 |
}
|
|
180 |
inline void update_survivor_overflowed(bool survivor_overflowed) {
|
|
181 |
_survivor_overflowed_counter->set_value(survivor_overflowed);
|
|
182 |
}
|
|
183 |
inline void update_tenuring_threshold(int threshold) {
|
|
184 |
tenuring_threshold()->set_value(threshold);
|
|
185 |
}
|
|
186 |
inline void update_increment_tenuring_threshold_for_gc_cost() {
|
|
187 |
_increment_tenuring_threshold_for_gc_cost_counter->set_value(
|
|
188 |
size_policy()->increment_tenuring_threshold_for_gc_cost());
|
|
189 |
}
|
|
190 |
inline void update_decrement_tenuring_threshold_for_gc_cost() {
|
|
191 |
_decrement_tenuring_threshold_for_gc_cost_counter->set_value(
|
|
192 |
size_policy()->decrement_tenuring_threshold_for_gc_cost());
|
|
193 |
}
|
|
194 |
inline void update_decrement_tenuring_threshold_for_survivor_limit() {
|
|
195 |
_decrement_tenuring_threshold_for_survivor_limit_counter->set_value(
|
|
196 |
size_policy()->decrement_tenuring_threshold_for_survivor_limit());
|
|
197 |
}
|
|
198 |
inline void update_change_young_gen_for_min_pauses() {
|
|
199 |
_change_young_gen_for_min_pauses_counter->set_value(
|
|
200 |
size_policy()->change_young_gen_for_min_pauses());
|
|
201 |
}
|
|
202 |
inline void update_change_old_gen_for_maj_pauses() {
|
|
203 |
_change_old_gen_for_maj_pauses_counter->set_value(
|
|
204 |
size_policy()->change_old_gen_for_maj_pauses());
|
|
205 |
}
|
|
206 |
|
|
207 |
inline void update_minor_collection_slope_counter() {
|
|
208 |
_minor_collection_slope_counter->set_value(
|
|
209 |
(jlong)(size_policy()->minor_collection_slope() * 1000)
|
|
210 |
);
|
|
211 |
}
|
|
212 |
|
|
213 |
inline void update_major_collection_slope_counter() {
|
|
214 |
_major_collection_slope_counter->set_value(
|
|
215 |
(jlong)(size_policy()->major_collection_slope() * 1000)
|
|
216 |
);
|
|
217 |
}
|
|
218 |
|
|
219 |
void set_size_policy(AdaptiveSizePolicy* v) { _size_policy = v; }
|
|
220 |
|
|
221 |
virtual GCPolicyCounters::Name kind() const {
|
|
222 |
return GCPolicyCounters::GCAdaptivePolicyCountersKind;
|
|
223 |
}
|
|
224 |
};
|