src/share/vm/gc_implementation/shared/adaptiveSizePolicy.hpp

Tue, 23 Nov 2010 13:22:55 -0800

author
stefank
date
Tue, 23 Nov 2010 13:22:55 -0800
changeset 2314
f95d63e2154a
parent 1907
c18cbe5936b8
child 3294
bca17e38de00
permissions
-rw-r--r--

6989984: Use standard include model for Hospot
Summary: Replaced MakeDeps and the includeDB files with more standardized solutions.
Reviewed-by: coleenp, kvn, kamg

duke@435 1 /*
trims@1907 2 * Copyright (c) 2004, 2010, 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
duke@435 41 class AdaptiveSizePolicy : public CHeapObj {
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
duke@435 190 // Accessors
duke@435 191
duke@435 192 double gc_pause_goal_sec() const { return _gc_pause_goal_sec; }
duke@435 193 // The value returned is unitless: it's the proportion of time
duke@435 194 // spent in a particular collection type.
duke@435 195 // An interval time will be 0.0 if a collection type hasn't occurred yet.
duke@435 196 // The 1.4.2 implementation put a floor on the values of major_gc_cost
duke@435 197 // and minor_gc_cost. This was useful because of the way major_gc_cost
duke@435 198 // and minor_gc_cost was used in calculating the sizes of the generations.
duke@435 199 // Do not use a floor in this implementation because any finite value
duke@435 200 // will put a limit on the throughput that can be achieved and any
duke@435 201 // throughput goal above that limit will drive the generations sizes
duke@435 202 // to extremes.
duke@435 203 double major_gc_cost() const {
duke@435 204 return MAX2(0.0F, _avg_major_gc_cost->average());
duke@435 205 }
duke@435 206
duke@435 207 // The value returned is unitless: it's the proportion of time
duke@435 208 // spent in a particular collection type.
duke@435 209 // An interval time will be 0.0 if a collection type hasn't occurred yet.
duke@435 210 // The 1.4.2 implementation put a floor on the values of major_gc_cost
duke@435 211 // and minor_gc_cost. This was useful because of the way major_gc_cost
duke@435 212 // and minor_gc_cost was used in calculating the sizes of the generations.
duke@435 213 // Do not use a floor in this implementation because any finite value
duke@435 214 // will put a limit on the throughput that can be achieved and any
duke@435 215 // throughput goal above that limit will drive the generations sizes
duke@435 216 // to extremes.
duke@435 217
duke@435 218 double minor_gc_cost() const {
duke@435 219 return MAX2(0.0F, _avg_minor_gc_cost->average());
duke@435 220 }
duke@435 221
duke@435 222 // Because we're dealing with averages, gc_cost() can be
duke@435 223 // larger than 1.0 if just the sum of the minor cost the
duke@435 224 // the major cost is used. Worse than that is the
duke@435 225 // fact that the minor cost and the major cost each
duke@435 226 // tend toward 1.0 in the extreme of high gc costs.
duke@435 227 // Limit the value of gc_cost to 1.0 so that the mutator
duke@435 228 // cost stays non-negative.
duke@435 229 virtual double gc_cost() const {
duke@435 230 double result = MIN2(1.0, minor_gc_cost() + major_gc_cost());
duke@435 231 assert(result >= 0.0, "Both minor and major costs are non-negative");
duke@435 232 return result;
duke@435 233 }
duke@435 234
duke@435 235 // Elapsed time since the last major collection.
duke@435 236 virtual double time_since_major_gc() const;
duke@435 237
duke@435 238 // Average interval between major collections to be used
duke@435 239 // in calculating the decaying major gc cost. An overestimate
duke@435 240 // of this time would be a conservative estimate because
duke@435 241 // this time is used to decide if the major GC cost
duke@435 242 // should be decayed (i.e., if the time since the last
duke@435 243 // major gc is long compared to the time returned here,
duke@435 244 // then the major GC cost will be decayed). See the
duke@435 245 // implementations for the specifics.
duke@435 246 virtual double major_gc_interval_average_for_decay() const {
duke@435 247 return _avg_major_interval->average();
duke@435 248 }
duke@435 249
duke@435 250 // Return the cost of the GC where the major gc cost
duke@435 251 // has been decayed based on the time since the last
duke@435 252 // major collection.
duke@435 253 double decaying_gc_cost() const;
duke@435 254
duke@435 255 // Decay the major gc cost. Use this only for decisions on
duke@435 256 // whether to adjust, not to determine by how much to adjust.
duke@435 257 // This approximation is crude and may not be good enough for the
duke@435 258 // latter.
duke@435 259 double decaying_major_gc_cost() const;
duke@435 260
duke@435 261 // Return the mutator cost using the decayed
duke@435 262 // GC cost.
duke@435 263 double adjusted_mutator_cost() const {
duke@435 264 double result = 1.0 - decaying_gc_cost();
duke@435 265 assert(result >= 0.0, "adjusted mutator cost calculation is incorrect");
duke@435 266 return result;
duke@435 267 }
duke@435 268
duke@435 269 virtual double mutator_cost() const {
duke@435 270 double result = 1.0 - gc_cost();
duke@435 271 assert(result >= 0.0, "mutator cost calculation is incorrect");
duke@435 272 return result;
duke@435 273 }
duke@435 274
duke@435 275
duke@435 276 bool young_gen_policy_is_ready() { return _young_gen_policy_is_ready; }
duke@435 277
duke@435 278 void update_minor_pause_young_estimator(double minor_pause_in_ms);
duke@435 279 virtual void update_minor_pause_old_estimator(double minor_pause_in_ms) {
duke@435 280 // This is not meaningful for all policies but needs to be present
duke@435 281 // to use minor_collection_end() in its current form.
duke@435 282 }
duke@435 283
duke@435 284 virtual size_t eden_increment(size_t cur_eden);
duke@435 285 virtual size_t eden_increment(size_t cur_eden, uint percent_change);
duke@435 286 virtual size_t eden_decrement(size_t cur_eden);
duke@435 287 virtual size_t promo_increment(size_t cur_eden);
duke@435 288 virtual size_t promo_increment(size_t cur_eden, uint percent_change);
duke@435 289 virtual size_t promo_decrement(size_t cur_eden);
duke@435 290
duke@435 291 virtual void clear_generation_free_space_flags();
duke@435 292
duke@435 293 int change_old_gen_for_throughput() const {
duke@435 294 return _change_old_gen_for_throughput;
duke@435 295 }
duke@435 296 void set_change_old_gen_for_throughput(int v) {
duke@435 297 _change_old_gen_for_throughput = v;
duke@435 298 }
duke@435 299 int change_young_gen_for_throughput() const {
duke@435 300 return _change_young_gen_for_throughput;
duke@435 301 }
duke@435 302 void set_change_young_gen_for_throughput(int v) {
duke@435 303 _change_young_gen_for_throughput = v;
duke@435 304 }
duke@435 305
duke@435 306 int change_old_gen_for_maj_pauses() const {
duke@435 307 return _change_old_gen_for_maj_pauses;
duke@435 308 }
duke@435 309 void set_change_old_gen_for_maj_pauses(int v) {
duke@435 310 _change_old_gen_for_maj_pauses = v;
duke@435 311 }
duke@435 312
duke@435 313 bool decrement_tenuring_threshold_for_gc_cost() const {
duke@435 314 return _decrement_tenuring_threshold_for_gc_cost;
duke@435 315 }
duke@435 316 void set_decrement_tenuring_threshold_for_gc_cost(bool v) {
duke@435 317 _decrement_tenuring_threshold_for_gc_cost = v;
duke@435 318 }
duke@435 319 bool increment_tenuring_threshold_for_gc_cost() const {
duke@435 320 return _increment_tenuring_threshold_for_gc_cost;
duke@435 321 }
duke@435 322 void set_increment_tenuring_threshold_for_gc_cost(bool v) {
duke@435 323 _increment_tenuring_threshold_for_gc_cost = v;
duke@435 324 }
duke@435 325 bool decrement_tenuring_threshold_for_survivor_limit() const {
duke@435 326 return _decrement_tenuring_threshold_for_survivor_limit;
duke@435 327 }
duke@435 328 void set_decrement_tenuring_threshold_for_survivor_limit(bool v) {
duke@435 329 _decrement_tenuring_threshold_for_survivor_limit = v;
duke@435 330 }
duke@435 331 // Return true if the policy suggested a change.
duke@435 332 bool tenuring_threshold_change() const;
duke@435 333
duke@435 334 public:
duke@435 335 AdaptiveSizePolicy(size_t init_eden_size,
duke@435 336 size_t init_promo_size,
duke@435 337 size_t init_survivor_size,
duke@435 338 double gc_pause_goal_sec,
duke@435 339 uint gc_cost_ratio);
duke@435 340
duke@435 341 bool is_gc_cms_adaptive_size_policy() {
duke@435 342 return kind() == _gc_cms_adaptive_size_policy;
duke@435 343 }
duke@435 344 bool is_gc_ps_adaptive_size_policy() {
duke@435 345 return kind() == _gc_ps_adaptive_size_policy;
duke@435 346 }
duke@435 347
duke@435 348 AdaptivePaddedAverage* avg_minor_pause() const { return _avg_minor_pause; }
duke@435 349 AdaptiveWeightedAverage* avg_minor_interval() const {
duke@435 350 return _avg_minor_interval;
duke@435 351 }
duke@435 352 AdaptiveWeightedAverage* avg_minor_gc_cost() const {
duke@435 353 return _avg_minor_gc_cost;
duke@435 354 }
duke@435 355
duke@435 356 AdaptiveWeightedAverage* avg_major_gc_cost() const {
duke@435 357 return _avg_major_gc_cost;
duke@435 358 }
duke@435 359
duke@435 360 AdaptiveWeightedAverage* avg_young_live() const { return _avg_young_live; }
duke@435 361 AdaptiveWeightedAverage* avg_eden_live() const { return _avg_eden_live; }
duke@435 362 AdaptiveWeightedAverage* avg_old_live() const { return _avg_old_live; }
duke@435 363
duke@435 364 AdaptivePaddedAverage* avg_survived() const { return _avg_survived; }
duke@435 365 AdaptivePaddedNoZeroDevAverage* avg_pretenured() { return _avg_pretenured; }
duke@435 366
duke@435 367 // Methods indicating events of interest to the adaptive size policy,
duke@435 368 // called by GC algorithms. It is the responsibility of users of this
duke@435 369 // policy to call these methods at the correct times!
duke@435 370 virtual void minor_collection_begin();
duke@435 371 virtual void minor_collection_end(GCCause::Cause gc_cause);
duke@435 372 virtual LinearLeastSquareFit* minor_pause_old_estimator() const {
duke@435 373 return _minor_pause_old_estimator;
duke@435 374 }
duke@435 375
duke@435 376 LinearLeastSquareFit* minor_pause_young_estimator() {
duke@435 377 return _minor_pause_young_estimator;
duke@435 378 }
duke@435 379 LinearLeastSquareFit* minor_collection_estimator() {
duke@435 380 return _minor_collection_estimator;
duke@435 381 }
duke@435 382
duke@435 383 LinearLeastSquareFit* major_collection_estimator() {
duke@435 384 return _major_collection_estimator;
duke@435 385 }
duke@435 386
duke@435 387 float minor_pause_young_slope() {
duke@435 388 return _minor_pause_young_estimator->slope();
duke@435 389 }
duke@435 390
duke@435 391 float minor_collection_slope() { return _minor_collection_estimator->slope();}
duke@435 392 float major_collection_slope() { return _major_collection_estimator->slope();}
duke@435 393
duke@435 394 float minor_pause_old_slope() {
duke@435 395 return _minor_pause_old_estimator->slope();
duke@435 396 }
duke@435 397
duke@435 398 void set_eden_size(size_t new_size) {
duke@435 399 _eden_size = new_size;
duke@435 400 }
duke@435 401 void set_survivor_size(size_t new_size) {
duke@435 402 _survivor_size = new_size;
duke@435 403 }
duke@435 404
duke@435 405 size_t calculated_eden_size_in_bytes() const {
duke@435 406 return _eden_size;
duke@435 407 }
duke@435 408
duke@435 409 size_t calculated_promo_size_in_bytes() const {
duke@435 410 return _promo_size;
duke@435 411 }
duke@435 412
duke@435 413 size_t calculated_survivor_size_in_bytes() const {
duke@435 414 return _survivor_size;
duke@435 415 }
duke@435 416
duke@435 417 // This is a hint for the heap: we've detected that gc times
duke@435 418 // are taking longer than GCTimeLimit allows.
duke@435 419 // Most heaps will choose to throw an OutOfMemoryError when
duke@435 420 // this occurs but it is up to the heap to request this information
duke@435 421 // of the policy
jmasa@1822 422 bool gc_overhead_limit_exceeded() {
jmasa@1822 423 return _gc_overhead_limit_exceeded;
duke@435 424 }
jmasa@1822 425 void set_gc_overhead_limit_exceeded(bool v) {
jmasa@1822 426 _gc_overhead_limit_exceeded = v;
duke@435 427 }
duke@435 428
jmasa@1822 429 // Tests conditions indicate the GC overhead limit is being approached.
jmasa@1822 430 bool gc_overhead_limit_near() {
jmasa@1822 431 return gc_overhead_limit_count() >=
jmasa@1822 432 (AdaptiveSizePolicyGCTimeLimitThreshold - 1);
jmasa@1822 433 }
jmasa@1822 434 uint gc_overhead_limit_count() { return _gc_overhead_limit_count; }
jmasa@1822 435 void reset_gc_overhead_limit_count() { _gc_overhead_limit_count = 0; }
jmasa@1822 436 void inc_gc_overhead_limit_count() { _gc_overhead_limit_count++; }
duke@435 437 // accessors for flags recording the decisions to resize the
duke@435 438 // generations to meet the pause goal.
duke@435 439
duke@435 440 int change_young_gen_for_min_pauses() const {
duke@435 441 return _change_young_gen_for_min_pauses;
duke@435 442 }
duke@435 443 void set_change_young_gen_for_min_pauses(int v) {
duke@435 444 _change_young_gen_for_min_pauses = v;
duke@435 445 }
duke@435 446 void set_decrease_for_footprint(int v) { _decrease_for_footprint = v; }
duke@435 447 int decrease_for_footprint() const { return _decrease_for_footprint; }
duke@435 448 int decide_at_full_gc() { return _decide_at_full_gc; }
duke@435 449 void set_decide_at_full_gc(int v) { _decide_at_full_gc = v; }
duke@435 450
jmasa@1822 451 // Check the conditions for an out-of-memory due to excessive GC time.
jmasa@1822 452 // Set _gc_overhead_limit_exceeded if all the conditions have been met.
jmasa@1822 453 void check_gc_overhead_limit(size_t young_live,
jmasa@1822 454 size_t eden_live,
jmasa@1822 455 size_t max_old_gen_size,
jmasa@1822 456 size_t max_eden_size,
jmasa@1822 457 bool is_full_gc,
jmasa@1822 458 GCCause::Cause gc_cause,
jmasa@1822 459 CollectorPolicy* collector_policy);
jmasa@1822 460
duke@435 461 // Printing support
duke@435 462 virtual bool print_adaptive_size_policy_on(outputStream* st) const;
duke@435 463 bool print_adaptive_size_policy_on(outputStream* st, int
duke@435 464 tenuring_threshold) const;
duke@435 465 };
duke@435 466
duke@435 467 // Class that can be used to print information about the
duke@435 468 // adaptive size policy at intervals specified by
duke@435 469 // AdaptiveSizePolicyOutputInterval. Only print information
duke@435 470 // if an adaptive size policy is in use.
duke@435 471 class AdaptiveSizePolicyOutput : StackObj {
duke@435 472 AdaptiveSizePolicy* _size_policy;
duke@435 473 bool _do_print;
duke@435 474 bool print_test(uint count) {
duke@435 475 // A count of zero is a special value that indicates that the
duke@435 476 // interval test should be ignored. An interval is of zero is
duke@435 477 // a special value that indicates that the interval test should
duke@435 478 // always fail (never do the print based on the interval test).
duke@435 479 return PrintGCDetails &&
duke@435 480 UseAdaptiveSizePolicy &&
duke@435 481 (UseParallelGC || UseConcMarkSweepGC) &&
duke@435 482 (AdaptiveSizePolicyOutputInterval > 0) &&
duke@435 483 ((count == 0) ||
duke@435 484 ((count % AdaptiveSizePolicyOutputInterval) == 0));
duke@435 485 }
duke@435 486 public:
duke@435 487 // The special value of a zero count can be used to ignore
duke@435 488 // the count test.
duke@435 489 AdaptiveSizePolicyOutput(uint count) {
duke@435 490 if (UseAdaptiveSizePolicy && (AdaptiveSizePolicyOutputInterval > 0)) {
duke@435 491 CollectedHeap* heap = Universe::heap();
duke@435 492 _size_policy = heap->size_policy();
duke@435 493 _do_print = print_test(count);
duke@435 494 } else {
duke@435 495 _size_policy = NULL;
duke@435 496 _do_print = false;
duke@435 497 }
duke@435 498 }
duke@435 499 AdaptiveSizePolicyOutput(AdaptiveSizePolicy* size_policy,
duke@435 500 uint count) :
duke@435 501 _size_policy(size_policy) {
duke@435 502 if (UseAdaptiveSizePolicy && (AdaptiveSizePolicyOutputInterval > 0)) {
duke@435 503 _do_print = print_test(count);
duke@435 504 } else {
duke@435 505 _do_print = false;
duke@435 506 }
duke@435 507 }
duke@435 508 ~AdaptiveSizePolicyOutput() {
duke@435 509 if (_do_print) {
duke@435 510 assert(UseAdaptiveSizePolicy, "Should not be in use");
duke@435 511 _size_policy->print_adaptive_size_policy_on(gclog_or_tty);
duke@435 512 }
duke@435 513 }
duke@435 514 };
stefank@2314 515
stefank@2314 516 #endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_ADAPTIVESIZEPOLICY_HPP

mercurial