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