1/*
2 * Copyright (c) 2003, 2019, 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/psGCAdaptivePolicyCounters.hpp"
27#include "memory/resourceArea.hpp"
28#include "runtime/arguments.hpp"
29
30
31
32PSGCAdaptivePolicyCounters::PSGCAdaptivePolicyCounters(const char* name_arg,
33 int collectors,
34 int generations,
35 PSAdaptiveSizePolicy* size_policy_arg)
36 : GCAdaptivePolicyCounters(name_arg,
37 collectors,
38 generations,
39 size_policy_arg) {
40 if (UsePerfData) {
41 EXCEPTION_MARK;
42 ResourceMark rm;
43
44 const char* cname;
45
46 cname = PerfDataManager::counter_name(name_space(), "oldPromoSize");
47 _old_promo_size = PerfDataManager::create_variable(SUN_GC, cname,
48 PerfData::U_Bytes, ps_size_policy()->calculated_promo_size_in_bytes(), CHECK);
49
50 cname = PerfDataManager::counter_name(name_space(), "oldEdenSize");
51 _old_eden_size = PerfDataManager::create_variable(SUN_GC, cname,
52 PerfData::U_Bytes, ps_size_policy()->calculated_eden_size_in_bytes(), CHECK);
53
54 cname = PerfDataManager::counter_name(name_space(), "oldCapacity");
55 _old_capacity = PerfDataManager::create_variable(SUN_GC, cname,
56 PerfData::U_Bytes, (jlong) InitialHeapSize, CHECK);
57
58 cname = PerfDataManager::counter_name(name_space(), "boundaryMoved");
59 _boundary_moved = PerfDataManager::create_variable(SUN_GC, cname,
60 PerfData::U_Bytes, (jlong) 0, CHECK);
61
62 cname = PerfDataManager::counter_name(name_space(), "avgPromotedAvg");
63 _avg_promoted_avg_counter =
64 PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes,
65 ps_size_policy()->calculated_promo_size_in_bytes(), CHECK);
66
67 cname = PerfDataManager::counter_name(name_space(), "avgPromotedDev");
68 _avg_promoted_dev_counter =
69 PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes,
70 (jlong) 0 , CHECK);
71
72 cname = PerfDataManager::counter_name(name_space(), "avgPromotedPaddedAvg");
73 _avg_promoted_padded_avg_counter =
74 PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes,
75 ps_size_policy()->calculated_promo_size_in_bytes(), CHECK);
76
77 cname = PerfDataManager::counter_name(name_space(),
78 "avgPretenuredPaddedAvg");
79 _avg_pretenured_padded_avg =
80 PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes,
81 (jlong) 0, CHECK);
82
83
84 cname = PerfDataManager::counter_name(name_space(),
85 "changeYoungGenForMajPauses");
86 _change_young_gen_for_maj_pauses_counter =
87 PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Events,
88 (jlong)0, CHECK);
89
90 cname = PerfDataManager::counter_name(name_space(),
91 "changeOldGenForMinPauses");
92 _change_old_gen_for_min_pauses =
93 PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Events,
94 (jlong)0, CHECK);
95
96
97 cname = PerfDataManager::counter_name(name_space(), "avgMajorPauseTime");
98 _avg_major_pause = PerfDataManager::create_variable(SUN_GC, cname,
99 PerfData::U_Ticks, (jlong) ps_size_policy()->_avg_major_pause->average(), CHECK);
100
101 cname = PerfDataManager::counter_name(name_space(), "avgMajorIntervalTime");
102 _avg_major_interval = PerfDataManager::create_variable(SUN_GC, cname,
103 PerfData::U_Ticks, (jlong) ps_size_policy()->_avg_major_interval->average(), CHECK);
104
105 cname = PerfDataManager::counter_name(name_space(), "majorGcCost");
106 _major_gc_cost_counter = PerfDataManager::create_variable(SUN_GC, cname,
107 PerfData::U_Ticks, (jlong) ps_size_policy()->major_gc_cost(), CHECK);
108
109 cname = PerfDataManager::counter_name(name_space(), "liveSpace");
110 _live_space = PerfDataManager::create_variable(SUN_GC, cname,
111 PerfData::U_Bytes, ps_size_policy()->live_space(), CHECK);
112
113 cname = PerfDataManager::counter_name(name_space(), "freeSpace");
114 _free_space = PerfDataManager::create_variable(SUN_GC, cname,
115 PerfData::U_Bytes, ps_size_policy()->free_space(), CHECK);
116
117 cname = PerfDataManager::counter_name(name_space(), "avgBaseFootprint");
118 _avg_base_footprint = PerfDataManager::create_variable(SUN_GC, cname,
119 PerfData::U_Bytes, (jlong) ps_size_policy()->avg_base_footprint()->average(), CHECK);
120
121 cname = PerfDataManager::counter_name(name_space(), "liveAtLastFullGc");
122 _live_at_last_full_gc_counter =
123 PerfDataManager::create_variable(SUN_GC, cname,
124 PerfData::U_Bytes, ps_size_policy()->live_at_last_full_gc(), CHECK);
125
126 cname = PerfDataManager::counter_name(name_space(), "majorPauseOldSlope");
127 _major_pause_old_slope = PerfDataManager::create_variable(SUN_GC, cname,
128 PerfData::U_None, (jlong) 0, CHECK);
129
130 cname = PerfDataManager::counter_name(name_space(), "minorPauseOldSlope");
131 _minor_pause_old_slope = PerfDataManager::create_variable(SUN_GC, cname,
132 PerfData::U_None, (jlong) 0, CHECK);
133
134 cname = PerfDataManager::counter_name(name_space(), "majorPauseYoungSlope");
135 _major_pause_young_slope = PerfDataManager::create_variable(SUN_GC, cname,
136 PerfData::U_None, (jlong) 0, CHECK);
137
138 cname = PerfDataManager::counter_name(name_space(), "scavengeSkipped");
139 _scavenge_skipped = PerfDataManager::create_variable(SUN_GC, cname,
140 PerfData::U_Bytes, (jlong) 0, CHECK);
141
142 cname = PerfDataManager::counter_name(name_space(), "fullFollowsScavenge");
143 _full_follows_scavenge = PerfDataManager::create_variable(SUN_GC, cname,
144 PerfData::U_Bytes, (jlong) 0, CHECK);
145
146 _counter_time_stamp.update();
147 }
148
149 assert(size_policy()->is_gc_ps_adaptive_size_policy(),
150 "Wrong type of size policy");
151}
152
153void PSGCAdaptivePolicyCounters::update_counters_from_policy() {
154 if (UsePerfData) {
155 GCAdaptivePolicyCounters::update_counters_from_policy();
156 update_eden_size();
157 update_promo_size();
158 update_avg_old_live();
159 update_survivor_size_counters();
160 update_avg_promoted_avg();
161 update_avg_promoted_dev();
162 update_avg_promoted_padded_avg();
163 update_avg_pretenured_padded_avg();
164
165 update_avg_major_pause();
166 update_avg_major_interval();
167 update_minor_gc_cost_counter();
168 update_major_gc_cost_counter();
169 update_mutator_cost_counter();
170 update_decrement_tenuring_threshold_for_gc_cost();
171 update_increment_tenuring_threshold_for_gc_cost();
172 update_decrement_tenuring_threshold_for_survivor_limit();
173 update_live_space();
174 update_free_space();
175 update_avg_base_footprint();
176
177 update_change_old_gen_for_maj_pauses();
178 update_change_young_gen_for_maj_pauses();
179 update_change_old_gen_for_min_pauses();
180
181 update_change_old_gen_for_throughput();
182 update_change_young_gen_for_throughput();
183
184 update_decrease_for_footprint();
185 update_decide_at_full_gc_counter();
186
187 update_major_pause_old_slope();
188 update_minor_pause_old_slope();
189 update_major_pause_young_slope();
190 update_minor_collection_slope_counter();
191 update_gc_overhead_limit_exceeded_counter();
192 update_live_at_last_full_gc_counter();
193 }
194}
195
196void PSGCAdaptivePolicyCounters::update_counters() {
197 if (UsePerfData) {
198 update_counters_from_policy();
199 }
200}
201