Thu, 19 Jun 2014 13:31:14 +0200
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
Reviewed-by: jwilhelm, ehelin, tschatzl
duke@435 | 1 | /* |
mikael@4153 | 2 | * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #ifndef SHARE_VM_GC_IMPLEMENTATION_SHARED_ADAPTIVESIZEPOLICY_HPP |
stefank@2314 | 26 | #define SHARE_VM_GC_IMPLEMENTATION_SHARED_ADAPTIVESIZEPOLICY_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "gc_implementation/shared/gcUtil.hpp" |
stefank@2314 | 29 | #include "gc_interface/collectedHeap.hpp" |
stefank@2314 | 30 | #include "gc_interface/gcCause.hpp" |
stefank@2314 | 31 | #include "memory/allocation.hpp" |
stefank@2314 | 32 | #include "memory/universe.hpp" |
stefank@2314 | 33 | |
duke@435 | 34 | // This class keeps statistical information and computes the |
duke@435 | 35 | // size of the heap. |
duke@435 | 36 | |
duke@435 | 37 | // Forward decls |
duke@435 | 38 | class elapsedTimer; |
jmasa@1822 | 39 | class CollectorPolicy; |
duke@435 | 40 | |
zgu@3900 | 41 | class AdaptiveSizePolicy : public CHeapObj<mtGC> { |
duke@435 | 42 | friend class GCAdaptivePolicyCounters; |
duke@435 | 43 | friend class PSGCAdaptivePolicyCounters; |
duke@435 | 44 | friend class CMSGCAdaptivePolicyCounters; |
duke@435 | 45 | protected: |
duke@435 | 46 | |
duke@435 | 47 | enum GCPolicyKind { |
duke@435 | 48 | _gc_adaptive_size_policy, |
duke@435 | 49 | _gc_ps_adaptive_size_policy, |
duke@435 | 50 | _gc_cms_adaptive_size_policy |
duke@435 | 51 | }; |
duke@435 | 52 | virtual GCPolicyKind kind() const { return _gc_adaptive_size_policy; } |
duke@435 | 53 | |
duke@435 | 54 | enum SizePolicyTrueValues { |
duke@435 | 55 | decrease_old_gen_for_throughput_true = -7, |
duke@435 | 56 | decrease_young_gen_for_througput_true = -6, |
duke@435 | 57 | |
duke@435 | 58 | increase_old_gen_for_min_pauses_true = -5, |
duke@435 | 59 | decrease_old_gen_for_min_pauses_true = -4, |
duke@435 | 60 | decrease_young_gen_for_maj_pauses_true = -3, |
duke@435 | 61 | increase_young_gen_for_min_pauses_true = -2, |
duke@435 | 62 | increase_old_gen_for_maj_pauses_true = -1, |
duke@435 | 63 | |
duke@435 | 64 | decrease_young_gen_for_min_pauses_true = 1, |
duke@435 | 65 | decrease_old_gen_for_maj_pauses_true = 2, |
duke@435 | 66 | increase_young_gen_for_maj_pauses_true = 3, |
duke@435 | 67 | |
duke@435 | 68 | increase_old_gen_for_throughput_true = 4, |
duke@435 | 69 | increase_young_gen_for_througput_true = 5, |
duke@435 | 70 | |
duke@435 | 71 | decrease_young_gen_for_footprint_true = 6, |
duke@435 | 72 | decrease_old_gen_for_footprint_true = 7, |
duke@435 | 73 | decide_at_full_gc_true = 8 |
duke@435 | 74 | }; |
duke@435 | 75 | |
duke@435 | 76 | // Goal for the fraction of the total time during which application |
duke@435 | 77 | // threads run. |
duke@435 | 78 | const double _throughput_goal; |
duke@435 | 79 | |
duke@435 | 80 | // Last calculated sizes, in bytes, and aligned |
duke@435 | 81 | size_t _eden_size; // calculated eden free space in bytes |
duke@435 | 82 | size_t _promo_size; // calculated cms gen free space in bytes |
duke@435 | 83 | |
duke@435 | 84 | size_t _survivor_size; // calculated survivor size in bytes |
duke@435 | 85 | |
duke@435 | 86 | // This is a hint for the heap: we've detected that gc times |
duke@435 | 87 | // are taking longer than GCTimeLimit allows. |
jmasa@1822 | 88 | bool _gc_overhead_limit_exceeded; |
jmasa@1822 | 89 | // Use for diagnostics only. If UseGCOverheadLimit is false, |
duke@435 | 90 | // this variable is still set. |
jmasa@1822 | 91 | bool _print_gc_overhead_limit_would_be_exceeded; |
duke@435 | 92 | // Count of consecutive GC that have exceeded the |
duke@435 | 93 | // GC time limit criterion. |
jmasa@1822 | 94 | uint _gc_overhead_limit_count; |
jmasa@1822 | 95 | // This flag signals that GCTimeLimit is being exceeded |
jmasa@1822 | 96 | // but may not have done so for the required number of consequetive |
jmasa@1822 | 97 | // collections. |
duke@435 | 98 | |
duke@435 | 99 | // Minor collection timers used to determine both |
duke@435 | 100 | // pause and interval times for collections. |
duke@435 | 101 | static elapsedTimer _minor_timer; |
duke@435 | 102 | |
duke@435 | 103 | // Major collection timers, used to determine both |
duke@435 | 104 | // pause and interval times for collections |
duke@435 | 105 | static elapsedTimer _major_timer; |
duke@435 | 106 | |
duke@435 | 107 | // Time statistics |
duke@435 | 108 | AdaptivePaddedAverage* _avg_minor_pause; |
duke@435 | 109 | AdaptiveWeightedAverage* _avg_minor_interval; |
duke@435 | 110 | AdaptiveWeightedAverage* _avg_minor_gc_cost; |
duke@435 | 111 | |
duke@435 | 112 | AdaptiveWeightedAverage* _avg_major_interval; |
duke@435 | 113 | AdaptiveWeightedAverage* _avg_major_gc_cost; |
duke@435 | 114 | |
duke@435 | 115 | // Footprint statistics |
duke@435 | 116 | AdaptiveWeightedAverage* _avg_young_live; |
duke@435 | 117 | AdaptiveWeightedAverage* _avg_eden_live; |
duke@435 | 118 | AdaptiveWeightedAverage* _avg_old_live; |
duke@435 | 119 | |
duke@435 | 120 | // Statistics for survivor space calculation for young generation |
duke@435 | 121 | AdaptivePaddedAverage* _avg_survived; |
duke@435 | 122 | |
duke@435 | 123 | // Objects that have been directly allocated in the old generation. |
duke@435 | 124 | AdaptivePaddedNoZeroDevAverage* _avg_pretenured; |
duke@435 | 125 | |
duke@435 | 126 | // Variable for estimating the major and minor pause times. |
duke@435 | 127 | // These variables represent linear least-squares fits of |
duke@435 | 128 | // the data. |
duke@435 | 129 | // minor pause time vs. old gen size |
duke@435 | 130 | LinearLeastSquareFit* _minor_pause_old_estimator; |
duke@435 | 131 | // minor pause time vs. young gen size |
duke@435 | 132 | LinearLeastSquareFit* _minor_pause_young_estimator; |
duke@435 | 133 | |
duke@435 | 134 | // Variables for estimating the major and minor collection costs |
duke@435 | 135 | // minor collection time vs. young gen size |
duke@435 | 136 | LinearLeastSquareFit* _minor_collection_estimator; |
duke@435 | 137 | // major collection time vs. cms gen size |
duke@435 | 138 | LinearLeastSquareFit* _major_collection_estimator; |
duke@435 | 139 | |
duke@435 | 140 | // These record the most recent collection times. They |
duke@435 | 141 | // are available as an alternative to using the averages |
duke@435 | 142 | // for making ergonomic decisions. |
duke@435 | 143 | double _latest_minor_mutator_interval_seconds; |
duke@435 | 144 | |
duke@435 | 145 | // Allowed difference between major and minor gc times, used |
duke@435 | 146 | // for computing tenuring_threshold. |
duke@435 | 147 | const double _threshold_tolerance_percent; |
duke@435 | 148 | |
duke@435 | 149 | const double _gc_pause_goal_sec; // goal for maximum gc pause |
duke@435 | 150 | |
duke@435 | 151 | // Flag indicating that the adaptive policy is ready to use |
duke@435 | 152 | bool _young_gen_policy_is_ready; |
duke@435 | 153 | |
duke@435 | 154 | // decrease/increase the young generation for minor pause time |
duke@435 | 155 | int _change_young_gen_for_min_pauses; |
duke@435 | 156 | |
duke@435 | 157 | // decrease/increase the old generation for major pause time |
duke@435 | 158 | int _change_old_gen_for_maj_pauses; |
duke@435 | 159 | |
duke@435 | 160 | // change old geneneration for throughput |
duke@435 | 161 | int _change_old_gen_for_throughput; |
duke@435 | 162 | |
duke@435 | 163 | // change young generation for throughput |
duke@435 | 164 | int _change_young_gen_for_throughput; |
duke@435 | 165 | |
duke@435 | 166 | // Flag indicating that the policy would |
duke@435 | 167 | // increase the tenuring threshold because of the total major gc cost |
duke@435 | 168 | // is greater than the total minor gc cost |
duke@435 | 169 | bool _increment_tenuring_threshold_for_gc_cost; |
duke@435 | 170 | // decrease the tenuring threshold because of the the total minor gc |
duke@435 | 171 | // cost is greater than the total major gc cost |
duke@435 | 172 | bool _decrement_tenuring_threshold_for_gc_cost; |
duke@435 | 173 | // decrease due to survivor size limit |
duke@435 | 174 | bool _decrement_tenuring_threshold_for_survivor_limit; |
duke@435 | 175 | |
duke@435 | 176 | // decrease generation sizes for footprint |
duke@435 | 177 | int _decrease_for_footprint; |
duke@435 | 178 | |
duke@435 | 179 | // Set if the ergonomic decisions were made at a full GC. |
duke@435 | 180 | int _decide_at_full_gc; |
duke@435 | 181 | |
duke@435 | 182 | // Changing the generation sizing depends on the data that is |
duke@435 | 183 | // gathered about the effects of changes on the pause times and |
duke@435 | 184 | // throughput. These variable count the number of data points |
duke@435 | 185 | // gathered. The policy may use these counters as a threshhold |
duke@435 | 186 | // for reliable data. |
duke@435 | 187 | julong _young_gen_change_for_minor_throughput; |
duke@435 | 188 | julong _old_gen_change_for_major_throughput; |
duke@435 | 189 | |
jmasa@3294 | 190 | static const uint GCWorkersPerJavaThread = 2; |
jmasa@3294 | 191 | |
duke@435 | 192 | // Accessors |
duke@435 | 193 | |
duke@435 | 194 | double gc_pause_goal_sec() const { return _gc_pause_goal_sec; } |
duke@435 | 195 | // The value returned is unitless: it's the proportion of time |
duke@435 | 196 | // spent in a particular collection type. |
duke@435 | 197 | // An interval time will be 0.0 if a collection type hasn't occurred yet. |
duke@435 | 198 | // The 1.4.2 implementation put a floor on the values of major_gc_cost |
duke@435 | 199 | // and minor_gc_cost. This was useful because of the way major_gc_cost |
duke@435 | 200 | // and minor_gc_cost was used in calculating the sizes of the generations. |
duke@435 | 201 | // Do not use a floor in this implementation because any finite value |
duke@435 | 202 | // will put a limit on the throughput that can be achieved and any |
duke@435 | 203 | // throughput goal above that limit will drive the generations sizes |
duke@435 | 204 | // to extremes. |
duke@435 | 205 | double major_gc_cost() const { |
duke@435 | 206 | return MAX2(0.0F, _avg_major_gc_cost->average()); |
duke@435 | 207 | } |
duke@435 | 208 | |
duke@435 | 209 | // The value returned is unitless: it's the proportion of time |
duke@435 | 210 | // spent in a particular collection type. |
duke@435 | 211 | // An interval time will be 0.0 if a collection type hasn't occurred yet. |
duke@435 | 212 | // The 1.4.2 implementation put a floor on the values of major_gc_cost |
duke@435 | 213 | // and minor_gc_cost. This was useful because of the way major_gc_cost |
duke@435 | 214 | // and minor_gc_cost was used in calculating the sizes of the generations. |
duke@435 | 215 | // Do not use a floor in this implementation because any finite value |
duke@435 | 216 | // will put a limit on the throughput that can be achieved and any |
duke@435 | 217 | // throughput goal above that limit will drive the generations sizes |
duke@435 | 218 | // to extremes. |
duke@435 | 219 | |
duke@435 | 220 | double minor_gc_cost() const { |
duke@435 | 221 | return MAX2(0.0F, _avg_minor_gc_cost->average()); |
duke@435 | 222 | } |
duke@435 | 223 | |
duke@435 | 224 | // Because we're dealing with averages, gc_cost() can be |
duke@435 | 225 | // larger than 1.0 if just the sum of the minor cost the |
duke@435 | 226 | // the major cost is used. Worse than that is the |
duke@435 | 227 | // fact that the minor cost and the major cost each |
duke@435 | 228 | // tend toward 1.0 in the extreme of high gc costs. |
duke@435 | 229 | // Limit the value of gc_cost to 1.0 so that the mutator |
duke@435 | 230 | // cost stays non-negative. |
duke@435 | 231 | virtual double gc_cost() const { |
duke@435 | 232 | double result = MIN2(1.0, minor_gc_cost() + major_gc_cost()); |
duke@435 | 233 | assert(result >= 0.0, "Both minor and major costs are non-negative"); |
duke@435 | 234 | return result; |
duke@435 | 235 | } |
duke@435 | 236 | |
duke@435 | 237 | // Elapsed time since the last major collection. |
duke@435 | 238 | virtual double time_since_major_gc() const; |
duke@435 | 239 | |
duke@435 | 240 | // Average interval between major collections to be used |
duke@435 | 241 | // in calculating the decaying major gc cost. An overestimate |
duke@435 | 242 | // of this time would be a conservative estimate because |
duke@435 | 243 | // this time is used to decide if the major GC cost |
duke@435 | 244 | // should be decayed (i.e., if the time since the last |
duke@435 | 245 | // major gc is long compared to the time returned here, |
duke@435 | 246 | // then the major GC cost will be decayed). See the |
duke@435 | 247 | // implementations for the specifics. |
duke@435 | 248 | virtual double major_gc_interval_average_for_decay() const { |
duke@435 | 249 | return _avg_major_interval->average(); |
duke@435 | 250 | } |
duke@435 | 251 | |
duke@435 | 252 | // Return the cost of the GC where the major gc cost |
duke@435 | 253 | // has been decayed based on the time since the last |
duke@435 | 254 | // major collection. |
duke@435 | 255 | double decaying_gc_cost() const; |
duke@435 | 256 | |
duke@435 | 257 | // Decay the major gc cost. Use this only for decisions on |
duke@435 | 258 | // whether to adjust, not to determine by how much to adjust. |
duke@435 | 259 | // This approximation is crude and may not be good enough for the |
duke@435 | 260 | // latter. |
duke@435 | 261 | double decaying_major_gc_cost() const; |
duke@435 | 262 | |
duke@435 | 263 | // Return the mutator cost using the decayed |
duke@435 | 264 | // GC cost. |
duke@435 | 265 | double adjusted_mutator_cost() const { |
duke@435 | 266 | double result = 1.0 - decaying_gc_cost(); |
duke@435 | 267 | assert(result >= 0.0, "adjusted mutator cost calculation is incorrect"); |
duke@435 | 268 | return result; |
duke@435 | 269 | } |
duke@435 | 270 | |
duke@435 | 271 | virtual double mutator_cost() const { |
duke@435 | 272 | double result = 1.0 - gc_cost(); |
duke@435 | 273 | assert(result >= 0.0, "mutator cost calculation is incorrect"); |
duke@435 | 274 | return result; |
duke@435 | 275 | } |
duke@435 | 276 | |
duke@435 | 277 | |
duke@435 | 278 | bool young_gen_policy_is_ready() { return _young_gen_policy_is_ready; } |
duke@435 | 279 | |
duke@435 | 280 | void update_minor_pause_young_estimator(double minor_pause_in_ms); |
duke@435 | 281 | virtual void update_minor_pause_old_estimator(double minor_pause_in_ms) { |
duke@435 | 282 | // This is not meaningful for all policies but needs to be present |
duke@435 | 283 | // to use minor_collection_end() in its current form. |
duke@435 | 284 | } |
duke@435 | 285 | |
duke@435 | 286 | virtual size_t eden_increment(size_t cur_eden); |
duke@435 | 287 | virtual size_t eden_increment(size_t cur_eden, uint percent_change); |
duke@435 | 288 | virtual size_t eden_decrement(size_t cur_eden); |
duke@435 | 289 | virtual size_t promo_increment(size_t cur_eden); |
duke@435 | 290 | virtual size_t promo_increment(size_t cur_eden, uint percent_change); |
duke@435 | 291 | virtual size_t promo_decrement(size_t cur_eden); |
duke@435 | 292 | |
duke@435 | 293 | virtual void clear_generation_free_space_flags(); |
duke@435 | 294 | |
duke@435 | 295 | int change_old_gen_for_throughput() const { |
duke@435 | 296 | return _change_old_gen_for_throughput; |
duke@435 | 297 | } |
duke@435 | 298 | void set_change_old_gen_for_throughput(int v) { |
duke@435 | 299 | _change_old_gen_for_throughput = v; |
duke@435 | 300 | } |
duke@435 | 301 | int change_young_gen_for_throughput() const { |
duke@435 | 302 | return _change_young_gen_for_throughput; |
duke@435 | 303 | } |
duke@435 | 304 | void set_change_young_gen_for_throughput(int v) { |
duke@435 | 305 | _change_young_gen_for_throughput = v; |
duke@435 | 306 | } |
duke@435 | 307 | |
duke@435 | 308 | int change_old_gen_for_maj_pauses() const { |
duke@435 | 309 | return _change_old_gen_for_maj_pauses; |
duke@435 | 310 | } |
duke@435 | 311 | void set_change_old_gen_for_maj_pauses(int v) { |
duke@435 | 312 | _change_old_gen_for_maj_pauses = v; |
duke@435 | 313 | } |
duke@435 | 314 | |
duke@435 | 315 | bool decrement_tenuring_threshold_for_gc_cost() const { |
duke@435 | 316 | return _decrement_tenuring_threshold_for_gc_cost; |
duke@435 | 317 | } |
duke@435 | 318 | void set_decrement_tenuring_threshold_for_gc_cost(bool v) { |
duke@435 | 319 | _decrement_tenuring_threshold_for_gc_cost = v; |
duke@435 | 320 | } |
duke@435 | 321 | bool increment_tenuring_threshold_for_gc_cost() const { |
duke@435 | 322 | return _increment_tenuring_threshold_for_gc_cost; |
duke@435 | 323 | } |
duke@435 | 324 | void set_increment_tenuring_threshold_for_gc_cost(bool v) { |
duke@435 | 325 | _increment_tenuring_threshold_for_gc_cost = v; |
duke@435 | 326 | } |
duke@435 | 327 | bool decrement_tenuring_threshold_for_survivor_limit() const { |
duke@435 | 328 | return _decrement_tenuring_threshold_for_survivor_limit; |
duke@435 | 329 | } |
duke@435 | 330 | void set_decrement_tenuring_threshold_for_survivor_limit(bool v) { |
duke@435 | 331 | _decrement_tenuring_threshold_for_survivor_limit = v; |
duke@435 | 332 | } |
duke@435 | 333 | // Return true if the policy suggested a change. |
duke@435 | 334 | bool tenuring_threshold_change() const; |
duke@435 | 335 | |
jmasa@3294 | 336 | static bool _debug_perturbation; |
jmasa@3294 | 337 | |
duke@435 | 338 | public: |
duke@435 | 339 | AdaptiveSizePolicy(size_t init_eden_size, |
duke@435 | 340 | size_t init_promo_size, |
duke@435 | 341 | size_t init_survivor_size, |
duke@435 | 342 | double gc_pause_goal_sec, |
duke@435 | 343 | uint gc_cost_ratio); |
duke@435 | 344 | |
jmasa@3294 | 345 | // Return number default GC threads to use in the next GC. |
jmasa@3294 | 346 | static int calc_default_active_workers(uintx total_workers, |
jmasa@3294 | 347 | const uintx min_workers, |
jmasa@3294 | 348 | uintx active_workers, |
jmasa@3294 | 349 | uintx application_workers); |
jmasa@3294 | 350 | |
jmasa@3294 | 351 | // Return number of GC threads to use in the next GC. |
jmasa@3294 | 352 | // This is called sparingly so as not to change the |
jmasa@3294 | 353 | // number of GC workers gratuitously. |
jmasa@3294 | 354 | // For ParNew collections |
jmasa@3294 | 355 | // For PS scavenge and ParOld collections |
jmasa@3294 | 356 | // For G1 evacuation pauses (subject to update) |
jmasa@3294 | 357 | // Other collection phases inherit the number of |
jmasa@3294 | 358 | // GC workers from the calls above. For example, |
jmasa@3294 | 359 | // a CMS parallel remark uses the same number of GC |
jmasa@3294 | 360 | // workers as the most recent ParNew collection. |
jmasa@3294 | 361 | static int calc_active_workers(uintx total_workers, |
jmasa@3294 | 362 | uintx active_workers, |
jmasa@3294 | 363 | uintx application_workers); |
jmasa@3294 | 364 | |
jmasa@3294 | 365 | // Return number of GC threads to use in the next concurrent GC phase. |
jmasa@3294 | 366 | static int calc_active_conc_workers(uintx total_workers, |
jmasa@3294 | 367 | uintx active_workers, |
jmasa@3294 | 368 | uintx application_workers); |
jmasa@3294 | 369 | |
duke@435 | 370 | bool is_gc_cms_adaptive_size_policy() { |
duke@435 | 371 | return kind() == _gc_cms_adaptive_size_policy; |
duke@435 | 372 | } |
duke@435 | 373 | bool is_gc_ps_adaptive_size_policy() { |
duke@435 | 374 | return kind() == _gc_ps_adaptive_size_policy; |
duke@435 | 375 | } |
duke@435 | 376 | |
duke@435 | 377 | AdaptivePaddedAverage* avg_minor_pause() const { return _avg_minor_pause; } |
duke@435 | 378 | AdaptiveWeightedAverage* avg_minor_interval() const { |
duke@435 | 379 | return _avg_minor_interval; |
duke@435 | 380 | } |
duke@435 | 381 | AdaptiveWeightedAverage* avg_minor_gc_cost() const { |
duke@435 | 382 | return _avg_minor_gc_cost; |
duke@435 | 383 | } |
duke@435 | 384 | |
duke@435 | 385 | AdaptiveWeightedAverage* avg_major_gc_cost() const { |
duke@435 | 386 | return _avg_major_gc_cost; |
duke@435 | 387 | } |
duke@435 | 388 | |
duke@435 | 389 | AdaptiveWeightedAverage* avg_young_live() const { return _avg_young_live; } |
duke@435 | 390 | AdaptiveWeightedAverage* avg_eden_live() const { return _avg_eden_live; } |
duke@435 | 391 | AdaptiveWeightedAverage* avg_old_live() const { return _avg_old_live; } |
duke@435 | 392 | |
duke@435 | 393 | AdaptivePaddedAverage* avg_survived() const { return _avg_survived; } |
duke@435 | 394 | AdaptivePaddedNoZeroDevAverage* avg_pretenured() { return _avg_pretenured; } |
duke@435 | 395 | |
duke@435 | 396 | // Methods indicating events of interest to the adaptive size policy, |
duke@435 | 397 | // called by GC algorithms. It is the responsibility of users of this |
duke@435 | 398 | // policy to call these methods at the correct times! |
duke@435 | 399 | virtual void minor_collection_begin(); |
duke@435 | 400 | virtual void minor_collection_end(GCCause::Cause gc_cause); |
duke@435 | 401 | virtual LinearLeastSquareFit* minor_pause_old_estimator() const { |
duke@435 | 402 | return _minor_pause_old_estimator; |
duke@435 | 403 | } |
duke@435 | 404 | |
duke@435 | 405 | LinearLeastSquareFit* minor_pause_young_estimator() { |
duke@435 | 406 | return _minor_pause_young_estimator; |
duke@435 | 407 | } |
duke@435 | 408 | LinearLeastSquareFit* minor_collection_estimator() { |
duke@435 | 409 | return _minor_collection_estimator; |
duke@435 | 410 | } |
duke@435 | 411 | |
duke@435 | 412 | LinearLeastSquareFit* major_collection_estimator() { |
duke@435 | 413 | return _major_collection_estimator; |
duke@435 | 414 | } |
duke@435 | 415 | |
duke@435 | 416 | float minor_pause_young_slope() { |
duke@435 | 417 | return _minor_pause_young_estimator->slope(); |
duke@435 | 418 | } |
duke@435 | 419 | |
duke@435 | 420 | float minor_collection_slope() { return _minor_collection_estimator->slope();} |
duke@435 | 421 | float major_collection_slope() { return _major_collection_estimator->slope();} |
duke@435 | 422 | |
duke@435 | 423 | float minor_pause_old_slope() { |
duke@435 | 424 | return _minor_pause_old_estimator->slope(); |
duke@435 | 425 | } |
duke@435 | 426 | |
duke@435 | 427 | void set_eden_size(size_t new_size) { |
duke@435 | 428 | _eden_size = new_size; |
duke@435 | 429 | } |
duke@435 | 430 | void set_survivor_size(size_t new_size) { |
duke@435 | 431 | _survivor_size = new_size; |
duke@435 | 432 | } |
duke@435 | 433 | |
duke@435 | 434 | size_t calculated_eden_size_in_bytes() const { |
duke@435 | 435 | return _eden_size; |
duke@435 | 436 | } |
duke@435 | 437 | |
duke@435 | 438 | size_t calculated_promo_size_in_bytes() const { |
duke@435 | 439 | return _promo_size; |
duke@435 | 440 | } |
duke@435 | 441 | |
duke@435 | 442 | size_t calculated_survivor_size_in_bytes() const { |
duke@435 | 443 | return _survivor_size; |
duke@435 | 444 | } |
duke@435 | 445 | |
duke@435 | 446 | // This is a hint for the heap: we've detected that gc times |
duke@435 | 447 | // are taking longer than GCTimeLimit allows. |
duke@435 | 448 | // Most heaps will choose to throw an OutOfMemoryError when |
duke@435 | 449 | // this occurs but it is up to the heap to request this information |
duke@435 | 450 | // of the policy |
jmasa@1822 | 451 | bool gc_overhead_limit_exceeded() { |
jmasa@1822 | 452 | return _gc_overhead_limit_exceeded; |
duke@435 | 453 | } |
jmasa@1822 | 454 | void set_gc_overhead_limit_exceeded(bool v) { |
jmasa@1822 | 455 | _gc_overhead_limit_exceeded = v; |
duke@435 | 456 | } |
duke@435 | 457 | |
jmasa@1822 | 458 | // Tests conditions indicate the GC overhead limit is being approached. |
jmasa@1822 | 459 | bool gc_overhead_limit_near() { |
jmasa@1822 | 460 | return gc_overhead_limit_count() >= |
jmasa@1822 | 461 | (AdaptiveSizePolicyGCTimeLimitThreshold - 1); |
jmasa@1822 | 462 | } |
jmasa@1822 | 463 | uint gc_overhead_limit_count() { return _gc_overhead_limit_count; } |
jmasa@1822 | 464 | void reset_gc_overhead_limit_count() { _gc_overhead_limit_count = 0; } |
jmasa@1822 | 465 | void inc_gc_overhead_limit_count() { _gc_overhead_limit_count++; } |
duke@435 | 466 | // accessors for flags recording the decisions to resize the |
duke@435 | 467 | // generations to meet the pause goal. |
duke@435 | 468 | |
duke@435 | 469 | int change_young_gen_for_min_pauses() const { |
duke@435 | 470 | return _change_young_gen_for_min_pauses; |
duke@435 | 471 | } |
duke@435 | 472 | void set_change_young_gen_for_min_pauses(int v) { |
duke@435 | 473 | _change_young_gen_for_min_pauses = v; |
duke@435 | 474 | } |
duke@435 | 475 | void set_decrease_for_footprint(int v) { _decrease_for_footprint = v; } |
duke@435 | 476 | int decrease_for_footprint() const { return _decrease_for_footprint; } |
duke@435 | 477 | int decide_at_full_gc() { return _decide_at_full_gc; } |
duke@435 | 478 | void set_decide_at_full_gc(int v) { _decide_at_full_gc = v; } |
duke@435 | 479 | |
jmasa@1822 | 480 | // Check the conditions for an out-of-memory due to excessive GC time. |
jmasa@1822 | 481 | // Set _gc_overhead_limit_exceeded if all the conditions have been met. |
jmasa@1822 | 482 | void check_gc_overhead_limit(size_t young_live, |
jmasa@1822 | 483 | size_t eden_live, |
jmasa@1822 | 484 | size_t max_old_gen_size, |
jmasa@1822 | 485 | size_t max_eden_size, |
jmasa@1822 | 486 | bool is_full_gc, |
jmasa@1822 | 487 | GCCause::Cause gc_cause, |
jmasa@1822 | 488 | CollectorPolicy* collector_policy); |
jmasa@1822 | 489 | |
duke@435 | 490 | // Printing support |
duke@435 | 491 | virtual bool print_adaptive_size_policy_on(outputStream* st) const; |
jwilhelm@4129 | 492 | bool print_adaptive_size_policy_on(outputStream* st, |
jwilhelm@4129 | 493 | uint tenuring_threshold) const; |
duke@435 | 494 | }; |
duke@435 | 495 | |
duke@435 | 496 | // Class that can be used to print information about the |
duke@435 | 497 | // adaptive size policy at intervals specified by |
duke@435 | 498 | // AdaptiveSizePolicyOutputInterval. Only print information |
duke@435 | 499 | // if an adaptive size policy is in use. |
duke@435 | 500 | class AdaptiveSizePolicyOutput : StackObj { |
duke@435 | 501 | AdaptiveSizePolicy* _size_policy; |
duke@435 | 502 | bool _do_print; |
duke@435 | 503 | bool print_test(uint count) { |
duke@435 | 504 | // A count of zero is a special value that indicates that the |
duke@435 | 505 | // interval test should be ignored. An interval is of zero is |
duke@435 | 506 | // a special value that indicates that the interval test should |
duke@435 | 507 | // always fail (never do the print based on the interval test). |
duke@435 | 508 | return PrintGCDetails && |
duke@435 | 509 | UseAdaptiveSizePolicy && |
duke@435 | 510 | (UseParallelGC || UseConcMarkSweepGC) && |
duke@435 | 511 | (AdaptiveSizePolicyOutputInterval > 0) && |
duke@435 | 512 | ((count == 0) || |
duke@435 | 513 | ((count % AdaptiveSizePolicyOutputInterval) == 0)); |
duke@435 | 514 | } |
duke@435 | 515 | public: |
duke@435 | 516 | // The special value of a zero count can be used to ignore |
duke@435 | 517 | // the count test. |
duke@435 | 518 | AdaptiveSizePolicyOutput(uint count) { |
duke@435 | 519 | if (UseAdaptiveSizePolicy && (AdaptiveSizePolicyOutputInterval > 0)) { |
duke@435 | 520 | CollectedHeap* heap = Universe::heap(); |
duke@435 | 521 | _size_policy = heap->size_policy(); |
duke@435 | 522 | _do_print = print_test(count); |
duke@435 | 523 | } else { |
duke@435 | 524 | _size_policy = NULL; |
duke@435 | 525 | _do_print = false; |
duke@435 | 526 | } |
duke@435 | 527 | } |
duke@435 | 528 | AdaptiveSizePolicyOutput(AdaptiveSizePolicy* size_policy, |
duke@435 | 529 | uint count) : |
duke@435 | 530 | _size_policy(size_policy) { |
duke@435 | 531 | if (UseAdaptiveSizePolicy && (AdaptiveSizePolicyOutputInterval > 0)) { |
duke@435 | 532 | _do_print = print_test(count); |
duke@435 | 533 | } else { |
duke@435 | 534 | _do_print = false; |
duke@435 | 535 | } |
duke@435 | 536 | } |
duke@435 | 537 | ~AdaptiveSizePolicyOutput() { |
duke@435 | 538 | if (_do_print) { |
duke@435 | 539 | assert(UseAdaptiveSizePolicy, "Should not be in use"); |
duke@435 | 540 | _size_policy->print_adaptive_size_policy_on(gclog_or_tty); |
duke@435 | 541 | } |
duke@435 | 542 | } |
duke@435 | 543 | }; |
stefank@2314 | 544 | |
stefank@2314 | 545 | #endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_ADAPTIVESIZEPOLICY_HPP |