1 /* 2 * Copyright (c) 2003, 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 // PSGCAdaptivePolicyCounters is a holder class for performance counters 26 // that track the data and decisions for the ergonomics policy for the 27 // parallel scavenge collector. 28 29 class PSGCAdaptivePolicyCounters : public GCAdaptivePolicyCounters { 30 friend class VMStructs; 31 32 private: 33 // survivor space vs. tenuring threshold 34 PerfVariable* _old_promo_size; 35 PerfVariable* _old_eden_size; 36 PerfVariable* _avg_promoted_avg_counter; 37 PerfVariable* _avg_promoted_dev_counter; 38 PerfVariable* _avg_promoted_padded_avg_counter; 39 PerfVariable* _avg_pretenured_padded_avg; 40 41 // young gen vs. old gen sizing 42 PerfVariable* _avg_major_pause; 43 PerfVariable* _avg_major_interval; 44 PerfVariable* _live_space; 45 PerfVariable* _free_space; 46 PerfVariable* _avg_base_footprint; 47 PerfVariable* _gc_overhead_limit_exceeded_counter; 48 PerfVariable* _live_at_last_full_gc_counter; 49 PerfVariable* _old_capacity; 50 PerfVariable* _boundary_moved; 51 52 PerfVariable* _change_old_gen_for_min_pauses; 53 PerfVariable* _change_young_gen_for_maj_pauses_counter; 54 55 PerfVariable* _major_pause_old_slope; 56 PerfVariable* _minor_pause_old_slope; 57 PerfVariable* _major_pause_young_slope; 58 59 PerfVariable* _scavenge_skipped; 60 PerfVariable* _full_follows_scavenge; 61 62 // Use this time stamp if the gc time stamp is not available. 63 TimeStamp _counter_time_stamp; 64 65 protected: 66 PSAdaptiveSizePolicy* ps_size_policy() { 67 return (PSAdaptiveSizePolicy*)_size_policy; 68 } 69 70 public: 71 PSGCAdaptivePolicyCounters(const char* name, int collectors, int generations, 72 PSAdaptiveSizePolicy* size_policy); 73 inline void update_old_capacity(size_t size_in_bytes) { 74 _old_capacity->set_value(size_in_bytes); 75 } 76 inline void update_old_eden_size(size_t old_size) { 77 _old_eden_size->set_value(old_size); 78 } 79 inline void update_old_promo_size(size_t old_size) { 80 _old_promo_size->set_value(old_size); 81 } 82 inline void update_boundary_moved(int size_in_bytes) { 83 _boundary_moved->set_value(size_in_bytes); 84 } 85 inline void update_avg_promoted_avg() { 86 _avg_promoted_avg_counter->set_value( 87 (jlong)(ps_size_policy()->avg_promoted()->average()) 88 ); 89 } 90 inline void update_avg_promoted_dev() { 91 _avg_promoted_dev_counter->set_value( 92 (jlong)(ps_size_policy()->avg_promoted()->deviation()) 93 ); 94 } 95 inline void update_avg_promoted_padded_avg() { 96 _avg_promoted_padded_avg_counter->set_value( 97 (jlong)(ps_size_policy()->avg_promoted()->padded_average()) 98 ); 99 } 100 101 inline void update_avg_pretenured_padded_avg() { 102 _avg_pretenured_padded_avg->set_value( 103 (jlong)(ps_size_policy()->_avg_pretenured->padded_average()) 104 ); 105 } 106 inline void update_change_young_gen_for_maj_pauses() { 107 _change_young_gen_for_maj_pauses_counter->set_value( 108 ps_size_policy()->change_young_gen_for_maj_pauses()); 109 } 110 inline void update_change_old_gen_for_min_pauses() { 111 _change_old_gen_for_min_pauses->set_value( 112 ps_size_policy()->change_old_gen_for_min_pauses()); 113 } 114 115 // compute_generation_free_space() statistics 116 117 inline void update_avg_major_pause() { 118 _avg_major_pause->set_value( 119 (jlong)(ps_size_policy()->_avg_major_pause->average() * 1000.0) 120 ); 121 } 122 inline void update_avg_major_interval() { 123 _avg_major_interval->set_value( 124 (jlong)(ps_size_policy()->_avg_major_interval->average() * 1000.0) 125 ); 126 } 127 128 inline void update_major_gc_cost_counter() { 129 _major_gc_cost_counter->set_value( 130 (jlong)(ps_size_policy()->major_gc_cost() * 100.0) 131 ); 132 } 133 inline void update_mutator_cost_counter() { 134 _mutator_cost_counter->set_value( 135 (jlong)(ps_size_policy()->mutator_cost() * 100.0) 136 ); 137 } 138 139 inline void update_live_space() { 140 _live_space->set_value(ps_size_policy()->live_space()); 141 } 142 inline void update_free_space() { 143 _free_space->set_value(ps_size_policy()->free_space()); 144 } 145 146 inline void update_avg_base_footprint() { 147 _avg_base_footprint->set_value( 148 (jlong)(ps_size_policy()->avg_base_footprint()->average()) 149 ); 150 } 151 inline void update_avg_old_live() { 152 _avg_old_live_counter->set_value( 153 (jlong)(ps_size_policy()->avg_old_live()->average()) 154 ); 155 } 156 // Scale up all the slopes 157 inline void update_major_pause_old_slope() { 158 _major_pause_old_slope->set_value( 159 (jlong)(ps_size_policy()->major_pause_old_slope() * 1000) 160 ); 161 } 162 inline void update_minor_pause_old_slope() { 163 _minor_pause_old_slope->set_value( 164 (jlong)(ps_size_policy()->minor_pause_old_slope() * 1000) 165 ); 166 } 167 inline void update_major_pause_young_slope() { 168 _major_pause_young_slope->set_value( 169 (jlong)(ps_size_policy()->major_pause_young_slope() * 1000) 170 ); 171 } 172 inline void update_gc_overhead_limit_exceeded_counter() { 173 _gc_overhead_limit_exceeded_counter->set_value( 174 (jlong) ps_size_policy()->gc_overhead_limit_exceeded()); 175 } 176 inline void update_live_at_last_full_gc_counter() { 177 _live_at_last_full_gc_counter->set_value( 178 (jlong)(ps_size_policy()->live_at_last_full_gc())); 179 } 180 181 inline void update_scavenge_skipped(int cause) { 182 _scavenge_skipped->set_value(cause); 183 } 184 185 inline void update_full_follows_scavenge(int event) { 186 _full_follows_scavenge->set_value(event); 187 } 188 189 // Update all the counters that can be updated from the size policy. 190 // This should be called after all policy changes have been made 191 // and reflected internall in the size policy. 192 void update_counters_from_policy(); 193 194 // Update counters that can be updated from fields internal to the 195 // counter or from globals. This is distinguished from counters 196 // that are updated via input parameters. 197 void update_counters(); 198 199 virtual GCPolicyCounters::Name kind() const { 200 return GCPolicyCounters::PSGCAdaptivePolicyCountersKind; 201 } 202 };