1 /* 2 * Copyright (c) 2004, 2005, 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 // CMSGCAdaptivePolicyCounters is a holder class for performance counters 26 // that track the data and decisions for the ergonomics policy for the 27 // concurrent mark sweep collector 28 29 class CMSGCAdaptivePolicyCounters : public GCAdaptivePolicyCounters { 30 friend class VMStructs; 31 32 private: 33 34 // Capacity of tenured generation recorded at the end of 35 // any collection. 36 PerfVariable* _cms_capacity_counter; // Make this common with PS _old_capacity 37 38 // Average stop-the-world pause time for both initial and 39 // remark pauses sampled at the end of the checkpointRootsFinalWork. 40 PerfVariable* _avg_cms_STW_time_counter; 41 // Average stop-the-world (STW) GC cost for the STW pause time 42 // _avg_cms_STW_time_counter. 43 PerfVariable* _avg_cms_STW_gc_cost_counter; 44 45 #ifdef NOT_PRODUCT 46 // These are useful to see how the most recent values of these 47 // counters compare to their respective averages but 48 // do not control behavior. 49 PerfVariable* _initial_pause_counter; 50 PerfVariable* _remark_pause_counter; 51 #endif 52 53 // Average of the initial marking pause for a concurrent collection. 54 PerfVariable* _avg_initial_pause_counter; 55 // Average of the remark pause for a concurrent collection. 56 PerfVariable* _avg_remark_pause_counter; 57 58 // Average for the sum of all the concurrent times per collection. 59 PerfVariable* _avg_concurrent_time_counter; 60 // Average for the time between the most recent end of a 61 // concurrent collection and the beginning of the next 62 // concurrent collection. 63 PerfVariable* _avg_concurrent_interval_counter; 64 // Average of the concurrent GC costs based on _avg_concurrent_time_counter 65 // and _avg_concurrent_interval_counter. 66 PerfVariable* _avg_concurrent_gc_cost_counter; 67 68 // Average of the free space in the tenured generation at the 69 // end of the sweep of the tenured generation. 70 PerfVariable* _avg_cms_free_counter; 71 // Average of the free space in the tenured generation at the 72 // start of the sweep of the tenured generation. 73 PerfVariable* _avg_cms_free_at_sweep_counter; 74 // Average of the free space in the tenured generation at the 75 // after any resizing of the tenured generation at the end 76 // of a collection of the tenured generation. 77 PerfVariable* _avg_cms_promo_counter; 78 79 // Average of the mark-sweep-compact (MSC) pause time for a collection 80 // of the tenured generation. 81 PerfVariable* _avg_msc_pause_counter; 82 // Average for the time between the most recent end of a 83 // MSC collection and the beginning of the next 84 // MSC collection. 85 PerfVariable* _avg_msc_interval_counter; 86 // Average for the GC cost of a MSC collection based on 87 // _avg_msc_pause_counter and _avg_msc_interval_counter. 88 PerfVariable* _msc_gc_cost_counter; 89 90 // Average of the mark-sweep (MS) pause time for a collection 91 // of the tenured generation. 92 PerfVariable* _avg_ms_pause_counter; 93 // Average for the time between the most recent end of a 94 // MS collection and the beginning of the next 95 // MS collection. 96 PerfVariable* _avg_ms_interval_counter; 97 // Average for the GC cost of a MS collection based on 98 // _avg_ms_pause_counter and _avg_ms_interval_counter. 99 PerfVariable* _ms_gc_cost_counter; 100 101 // Average of the bytes promoted per minor collection. 102 PerfVariable* _promoted_avg_counter; 103 // Average of the deviation of the promoted average 104 PerfVariable* _promoted_avg_dev_counter; 105 // Padded average of the bytes promoted per minor colleciton 106 PerfVariable* _promoted_padded_avg_counter; 107 108 // See description of the _change_young_gen_for_maj_pauses 109 // variable recently in cmsAdaptiveSizePolicy.hpp. 110 PerfVariable* _change_young_gen_for_maj_pauses_counter; 111 112 // See descriptions of _remark_pause_old_slope, _initial_pause_old_slope, 113 // etc. variables recently in cmsAdaptiveSizePolicy.hpp. 114 PerfVariable* _remark_pause_old_slope_counter; 115 PerfVariable* _initial_pause_old_slope_counter; 116 PerfVariable* _remark_pause_young_slope_counter; 117 PerfVariable* _initial_pause_young_slope_counter; 118 119 CMSAdaptiveSizePolicy* cms_size_policy() { 120 assert(_size_policy->kind() == 121 AdaptiveSizePolicy::_gc_cms_adaptive_size_policy, 122 "Wrong size policy"); 123 return (CMSAdaptiveSizePolicy*)_size_policy; 124 } 125 126 inline void update_avg_cms_STW_time_counter() { 127 _avg_cms_STW_time_counter->set_value( 128 (jlong) (cms_size_policy()->avg_cms_STW_time()->average() * 129 (double) MILLIUNITS)); 130 } 131 132 inline void update_avg_cms_STW_gc_cost_counter() { 133 _avg_cms_STW_gc_cost_counter->set_value( 134 (jlong) (cms_size_policy()->avg_cms_STW_gc_cost()->average() * 100.0)); 135 } 136 137 inline void update_avg_initial_pause_counter() { 138 _avg_initial_pause_counter->set_value( 139 (jlong) (cms_size_policy()->avg_initial_pause()->average() * 140 (double) MILLIUNITS)); 141 } 142 #ifdef NOT_PRODUCT 143 inline void update_avg_remark_pause_counter() { 144 _avg_remark_pause_counter->set_value( 145 (jlong) (cms_size_policy()-> avg_remark_pause()->average() * 146 (double) MILLIUNITS)); 147 } 148 149 inline void update_initial_pause_counter() { 150 _initial_pause_counter->set_value( 151 (jlong) (cms_size_policy()->avg_initial_pause()->average() * 152 (double) MILLIUNITS)); 153 } 154 #endif 155 inline void update_remark_pause_counter() { 156 _remark_pause_counter->set_value( 157 (jlong) (cms_size_policy()-> avg_remark_pause()->last_sample() * 158 (double) MILLIUNITS)); 159 } 160 161 inline void update_avg_concurrent_time_counter() { 162 _avg_concurrent_time_counter->set_value( 163 (jlong) (cms_size_policy()->avg_concurrent_time()->last_sample() * 164 (double) MILLIUNITS)); 165 } 166 167 inline void update_avg_concurrent_interval_counter() { 168 _avg_concurrent_interval_counter->set_value( 169 (jlong) (cms_size_policy()->avg_concurrent_interval()->average() * 170 (double) MILLIUNITS)); 171 } 172 173 inline void update_avg_concurrent_gc_cost_counter() { 174 _avg_concurrent_gc_cost_counter->set_value( 175 (jlong) (cms_size_policy()->avg_concurrent_gc_cost()->average() * 100.0)); 176 } 177 178 inline void update_avg_cms_free_counter() { 179 _avg_cms_free_counter->set_value( 180 (jlong) cms_size_policy()->avg_cms_free()->average()); 181 } 182 183 inline void update_avg_cms_free_at_sweep_counter() { 184 _avg_cms_free_at_sweep_counter->set_value( 185 (jlong) cms_size_policy()->avg_cms_free_at_sweep()->average()); 186 } 187 188 inline void update_avg_cms_promo_counter() { 189 _avg_cms_promo_counter->set_value( 190 (jlong) cms_size_policy()->avg_cms_promo()->average()); 191 } 192 193 inline void update_avg_old_live_counter() { 194 _avg_old_live_counter->set_value( 195 (jlong)(cms_size_policy()->avg_old_live()->average()) 196 ); 197 } 198 199 inline void update_avg_msc_pause_counter() { 200 _avg_msc_pause_counter->set_value( 201 (jlong) (cms_size_policy()->avg_msc_pause()->average() * 202 (double) MILLIUNITS)); 203 } 204 205 inline void update_avg_msc_interval_counter() { 206 _avg_msc_interval_counter->set_value( 207 (jlong) (cms_size_policy()->avg_msc_interval()->average() * 208 (double) MILLIUNITS)); 209 } 210 211 inline void update_msc_gc_cost_counter() { 212 _msc_gc_cost_counter->set_value( 213 (jlong) (cms_size_policy()->avg_msc_gc_cost()->average() * 100.0)); 214 } 215 216 inline void update_avg_ms_pause_counter() { 217 _avg_ms_pause_counter->set_value( 218 (jlong) (cms_size_policy()->avg_ms_pause()->average() * 219 (double) MILLIUNITS)); 220 } 221 222 inline void update_avg_ms_interval_counter() { 223 _avg_ms_interval_counter->set_value( 224 (jlong) (cms_size_policy()->avg_ms_interval()->average() * 225 (double) MILLIUNITS)); 226 } 227 228 inline void update_ms_gc_cost_counter() { 229 _ms_gc_cost_counter->set_value( 230 (jlong) (cms_size_policy()->avg_ms_gc_cost()->average() * 100.0)); 231 } 232 233 inline void update_major_gc_cost_counter() { 234 _major_gc_cost_counter->set_value( 235 (jlong)(cms_size_policy()->cms_gc_cost() * 100.0) 236 ); 237 } 238 inline void update_mutator_cost_counter() { 239 _mutator_cost_counter->set_value( 240 (jlong)(cms_size_policy()->mutator_cost() * 100.0) 241 ); 242 } 243 244 inline void update_avg_promoted_avg(CMSGCStats* gc_stats) { 245 _promoted_avg_counter->set_value( 246 (jlong)(gc_stats->avg_promoted()->average()) 247 ); 248 } 249 inline void update_avg_promoted_dev(CMSGCStats* gc_stats) { 250 _promoted_avg_dev_counter->set_value( 251 (jlong)(gc_stats->avg_promoted()->deviation()) 252 ); 253 } 254 inline void update_avg_promoted_padded_avg(CMSGCStats* gc_stats) { 255 _promoted_padded_avg_counter->set_value( 256 (jlong)(gc_stats->avg_promoted()->padded_average()) 257 ); 258 } 259 inline void update_remark_pause_old_slope_counter() { 260 _remark_pause_old_slope_counter->set_value( 261 (jlong)(cms_size_policy()->remark_pause_old_slope() * 1000) 262 ); 263 } 264 inline void update_initial_pause_old_slope_counter() { 265 _initial_pause_old_slope_counter->set_value( 266 (jlong)(cms_size_policy()->initial_pause_old_slope() * 1000) 267 ); 268 } 269 inline void update_remark_pause_young_slope_counter() { 270 _remark_pause_young_slope_counter->set_value( 271 (jlong)(cms_size_policy()->remark_pause_young_slope() * 1000) 272 ); 273 } 274 inline void update_initial_pause_young_slope_counter() { 275 _initial_pause_young_slope_counter->set_value( 276 (jlong)(cms_size_policy()->initial_pause_young_slope() * 1000) 277 ); 278 } 279 inline void update_change_young_gen_for_maj_pauses() { 280 _change_young_gen_for_maj_pauses_counter->set_value( 281 cms_size_policy()->change_young_gen_for_maj_pauses()); 282 } 283 284 public: 285 CMSGCAdaptivePolicyCounters(const char* name, int collectors, int generations, 286 AdaptiveSizePolicy* size_policy); 287 288 // update counters 289 void update_counters(); 290 void update_counters(CMSGCStats* gc_stats); 291 void update_counters_from_policy(); 292 293 inline void update_cms_capacity_counter(size_t size_in_bytes) { 294 _cms_capacity_counter->set_value(size_in_bytes); 295 } 296 297 virtual GCPolicyCounters::Name kind() const { 298 return GCPolicyCounters::CMSGCAdaptivePolicyCountersKind; 299 } 300 };