1 | /* |
2 | * Copyright (c) 2004, 2015, Oracle and/or its affiliates. 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 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/parallel/gcAdaptivePolicyCounters.hpp" |
27 | #include "memory/resourceArea.hpp" |
28 | |
29 | // This class keeps statistical information and computes the |
30 | // size of the heap. |
31 | |
32 | GCAdaptivePolicyCounters::GCAdaptivePolicyCounters(const char* name, |
33 | int collectors, |
34 | int generations, |
35 | AdaptiveSizePolicy* size_policy_arg) |
36 | : GCPolicyCounters(name, collectors, generations), |
37 | _size_policy(size_policy_arg) { |
38 | if (UsePerfData) { |
39 | EXCEPTION_MARK; |
40 | ResourceMark rm; |
41 | |
42 | const char* cname = PerfDataManager::counter_name(name_space(), "edenSize" ); |
43 | _eden_size_counter = PerfDataManager::create_variable(SUN_GC, cname, |
44 | PerfData::U_Bytes, _size_policy->calculated_eden_size_in_bytes(), CHECK); |
45 | |
46 | cname = PerfDataManager::counter_name(name_space(), "promoSize" ); |
47 | _promo_size_counter = PerfDataManager::create_variable(SUN_GC, cname, |
48 | PerfData::U_Bytes, size_policy()->calculated_promo_size_in_bytes(), |
49 | CHECK); |
50 | |
51 | cname = PerfDataManager::counter_name(name_space(), "youngCapacity" ); |
52 | size_t young_capacity_in_bytes = |
53 | _size_policy->calculated_eden_size_in_bytes() + |
54 | _size_policy->calculated_survivor_size_in_bytes(); |
55 | _young_capacity_counter = PerfDataManager::create_variable(SUN_GC, cname, |
56 | PerfData::U_Bytes, young_capacity_in_bytes, CHECK); |
57 | |
58 | cname = PerfDataManager::counter_name(name_space(), "avgSurvivedAvg" ); |
59 | _avg_survived_avg_counter = PerfDataManager::create_variable(SUN_GC, cname, |
60 | PerfData::U_Bytes, size_policy()->calculated_survivor_size_in_bytes(), |
61 | CHECK); |
62 | |
63 | cname = PerfDataManager::counter_name(name_space(), "avgSurvivedDev" ); |
64 | _avg_survived_dev_counter = PerfDataManager::create_variable(SUN_GC, cname, |
65 | PerfData::U_Bytes, (jlong) 0 , CHECK); |
66 | |
67 | cname = PerfDataManager::counter_name(name_space(), "avgSurvivedPaddedAvg" ); |
68 | _avg_survived_padded_avg_counter = |
69 | PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes, |
70 | size_policy()->calculated_survivor_size_in_bytes(), CHECK); |
71 | |
72 | cname = PerfDataManager::counter_name(name_space(), "avgMinorPauseTime" ); |
73 | _avg_minor_pause_counter = PerfDataManager::create_variable(SUN_GC, cname, |
74 | PerfData::U_Ticks, (jlong) _size_policy->_avg_minor_pause->average(), |
75 | CHECK); |
76 | |
77 | cname = PerfDataManager::counter_name(name_space(), "avgMinorIntervalTime" ); |
78 | _avg_minor_interval_counter = PerfDataManager::create_variable(SUN_GC, |
79 | cname, |
80 | PerfData::U_Ticks, |
81 | (jlong) _size_policy->_avg_minor_interval->average(), |
82 | CHECK); |
83 | |
84 | #ifdef NOT_PRODUCT |
85 | // This is a counter for the most recent minor pause time |
86 | // (the last sample, not the average). It is useful for |
87 | // verifying the average pause time but not worth putting |
88 | // into the product. |
89 | cname = PerfDataManager::counter_name(name_space(), "minorPauseTime" ); |
90 | _minor_pause_counter = PerfDataManager::create_variable(SUN_GC, cname, |
91 | PerfData::U_Ticks, (jlong) _size_policy->_avg_minor_pause->last_sample(), |
92 | CHECK); |
93 | #endif |
94 | |
95 | cname = PerfDataManager::counter_name(name_space(), "minorGcCost" ); |
96 | _minor_gc_cost_counter = PerfDataManager::create_variable(SUN_GC, |
97 | cname, |
98 | PerfData::U_Ticks, |
99 | (jlong) _size_policy->minor_gc_cost(), |
100 | CHECK); |
101 | |
102 | cname = PerfDataManager::counter_name(name_space(), "mutatorCost" ); |
103 | _mutator_cost_counter = PerfDataManager::create_variable(SUN_GC, cname, |
104 | PerfData::U_Ticks, (jlong) _size_policy->mutator_cost(), CHECK); |
105 | |
106 | cname = PerfDataManager::counter_name(name_space(), "survived" ); |
107 | _survived_counter = PerfDataManager::create_variable(SUN_GC, cname, |
108 | PerfData::U_Bytes, (jlong) 0, CHECK); |
109 | |
110 | cname = PerfDataManager::counter_name(name_space(), "promoted" ); |
111 | _promoted_counter = PerfDataManager::create_variable(SUN_GC, cname, |
112 | PerfData::U_Bytes, (jlong) 0, CHECK); |
113 | |
114 | cname = PerfDataManager::counter_name(name_space(), "avgYoungLive" ); |
115 | _avg_young_live_counter = PerfDataManager::create_variable(SUN_GC, cname, |
116 | PerfData::U_Bytes, (jlong) size_policy()->avg_young_live()->average(), |
117 | CHECK); |
118 | |
119 | cname = PerfDataManager::counter_name(name_space(), "avgOldLive" ); |
120 | _avg_old_live_counter = PerfDataManager::create_variable(SUN_GC, cname, |
121 | PerfData::U_Bytes, (jlong) size_policy()->avg_old_live()->average(), |
122 | CHECK); |
123 | |
124 | cname = PerfDataManager::counter_name(name_space(), "survivorOverflowed" ); |
125 | _survivor_overflowed_counter = PerfDataManager::create_variable(SUN_GC, cname, |
126 | PerfData::U_Events, (jlong)0, CHECK); |
127 | |
128 | cname = PerfDataManager::counter_name(name_space(), |
129 | "decrementTenuringThresholdForGcCost" ); |
130 | _decrement_tenuring_threshold_for_gc_cost_counter = |
131 | PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Events, |
132 | (jlong)0, CHECK); |
133 | |
134 | cname = PerfDataManager::counter_name(name_space(), |
135 | "incrementTenuringThresholdForGcCost" ); |
136 | _increment_tenuring_threshold_for_gc_cost_counter = |
137 | PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Events, |
138 | (jlong)0, CHECK); |
139 | |
140 | cname = PerfDataManager::counter_name(name_space(), |
141 | "decrementTenuringThresholdForSurvivorLimit" ); |
142 | _decrement_tenuring_threshold_for_survivor_limit_counter = |
143 | PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Events, |
144 | (jlong)0, CHECK); |
145 | cname = PerfDataManager::counter_name(name_space(), |
146 | "changeYoungGenForMinPauses" ); |
147 | _change_young_gen_for_min_pauses_counter = |
148 | PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Events, |
149 | (jlong)0, CHECK); |
150 | |
151 | cname = PerfDataManager::counter_name(name_space(), |
152 | "changeOldGenForMajPauses" ); |
153 | _change_old_gen_for_maj_pauses_counter = |
154 | PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Events, |
155 | (jlong)0, CHECK); |
156 | |
157 | cname = PerfDataManager::counter_name(name_space(), |
158 | "increaseOldGenForThroughput" ); |
159 | _change_old_gen_for_throughput_counter = |
160 | PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Events, |
161 | (jlong)0, CHECK); |
162 | |
163 | cname = PerfDataManager::counter_name(name_space(), |
164 | "increaseYoungGenForThroughput" ); |
165 | _change_young_gen_for_throughput_counter = |
166 | PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Events, |
167 | (jlong)0, CHECK); |
168 | |
169 | cname = PerfDataManager::counter_name(name_space(), |
170 | "decreaseForFootprint" ); |
171 | _decrease_for_footprint_counter = |
172 | PerfDataManager::create_variable(SUN_GC, cname, |
173 | PerfData::U_Events, (jlong)0, CHECK); |
174 | |
175 | cname = PerfDataManager::counter_name(name_space(), "decideAtFullGc" ); |
176 | _decide_at_full_gc_counter = PerfDataManager::create_variable(SUN_GC, cname, |
177 | PerfData::U_None, (jlong)0, CHECK); |
178 | |
179 | cname = PerfDataManager::counter_name(name_space(), "minorPauseYoungSlope" ); |
180 | _minor_pause_young_slope_counter = |
181 | PerfDataManager::create_variable(SUN_GC, cname, |
182 | PerfData::U_None, (jlong) 0, CHECK); |
183 | |
184 | cname = PerfDataManager::counter_name(name_space(), "majorCollectionSlope" ); |
185 | _major_collection_slope_counter = |
186 | PerfDataManager::create_variable(SUN_GC, cname, |
187 | PerfData::U_None, (jlong) 0, CHECK); |
188 | |
189 | cname = PerfDataManager::counter_name(name_space(), "minorCollectionSlope" ); |
190 | _minor_collection_slope_counter = |
191 | PerfDataManager::create_variable(SUN_GC, cname, |
192 | PerfData::U_None, (jlong) 0, CHECK); |
193 | } |
194 | } |
195 | |
196 | void GCAdaptivePolicyCounters::update_counters_from_policy() { |
197 | if (UsePerfData && (size_policy() != NULL)) { |
198 | update_avg_minor_pause_counter(); |
199 | update_avg_minor_interval_counter(); |
200 | #ifdef NOT_PRODUCT |
201 | update_minor_pause_counter(); |
202 | #endif |
203 | update_minor_gc_cost_counter(); |
204 | update_avg_young_live_counter(); |
205 | |
206 | update_survivor_size_counters(); |
207 | update_avg_survived_avg_counters(); |
208 | update_avg_survived_dev_counters(); |
209 | update_avg_survived_padded_avg_counters(); |
210 | |
211 | update_change_old_gen_for_throughput(); |
212 | update_change_young_gen_for_throughput(); |
213 | update_decrease_for_footprint(); |
214 | update_change_young_gen_for_min_pauses(); |
215 | update_change_old_gen_for_maj_pauses(); |
216 | |
217 | update_minor_pause_young_slope_counter(); |
218 | update_minor_collection_slope_counter(); |
219 | update_major_collection_slope_counter(); |
220 | } |
221 | } |
222 | |
223 | void GCAdaptivePolicyCounters::update_counters() { |
224 | if (UsePerfData) { |
225 | update_counters_from_policy(); |
226 | } |
227 | } |
228 | |