psAdaptiveSizePolicy.cpp revision 9727:f944761a3ce3
1/* 2 * Copyright (c) 2002, 2015, 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#include "precompiled.hpp" 26#include "gc/parallel/parallelScavengeHeap.hpp" 27#include "gc/parallel/psAdaptiveSizePolicy.hpp" 28#include "gc/parallel/psGCAdaptivePolicyCounters.hpp" 29#include "gc/parallel/psScavenge.hpp" 30#include "gc/shared/collectorPolicy.hpp" 31#include "gc/shared/gcCause.hpp" 32#include "gc/shared/gcPolicyCounters.hpp" 33#include "logging/log.hpp" 34#include "runtime/timer.hpp" 35#include "utilities/top.hpp" 36 37#include <math.h> 38 39PSAdaptiveSizePolicy::PSAdaptiveSizePolicy(size_t init_eden_size, 40 size_t init_promo_size, 41 size_t init_survivor_size, 42 size_t space_alignment, 43 double gc_pause_goal_sec, 44 double gc_minor_pause_goal_sec, 45 uint gc_cost_ratio) : 46 AdaptiveSizePolicy(init_eden_size, 47 init_promo_size, 48 init_survivor_size, 49 gc_pause_goal_sec, 50 gc_cost_ratio), 51 _collection_cost_margin_fraction(AdaptiveSizePolicyCollectionCostMargin / 100.0), 52 _space_alignment(space_alignment), 53 _live_at_last_full_gc(init_promo_size), 54 _gc_minor_pause_goal_sec(gc_minor_pause_goal_sec), 55 _latest_major_mutator_interval_seconds(0), 56 _young_gen_change_for_major_pause_count(0) 57{ 58 // Sizing policy statistics 59 _avg_major_pause = 60 new AdaptivePaddedAverage(AdaptiveTimeWeight, PausePadding); 61 _avg_minor_interval = new AdaptiveWeightedAverage(AdaptiveTimeWeight); 62 _avg_major_interval = new AdaptiveWeightedAverage(AdaptiveTimeWeight); 63 64 _avg_base_footprint = new AdaptiveWeightedAverage(AdaptiveSizePolicyWeight); 65 _major_pause_old_estimator = 66 new LinearLeastSquareFit(AdaptiveSizePolicyWeight); 67 _major_pause_young_estimator = 68 new LinearLeastSquareFit(AdaptiveSizePolicyWeight); 69 _major_collection_estimator = 70 new LinearLeastSquareFit(AdaptiveSizePolicyWeight); 71 72 _young_gen_size_increment_supplement = YoungGenerationSizeSupplement; 73 _old_gen_size_increment_supplement = TenuredGenerationSizeSupplement; 74 75 // Start the timers 76 _major_timer.start(); 77 78 _old_gen_policy_is_ready = false; 79} 80 81size_t PSAdaptiveSizePolicy::calculate_free_based_on_live(size_t live, uintx ratio_as_percentage) { 82 // We want to calculate how much free memory there can be based on the 83 // amount of live data currently in the old gen. Using the formula: 84 // ratio * (free + live) = free 85 // Some equation solving later we get: 86 // free = (live * ratio) / (1 - ratio) 87 88 const double ratio = ratio_as_percentage / 100.0; 89 const double ratio_inverse = 1.0 - ratio; 90 const double tmp = live * ratio; 91 size_t free = (size_t)(tmp / ratio_inverse); 92 93 return free; 94} 95 96size_t PSAdaptiveSizePolicy::calculated_old_free_size_in_bytes() const { 97 size_t free_size = (size_t)(_promo_size + avg_promoted()->padded_average()); 98 size_t live = ParallelScavengeHeap::heap()->old_gen()->used_in_bytes(); 99 100 if (MinHeapFreeRatio != 0) { 101 size_t min_free = calculate_free_based_on_live(live, MinHeapFreeRatio); 102 free_size = MAX2(free_size, min_free); 103 } 104 105 if (MaxHeapFreeRatio != 100) { 106 size_t max_free = calculate_free_based_on_live(live, MaxHeapFreeRatio); 107 free_size = MIN2(max_free, free_size); 108 } 109 110 return free_size; 111} 112 113void PSAdaptiveSizePolicy::major_collection_begin() { 114 // Update the interval time 115 _major_timer.stop(); 116 // Save most recent collection time 117 _latest_major_mutator_interval_seconds = _major_timer.seconds(); 118 _major_timer.reset(); 119 _major_timer.start(); 120} 121 122void PSAdaptiveSizePolicy::update_minor_pause_old_estimator( 123 double minor_pause_in_ms) { 124 double promo_size_in_mbytes = ((double)_promo_size)/((double)M); 125 _minor_pause_old_estimator->update(promo_size_in_mbytes, 126 minor_pause_in_ms); 127} 128 129void PSAdaptiveSizePolicy::major_collection_end(size_t amount_live, 130 GCCause::Cause gc_cause) { 131 // Update the pause time. 132 _major_timer.stop(); 133 134 if (should_update_promo_stats(gc_cause)) { 135 double major_pause_in_seconds = _major_timer.seconds(); 136 double major_pause_in_ms = major_pause_in_seconds * MILLIUNITS; 137 138 // Sample for performance counter 139 _avg_major_pause->sample(major_pause_in_seconds); 140 141 // Cost of collection (unit-less) 142 double collection_cost = 0.0; 143 if ((_latest_major_mutator_interval_seconds > 0.0) && 144 (major_pause_in_seconds > 0.0)) { 145 double interval_in_seconds = 146 _latest_major_mutator_interval_seconds + major_pause_in_seconds; 147 collection_cost = 148 major_pause_in_seconds / interval_in_seconds; 149 avg_major_gc_cost()->sample(collection_cost); 150 151 // Sample for performance counter 152 _avg_major_interval->sample(interval_in_seconds); 153 } 154 155 // Calculate variables used to estimate pause time vs. gen sizes 156 double eden_size_in_mbytes = ((double)_eden_size)/((double)M); 157 double promo_size_in_mbytes = ((double)_promo_size)/((double)M); 158 _major_pause_old_estimator->update(promo_size_in_mbytes, 159 major_pause_in_ms); 160 _major_pause_young_estimator->update(eden_size_in_mbytes, 161 major_pause_in_ms); 162 163 log_trace(gc, ergo)("psAdaptiveSizePolicy::major_collection_end: major gc cost: %f average: %f", 164 collection_cost,avg_major_gc_cost()->average()); 165 log_trace(gc, ergo)(" major pause: %f major period %f", 166 major_pause_in_ms, _latest_major_mutator_interval_seconds * MILLIUNITS); 167 168 // Calculate variable used to estimate collection cost vs. gen sizes 169 assert(collection_cost >= 0.0, "Expected to be non-negative"); 170 _major_collection_estimator->update(promo_size_in_mbytes, 171 collection_cost); 172 } 173 174 // Update the amount live at the end of a full GC 175 _live_at_last_full_gc = amount_live; 176 177 // The policy does not have enough data until at least some major collections 178 // have been done. 179 if (_avg_major_pause->count() >= AdaptiveSizePolicyReadyThreshold) { 180 _old_gen_policy_is_ready = true; 181 } 182 183 // Interval times use this timer to measure the interval that 184 // the mutator runs. Reset after the GC pause has been measured. 185 _major_timer.reset(); 186 _major_timer.start(); 187} 188 189// If the remaining free space in the old generation is less that 190// that expected to be needed by the next collection, do a full 191// collection now. 192bool PSAdaptiveSizePolicy::should_full_GC(size_t old_free_in_bytes) { 193 194 // A similar test is done in the scavenge's should_attempt_scavenge(). If 195 // this is changed, decide if that test should also be changed. 196 bool result = padded_average_promoted_in_bytes() > (float) old_free_in_bytes; 197 log_trace(gc, ergo)("%s after scavenge average_promoted " SIZE_FORMAT " padded_average_promoted " SIZE_FORMAT " free in old gen " SIZE_FORMAT, 198 result ? "Full" : "No full", 199 (size_t) average_promoted_in_bytes(), 200 (size_t) padded_average_promoted_in_bytes(), 201 old_free_in_bytes); 202 return result; 203} 204 205void PSAdaptiveSizePolicy::clear_generation_free_space_flags() { 206 207 AdaptiveSizePolicy::clear_generation_free_space_flags(); 208 209 set_change_old_gen_for_min_pauses(0); 210 211 set_change_young_gen_for_maj_pauses(0); 212} 213 214// If this is not a full GC, only test and modify the young generation. 215 216void PSAdaptiveSizePolicy::compute_generations_free_space( 217 size_t young_live, 218 size_t eden_live, 219 size_t old_live, 220 size_t cur_eden, 221 size_t max_old_gen_size, 222 size_t max_eden_size, 223 bool is_full_gc) { 224 compute_eden_space_size(young_live, 225 eden_live, 226 cur_eden, 227 max_eden_size, 228 is_full_gc); 229 230 compute_old_gen_free_space(old_live, 231 cur_eden, 232 max_old_gen_size, 233 is_full_gc); 234} 235 236void PSAdaptiveSizePolicy::compute_eden_space_size( 237 size_t young_live, 238 size_t eden_live, 239 size_t cur_eden, 240 size_t max_eden_size, 241 bool is_full_gc) { 242 243 // Update statistics 244 // Time statistics are updated as we go, update footprint stats here 245 _avg_base_footprint->sample(BaseFootPrintEstimate); 246 avg_young_live()->sample(young_live); 247 avg_eden_live()->sample(eden_live); 248 249 // This code used to return if the policy was not ready , i.e., 250 // policy_is_ready() returning false. The intent was that 251 // decisions below needed major collection times and so could 252 // not be made before two major collections. A consequence was 253 // adjustments to the young generation were not done until after 254 // two major collections even if the minor collections times 255 // exceeded the requested goals. Now let the young generation 256 // adjust for the minor collection times. Major collection times 257 // will be zero for the first collection and will naturally be 258 // ignored. Tenured generation adjustments are only made at the 259 // full collections so until the second major collection has 260 // been reached, no tenured generation adjustments will be made. 261 262 // Until we know better, desired promotion size uses the last calculation 263 size_t desired_promo_size = _promo_size; 264 265 // Start eden at the current value. The desired value that is stored 266 // in _eden_size is not bounded by constraints of the heap and can 267 // run away. 268 // 269 // As expected setting desired_eden_size to the current 270 // value of desired_eden_size as a starting point 271 // caused desired_eden_size to grow way too large and caused 272 // an overflow down stream. It may have improved performance in 273 // some case but is dangerous. 274 size_t desired_eden_size = cur_eden; 275 276 // Cache some values. There's a bit of work getting these, so 277 // we might save a little time. 278 const double major_cost = major_gc_cost(); 279 const double minor_cost = minor_gc_cost(); 280 281 // This method sets the desired eden size. That plus the 282 // desired survivor space sizes sets the desired young generation 283 // size. This methods does not know what the desired survivor 284 // size is but expects that other policy will attempt to make 285 // the survivor sizes compatible with the live data in the 286 // young generation. This limit is an estimate of the space left 287 // in the young generation after the survivor spaces have been 288 // subtracted out. 289 size_t eden_limit = max_eden_size; 290 291 const double gc_cost_limit = GCTimeLimit / 100.0; 292 293 // Which way should we go? 294 // if pause requirement is not met 295 // adjust size of any generation with average paus exceeding 296 // the pause limit. Adjust one pause at a time (the larger) 297 // and only make adjustments for the major pause at full collections. 298 // else if throughput requirement not met 299 // adjust the size of the generation with larger gc time. Only 300 // adjust one generation at a time. 301 // else 302 // adjust down the total heap size. Adjust down the larger of the 303 // generations. 304 305 // Add some checks for a threshold for a change. For example, 306 // a change less than the necessary alignment is probably not worth 307 // attempting. 308 309 310 if ((_avg_minor_pause->padded_average() > gc_pause_goal_sec()) || 311 (_avg_major_pause->padded_average() > gc_pause_goal_sec())) { 312 // 313 // Check pauses 314 // 315 // Make changes only to affect one of the pauses (the larger) 316 // at a time. 317 adjust_eden_for_pause_time(is_full_gc, &desired_promo_size, &desired_eden_size); 318 319 } else if (_avg_minor_pause->padded_average() > gc_minor_pause_goal_sec()) { 320 // Adjust only for the minor pause time goal 321 adjust_eden_for_minor_pause_time(is_full_gc, &desired_eden_size); 322 323 } else if(adjusted_mutator_cost() < _throughput_goal) { 324 // This branch used to require that (mutator_cost() > 0.0 in 1.4.2. 325 // This sometimes resulted in skipping to the minimize footprint 326 // code. Change this to try and reduce GC time if mutator time is 327 // negative for whatever reason. Or for future consideration, 328 // bail out of the code if mutator time is negative. 329 // 330 // Throughput 331 // 332 assert(major_cost >= 0.0, "major cost is < 0.0"); 333 assert(minor_cost >= 0.0, "minor cost is < 0.0"); 334 // Try to reduce the GC times. 335 adjust_eden_for_throughput(is_full_gc, &desired_eden_size); 336 337 } else { 338 339 // Be conservative about reducing the footprint. 340 // Do a minimum number of major collections first. 341 // Have reasonable averages for major and minor collections costs. 342 if (UseAdaptiveSizePolicyFootprintGoal && 343 young_gen_policy_is_ready() && 344 avg_major_gc_cost()->average() >= 0.0 && 345 avg_minor_gc_cost()->average() >= 0.0) { 346 size_t desired_sum = desired_eden_size + desired_promo_size; 347 desired_eden_size = adjust_eden_for_footprint(desired_eden_size, desired_sum); 348 } 349 } 350 351 // Note we make the same tests as in the code block below; the code 352 // seems a little easier to read with the printing in another block. 353 if (desired_eden_size > eden_limit) { 354 log_debug(gc, ergo)( 355 "PSAdaptiveSizePolicy::compute_eden_space_size limits:" 356 " desired_eden_size: " SIZE_FORMAT 357 " old_eden_size: " SIZE_FORMAT 358 " eden_limit: " SIZE_FORMAT 359 " cur_eden: " SIZE_FORMAT 360 " max_eden_size: " SIZE_FORMAT 361 " avg_young_live: " SIZE_FORMAT, 362 desired_eden_size, _eden_size, eden_limit, cur_eden, 363 max_eden_size, (size_t)avg_young_live()->average()); 364 } 365 if (gc_cost() > gc_cost_limit) { 366 log_debug(gc, ergo)( 367 "PSAdaptiveSizePolicy::compute_eden_space_size: gc time limit" 368 " gc_cost: %f " 369 " GCTimeLimit: " UINTX_FORMAT, 370 gc_cost(), GCTimeLimit); 371 } 372 373 // Align everything and make a final limit check 374 desired_eden_size = align_size_up(desired_eden_size, _space_alignment); 375 desired_eden_size = MAX2(desired_eden_size, _space_alignment); 376 377 eden_limit = align_size_down(eden_limit, _space_alignment); 378 379 // And one last limit check, now that we've aligned things. 380 if (desired_eden_size > eden_limit) { 381 // If the policy says to get a larger eden but 382 // is hitting the limit, don't decrease eden. 383 // This can lead to a general drifting down of the 384 // eden size. Let the tenuring calculation push more 385 // into the old gen. 386 desired_eden_size = MAX2(eden_limit, cur_eden); 387 } 388 389 log_debug(gc, ergo)("PSAdaptiveSizePolicy::compute_eden_space_size: costs minor_time: %f major_cost: %f mutator_cost: %f throughput_goal: %f", 390 minor_gc_cost(), major_gc_cost(), mutator_cost(), _throughput_goal); 391 392 log_trace(gc, ergo)("Minor_pause: %f major_pause: %f minor_interval: %f major_interval: %fpause_goal: %f", 393 _avg_minor_pause->padded_average(), 394 _avg_major_pause->padded_average(), 395 _avg_minor_interval->average(), 396 _avg_major_interval->average(), 397 gc_pause_goal_sec()); 398 399 log_debug(gc, ergo)("Live_space: " SIZE_FORMAT " free_space: " SIZE_FORMAT, 400 live_space(), free_space()); 401 402 log_trace(gc, ergo)("Base_footprint: " SIZE_FORMAT " avg_young_live: " SIZE_FORMAT " avg_old_live: " SIZE_FORMAT, 403 (size_t)_avg_base_footprint->average(), 404 (size_t)avg_young_live()->average(), 405 (size_t)avg_old_live()->average()); 406 407 log_debug(gc, ergo)("Old eden_size: " SIZE_FORMAT " desired_eden_size: " SIZE_FORMAT, 408 _eden_size, desired_eden_size); 409 410 set_eden_size(desired_eden_size); 411} 412 413void PSAdaptiveSizePolicy::compute_old_gen_free_space( 414 size_t old_live, 415 size_t cur_eden, 416 size_t max_old_gen_size, 417 bool is_full_gc) { 418 419 // Update statistics 420 // Time statistics are updated as we go, update footprint stats here 421 if (is_full_gc) { 422 // old_live is only accurate after a full gc 423 avg_old_live()->sample(old_live); 424 } 425 426 // This code used to return if the policy was not ready , i.e., 427 // policy_is_ready() returning false. The intent was that 428 // decisions below needed major collection times and so could 429 // not be made before two major collections. A consequence was 430 // adjustments to the young generation were not done until after 431 // two major collections even if the minor collections times 432 // exceeded the requested goals. Now let the young generation 433 // adjust for the minor collection times. Major collection times 434 // will be zero for the first collection and will naturally be 435 // ignored. Tenured generation adjustments are only made at the 436 // full collections so until the second major collection has 437 // been reached, no tenured generation adjustments will be made. 438 439 // Until we know better, desired promotion size uses the last calculation 440 size_t desired_promo_size = _promo_size; 441 442 // Start eden at the current value. The desired value that is stored 443 // in _eden_size is not bounded by constraints of the heap and can 444 // run away. 445 // 446 // As expected setting desired_eden_size to the current 447 // value of desired_eden_size as a starting point 448 // caused desired_eden_size to grow way too large and caused 449 // an overflow down stream. It may have improved performance in 450 // some case but is dangerous. 451 size_t desired_eden_size = cur_eden; 452 453 // Cache some values. There's a bit of work getting these, so 454 // we might save a little time. 455 const double major_cost = major_gc_cost(); 456 const double minor_cost = minor_gc_cost(); 457 458 // Limits on our growth 459 size_t promo_limit = (size_t)(max_old_gen_size - avg_old_live()->average()); 460 461 // But don't force a promo size below the current promo size. Otherwise, 462 // the promo size will shrink for no good reason. 463 promo_limit = MAX2(promo_limit, _promo_size); 464 465 const double gc_cost_limit = GCTimeLimit/100.0; 466 467 // Which way should we go? 468 // if pause requirement is not met 469 // adjust size of any generation with average paus exceeding 470 // the pause limit. Adjust one pause at a time (the larger) 471 // and only make adjustments for the major pause at full collections. 472 // else if throughput requirement not met 473 // adjust the size of the generation with larger gc time. Only 474 // adjust one generation at a time. 475 // else 476 // adjust down the total heap size. Adjust down the larger of the 477 // generations. 478 479 // Add some checks for a threshold for a change. For example, 480 // a change less than the necessary alignment is probably not worth 481 // attempting. 482 483 if ((_avg_minor_pause->padded_average() > gc_pause_goal_sec()) || 484 (_avg_major_pause->padded_average() > gc_pause_goal_sec())) { 485 // 486 // Check pauses 487 // 488 // Make changes only to affect one of the pauses (the larger) 489 // at a time. 490 if (is_full_gc) { 491 set_decide_at_full_gc(decide_at_full_gc_true); 492 adjust_promo_for_pause_time(is_full_gc, &desired_promo_size, &desired_eden_size); 493 } 494 } else if (adjusted_mutator_cost() < _throughput_goal) { 495 // This branch used to require that (mutator_cost() > 0.0 in 1.4.2. 496 // This sometimes resulted in skipping to the minimize footprint 497 // code. Change this to try and reduce GC time if mutator time is 498 // negative for whatever reason. Or for future consideration, 499 // bail out of the code if mutator time is negative. 500 // 501 // Throughput 502 // 503 assert(major_cost >= 0.0, "major cost is < 0.0"); 504 assert(minor_cost >= 0.0, "minor cost is < 0.0"); 505 // Try to reduce the GC times. 506 if (is_full_gc) { 507 set_decide_at_full_gc(decide_at_full_gc_true); 508 adjust_promo_for_throughput(is_full_gc, &desired_promo_size); 509 } 510 } else { 511 512 // Be conservative about reducing the footprint. 513 // Do a minimum number of major collections first. 514 // Have reasonable averages for major and minor collections costs. 515 if (UseAdaptiveSizePolicyFootprintGoal && 516 young_gen_policy_is_ready() && 517 avg_major_gc_cost()->average() >= 0.0 && 518 avg_minor_gc_cost()->average() >= 0.0) { 519 if (is_full_gc) { 520 set_decide_at_full_gc(decide_at_full_gc_true); 521 size_t desired_sum = desired_eden_size + desired_promo_size; 522 desired_promo_size = adjust_promo_for_footprint(desired_promo_size, desired_sum); 523 } 524 } 525 } 526 527 // Note we make the same tests as in the code block below; the code 528 // seems a little easier to read with the printing in another block. 529 if (desired_promo_size > promo_limit) { 530 // "free_in_old_gen" was the original value for used for promo_limit 531 size_t free_in_old_gen = (size_t)(max_old_gen_size - avg_old_live()->average()); 532 log_debug(gc, ergo)( 533 "PSAdaptiveSizePolicy::compute_old_gen_free_space limits:" 534 " desired_promo_size: " SIZE_FORMAT 535 " promo_limit: " SIZE_FORMAT 536 " free_in_old_gen: " SIZE_FORMAT 537 " max_old_gen_size: " SIZE_FORMAT 538 " avg_old_live: " SIZE_FORMAT, 539 desired_promo_size, promo_limit, free_in_old_gen, 540 max_old_gen_size, (size_t) avg_old_live()->average()); 541 } 542 if (gc_cost() > gc_cost_limit) { 543 log_debug(gc, ergo)( 544 "PSAdaptiveSizePolicy::compute_old_gen_free_space: gc time limit" 545 " gc_cost: %f " 546 " GCTimeLimit: " UINTX_FORMAT, 547 gc_cost(), GCTimeLimit); 548 } 549 550 // Align everything and make a final limit check 551 desired_promo_size = align_size_up(desired_promo_size, _space_alignment); 552 desired_promo_size = MAX2(desired_promo_size, _space_alignment); 553 554 promo_limit = align_size_down(promo_limit, _space_alignment); 555 556 // And one last limit check, now that we've aligned things. 557 desired_promo_size = MIN2(desired_promo_size, promo_limit); 558 559 // Timing stats 560 log_debug(gc, ergo)("PSAdaptiveSizePolicy::compute_old_gen_free_space: costs minor_time: %f major_cost: %f mutator_cost: %f throughput_goal: %f", 561 minor_gc_cost(), major_gc_cost(), mutator_cost(), _throughput_goal); 562 563 log_trace(gc, ergo)("Minor_pause: %f major_pause: %f minor_interval: %f major_interval: %f pause_goal: %f", 564 _avg_minor_pause->padded_average(), 565 _avg_major_pause->padded_average(), 566 _avg_minor_interval->average(), 567 _avg_major_interval->average(), 568 gc_pause_goal_sec()); 569 570 // Footprint stats 571 log_debug(gc, ergo)("Live_space: " SIZE_FORMAT " free_space: " SIZE_FORMAT, 572 live_space(), free_space()); 573 574 log_trace(gc, ergo)("Base_footprint: " SIZE_FORMAT " avg_young_live: " SIZE_FORMAT " avg_old_live: " SIZE_FORMAT, 575 (size_t)_avg_base_footprint->average(), 576 (size_t)avg_young_live()->average(), 577 (size_t)avg_old_live()->average()); 578 579 log_debug(gc, ergo)("Old promo_size: " SIZE_FORMAT " desired_promo_size: " SIZE_FORMAT, 580 _promo_size, desired_promo_size); 581 582 set_promo_size(desired_promo_size); 583} 584 585void PSAdaptiveSizePolicy::decay_supplemental_growth(bool is_full_gc) { 586 // Decay the supplemental increment? Decay the supplement growth 587 // factor even if it is not used. It is only meant to give a boost 588 // to the initial growth and if it is not used, then it was not 589 // needed. 590 if (is_full_gc) { 591 // Don't wait for the threshold value for the major collections. If 592 // here, the supplemental growth term was used and should decay. 593 if ((_avg_major_pause->count() % TenuredGenerationSizeSupplementDecay) 594 == 0) { 595 _old_gen_size_increment_supplement = 596 _old_gen_size_increment_supplement >> 1; 597 } 598 } else { 599 if ((_avg_minor_pause->count() >= AdaptiveSizePolicyReadyThreshold) && 600 (_avg_minor_pause->count() % YoungGenerationSizeSupplementDecay) == 0) { 601 _young_gen_size_increment_supplement = 602 _young_gen_size_increment_supplement >> 1; 603 } 604 } 605} 606 607void PSAdaptiveSizePolicy::adjust_eden_for_minor_pause_time(bool is_full_gc, 608 size_t* desired_eden_size_ptr) { 609 610 // Adjust the young generation size to reduce pause time of 611 // of collections. 612 // 613 // The AdaptiveSizePolicyInitializingSteps test is not used 614 // here. It has not seemed to be needed but perhaps should 615 // be added for consistency. 616 if (minor_pause_young_estimator()->decrement_will_decrease()) { 617 // reduce eden size 618 set_change_young_gen_for_min_pauses( 619 decrease_young_gen_for_min_pauses_true); 620 *desired_eden_size_ptr = *desired_eden_size_ptr - 621 eden_decrement_aligned_down(*desired_eden_size_ptr); 622 } else { 623 // EXPERIMENTAL ADJUSTMENT 624 // Only record that the estimator indicated such an action. 625 // *desired_eden_size_ptr = *desired_eden_size_ptr + eden_heap_delta; 626 set_change_young_gen_for_min_pauses( 627 increase_young_gen_for_min_pauses_true); 628 } 629} 630 631void PSAdaptiveSizePolicy::adjust_promo_for_pause_time(bool is_full_gc, 632 size_t* desired_promo_size_ptr, 633 size_t* desired_eden_size_ptr) { 634 635 size_t promo_heap_delta = 0; 636 // Add some checks for a threshold for a change. For example, 637 // a change less than the required alignment is probably not worth 638 // attempting. 639 640 if (_avg_minor_pause->padded_average() <= _avg_major_pause->padded_average() && is_full_gc) { 641 // Adjust for the major pause time only at full gc's because the 642 // affects of a change can only be seen at full gc's. 643 644 // Reduce old generation size to reduce pause? 645 if (major_pause_old_estimator()->decrement_will_decrease()) { 646 // reduce old generation size 647 set_change_old_gen_for_maj_pauses(decrease_old_gen_for_maj_pauses_true); 648 promo_heap_delta = promo_decrement_aligned_down(*desired_promo_size_ptr); 649 *desired_promo_size_ptr = _promo_size - promo_heap_delta; 650 } else { 651 // EXPERIMENTAL ADJUSTMENT 652 // Only record that the estimator indicated such an action. 653 // *desired_promo_size_ptr = _promo_size + 654 // promo_increment_aligned_up(*desired_promo_size_ptr); 655 set_change_old_gen_for_maj_pauses(increase_old_gen_for_maj_pauses_true); 656 } 657 } 658 659 log_trace(gc, ergo)( 660 "PSAdaptiveSizePolicy::adjust_promo_for_pause_time " 661 "adjusting gen sizes for major pause (avg %f goal %f). " 662 "desired_promo_size " SIZE_FORMAT " promo delta " SIZE_FORMAT, 663 _avg_major_pause->average(), gc_pause_goal_sec(), 664 *desired_promo_size_ptr, promo_heap_delta); 665} 666 667void PSAdaptiveSizePolicy::adjust_eden_for_pause_time(bool is_full_gc, 668 size_t* desired_promo_size_ptr, 669 size_t* desired_eden_size_ptr) { 670 671 size_t eden_heap_delta = 0; 672 // Add some checks for a threshold for a change. For example, 673 // a change less than the required alignment is probably not worth 674 // attempting. 675 if (_avg_minor_pause->padded_average() > _avg_major_pause->padded_average()) { 676 adjust_eden_for_minor_pause_time(is_full_gc, desired_eden_size_ptr); 677 } 678 log_trace(gc, ergo)( 679 "PSAdaptiveSizePolicy::adjust_eden_for_pause_time " 680 "adjusting gen sizes for major pause (avg %f goal %f). " 681 "desired_eden_size " SIZE_FORMAT " eden delta " SIZE_FORMAT, 682 _avg_major_pause->average(), gc_pause_goal_sec(), 683 *desired_eden_size_ptr, eden_heap_delta); 684} 685 686void PSAdaptiveSizePolicy::adjust_promo_for_throughput(bool is_full_gc, 687 size_t* desired_promo_size_ptr) { 688 689 // Add some checks for a threshold for a change. For example, 690 // a change less than the required alignment is probably not worth 691 // attempting. 692 693 if ((gc_cost() + mutator_cost()) == 0.0) { 694 return; 695 } 696 697 log_trace(gc, ergo)("PSAdaptiveSizePolicy::adjust_promo_for_throughput(is_full: %d, promo: " SIZE_FORMAT "): mutator_cost %f major_gc_cost %f minor_gc_cost %f", 698 is_full_gc, *desired_promo_size_ptr, mutator_cost(), major_gc_cost(), minor_gc_cost()); 699 700 // Tenured generation 701 if (is_full_gc) { 702 // Calculate the change to use for the tenured gen. 703 size_t scaled_promo_heap_delta = 0; 704 // Can the increment to the generation be scaled? 705 if (gc_cost() >= 0.0 && major_gc_cost() >= 0.0) { 706 size_t promo_heap_delta = 707 promo_increment_with_supplement_aligned_up(*desired_promo_size_ptr); 708 double scale_by_ratio = major_gc_cost() / gc_cost(); 709 scaled_promo_heap_delta = 710 (size_t) (scale_by_ratio * (double) promo_heap_delta); 711 log_trace(gc, ergo)("Scaled tenured increment: " SIZE_FORMAT " by %f down to " SIZE_FORMAT, 712 promo_heap_delta, scale_by_ratio, scaled_promo_heap_delta); 713 } else if (major_gc_cost() >= 0.0) { 714 // Scaling is not going to work. If the major gc time is the 715 // larger, give it a full increment. 716 if (major_gc_cost() >= minor_gc_cost()) { 717 scaled_promo_heap_delta = 718 promo_increment_with_supplement_aligned_up(*desired_promo_size_ptr); 719 } 720 } else { 721 // Don't expect to get here but it's ok if it does 722 // in the product build since the delta will be 0 723 // and nothing will change. 724 assert(false, "Unexpected value for gc costs"); 725 } 726 727 switch (AdaptiveSizeThroughPutPolicy) { 728 case 1: 729 // Early in the run the statistics might not be good. Until 730 // a specific number of collections have been, use the heuristic 731 // that a larger generation size means lower collection costs. 732 if (major_collection_estimator()->increment_will_decrease() || 733 (_old_gen_change_for_major_throughput 734 <= AdaptiveSizePolicyInitializingSteps)) { 735 // Increase tenured generation size to reduce major collection cost 736 if ((*desired_promo_size_ptr + scaled_promo_heap_delta) > 737 *desired_promo_size_ptr) { 738 *desired_promo_size_ptr = _promo_size + scaled_promo_heap_delta; 739 } 740 set_change_old_gen_for_throughput( 741 increase_old_gen_for_throughput_true); 742 _old_gen_change_for_major_throughput++; 743 } else { 744 // EXPERIMENTAL ADJUSTMENT 745 // Record that decreasing the old gen size would decrease 746 // the major collection cost but don't do it. 747 // *desired_promo_size_ptr = _promo_size - 748 // promo_decrement_aligned_down(*desired_promo_size_ptr); 749 set_change_old_gen_for_throughput( 750 decrease_old_gen_for_throughput_true); 751 } 752 753 break; 754 default: 755 // Simplest strategy 756 if ((*desired_promo_size_ptr + scaled_promo_heap_delta) > 757 *desired_promo_size_ptr) { 758 *desired_promo_size_ptr = *desired_promo_size_ptr + 759 scaled_promo_heap_delta; 760 } 761 set_change_old_gen_for_throughput( 762 increase_old_gen_for_throughput_true); 763 _old_gen_change_for_major_throughput++; 764 } 765 766 log_trace(gc, ergo)("Adjusting tenured gen for throughput (avg %f goal %f). desired_promo_size " SIZE_FORMAT " promo_delta " SIZE_FORMAT , 767 mutator_cost(), 768 _throughput_goal, 769 *desired_promo_size_ptr, scaled_promo_heap_delta); 770 } 771} 772 773void PSAdaptiveSizePolicy::adjust_eden_for_throughput(bool is_full_gc, 774 size_t* desired_eden_size_ptr) { 775 776 // Add some checks for a threshold for a change. For example, 777 // a change less than the required alignment is probably not worth 778 // attempting. 779 780 if ((gc_cost() + mutator_cost()) == 0.0) { 781 return; 782 } 783 784 log_trace(gc, ergo)("PSAdaptiveSizePolicy::adjust_eden_for_throughput(is_full: %d, cur_eden: " SIZE_FORMAT "): mutator_cost %f major_gc_cost %f minor_gc_cost %f", 785 is_full_gc, *desired_eden_size_ptr, mutator_cost(), major_gc_cost(), minor_gc_cost()); 786 787 // Young generation 788 size_t scaled_eden_heap_delta = 0; 789 // Can the increment to the generation be scaled? 790 if (gc_cost() >= 0.0 && minor_gc_cost() >= 0.0) { 791 size_t eden_heap_delta = 792 eden_increment_with_supplement_aligned_up(*desired_eden_size_ptr); 793 double scale_by_ratio = minor_gc_cost() / gc_cost(); 794 assert(scale_by_ratio <= 1.0 && scale_by_ratio >= 0.0, "Scaling is wrong"); 795 scaled_eden_heap_delta = 796 (size_t) (scale_by_ratio * (double) eden_heap_delta); 797 log_trace(gc, ergo)("Scaled eden increment: " SIZE_FORMAT " by %f down to " SIZE_FORMAT, 798 eden_heap_delta, scale_by_ratio, scaled_eden_heap_delta); 799 } else if (minor_gc_cost() >= 0.0) { 800 // Scaling is not going to work. If the minor gc time is the 801 // larger, give it a full increment. 802 if (minor_gc_cost() > major_gc_cost()) { 803 scaled_eden_heap_delta = 804 eden_increment_with_supplement_aligned_up(*desired_eden_size_ptr); 805 } 806 } else { 807 // Don't expect to get here but it's ok if it does 808 // in the product build since the delta will be 0 809 // and nothing will change. 810 assert(false, "Unexpected value for gc costs"); 811 } 812 813 // Use a heuristic for some number of collections to give 814 // the averages time to settle down. 815 switch (AdaptiveSizeThroughPutPolicy) { 816 case 1: 817 if (minor_collection_estimator()->increment_will_decrease() || 818 (_young_gen_change_for_minor_throughput 819 <= AdaptiveSizePolicyInitializingSteps)) { 820 // Expand young generation size to reduce frequency of 821 // of collections. 822 if ((*desired_eden_size_ptr + scaled_eden_heap_delta) > 823 *desired_eden_size_ptr) { 824 *desired_eden_size_ptr = 825 *desired_eden_size_ptr + scaled_eden_heap_delta; 826 } 827 set_change_young_gen_for_throughput( 828 increase_young_gen_for_througput_true); 829 _young_gen_change_for_minor_throughput++; 830 } else { 831 // EXPERIMENTAL ADJUSTMENT 832 // Record that decreasing the young gen size would decrease 833 // the minor collection cost but don't do it. 834 // *desired_eden_size_ptr = _eden_size - 835 // eden_decrement_aligned_down(*desired_eden_size_ptr); 836 set_change_young_gen_for_throughput( 837 decrease_young_gen_for_througput_true); 838 } 839 break; 840 default: 841 if ((*desired_eden_size_ptr + scaled_eden_heap_delta) > 842 *desired_eden_size_ptr) { 843 *desired_eden_size_ptr = 844 *desired_eden_size_ptr + scaled_eden_heap_delta; 845 } 846 set_change_young_gen_for_throughput( 847 increase_young_gen_for_througput_true); 848 _young_gen_change_for_minor_throughput++; 849 } 850 851 log_trace(gc, ergo)("Adjusting eden for throughput (avg %f goal %f). desired_eden_size " SIZE_FORMAT " eden delta " SIZE_FORMAT, 852 mutator_cost(), _throughput_goal, *desired_eden_size_ptr, scaled_eden_heap_delta); 853} 854 855size_t PSAdaptiveSizePolicy::adjust_promo_for_footprint( 856 size_t desired_promo_size, size_t desired_sum) { 857 assert(desired_promo_size <= desired_sum, "Inconsistent parameters"); 858 set_decrease_for_footprint(decrease_old_gen_for_footprint_true); 859 860 size_t change = promo_decrement(desired_promo_size); 861 change = scale_down(change, desired_promo_size, desired_sum); 862 863 size_t reduced_size = desired_promo_size - change; 864 865 log_trace(gc, ergo)( 866 "AdaptiveSizePolicy::adjust_promo_for_footprint " 867 "adjusting tenured gen for footprint. " 868 "starting promo size " SIZE_FORMAT 869 " reduced promo size " SIZE_FORMAT 870 " promo delta " SIZE_FORMAT, 871 desired_promo_size, reduced_size, change ); 872 873 assert(reduced_size <= desired_promo_size, "Inconsistent result"); 874 return reduced_size; 875} 876 877size_t PSAdaptiveSizePolicy::adjust_eden_for_footprint( 878 size_t desired_eden_size, size_t desired_sum) { 879 assert(desired_eden_size <= desired_sum, "Inconsistent parameters"); 880 set_decrease_for_footprint(decrease_young_gen_for_footprint_true); 881 882 size_t change = eden_decrement(desired_eden_size); 883 change = scale_down(change, desired_eden_size, desired_sum); 884 885 size_t reduced_size = desired_eden_size - change; 886 887 log_trace(gc, ergo)( 888 "AdaptiveSizePolicy::adjust_eden_for_footprint " 889 "adjusting eden for footprint. " 890 " starting eden size " SIZE_FORMAT 891 " reduced eden size " SIZE_FORMAT 892 " eden delta " SIZE_FORMAT, 893 desired_eden_size, reduced_size, change); 894 895 assert(reduced_size <= desired_eden_size, "Inconsistent result"); 896 return reduced_size; 897} 898 899// Scale down "change" by the factor 900// part / total 901// Don't align the results. 902 903size_t PSAdaptiveSizePolicy::scale_down(size_t change, 904 double part, 905 double total) { 906 assert(part <= total, "Inconsistent input"); 907 size_t reduced_change = change; 908 if (total > 0) { 909 double fraction = part / total; 910 reduced_change = (size_t) (fraction * (double) change); 911 } 912 assert(reduced_change <= change, "Inconsistent result"); 913 return reduced_change; 914} 915 916size_t PSAdaptiveSizePolicy::eden_increment(size_t cur_eden, 917 uint percent_change) { 918 size_t eden_heap_delta; 919 eden_heap_delta = cur_eden / 100 * percent_change; 920 return eden_heap_delta; 921} 922 923size_t PSAdaptiveSizePolicy::eden_increment(size_t cur_eden) { 924 return eden_increment(cur_eden, YoungGenerationSizeIncrement); 925} 926 927size_t PSAdaptiveSizePolicy::eden_increment_aligned_up(size_t cur_eden) { 928 size_t result = eden_increment(cur_eden, YoungGenerationSizeIncrement); 929 return align_size_up(result, _space_alignment); 930} 931 932size_t PSAdaptiveSizePolicy::eden_increment_aligned_down(size_t cur_eden) { 933 size_t result = eden_increment(cur_eden); 934 return align_size_down(result, _space_alignment); 935} 936 937size_t PSAdaptiveSizePolicy::eden_increment_with_supplement_aligned_up( 938 size_t cur_eden) { 939 size_t result = eden_increment(cur_eden, 940 YoungGenerationSizeIncrement + _young_gen_size_increment_supplement); 941 return align_size_up(result, _space_alignment); 942} 943 944size_t PSAdaptiveSizePolicy::eden_decrement_aligned_down(size_t cur_eden) { 945 size_t eden_heap_delta = eden_decrement(cur_eden); 946 return align_size_down(eden_heap_delta, _space_alignment); 947} 948 949size_t PSAdaptiveSizePolicy::eden_decrement(size_t cur_eden) { 950 size_t eden_heap_delta = eden_increment(cur_eden) / 951 AdaptiveSizeDecrementScaleFactor; 952 return eden_heap_delta; 953} 954 955size_t PSAdaptiveSizePolicy::promo_increment(size_t cur_promo, 956 uint percent_change) { 957 size_t promo_heap_delta; 958 promo_heap_delta = cur_promo / 100 * percent_change; 959 return promo_heap_delta; 960} 961 962size_t PSAdaptiveSizePolicy::promo_increment(size_t cur_promo) { 963 return promo_increment(cur_promo, TenuredGenerationSizeIncrement); 964} 965 966size_t PSAdaptiveSizePolicy::promo_increment_aligned_up(size_t cur_promo) { 967 size_t result = promo_increment(cur_promo, TenuredGenerationSizeIncrement); 968 return align_size_up(result, _space_alignment); 969} 970 971size_t PSAdaptiveSizePolicy::promo_increment_aligned_down(size_t cur_promo) { 972 size_t result = promo_increment(cur_promo, TenuredGenerationSizeIncrement); 973 return align_size_down(result, _space_alignment); 974} 975 976size_t PSAdaptiveSizePolicy::promo_increment_with_supplement_aligned_up( 977 size_t cur_promo) { 978 size_t result = promo_increment(cur_promo, 979 TenuredGenerationSizeIncrement + _old_gen_size_increment_supplement); 980 return align_size_up(result, _space_alignment); 981} 982 983size_t PSAdaptiveSizePolicy::promo_decrement_aligned_down(size_t cur_promo) { 984 size_t promo_heap_delta = promo_decrement(cur_promo); 985 return align_size_down(promo_heap_delta, _space_alignment); 986} 987 988size_t PSAdaptiveSizePolicy::promo_decrement(size_t cur_promo) { 989 size_t promo_heap_delta = promo_increment(cur_promo); 990 promo_heap_delta = promo_heap_delta / AdaptiveSizeDecrementScaleFactor; 991 return promo_heap_delta; 992} 993 994uint PSAdaptiveSizePolicy::compute_survivor_space_size_and_threshold( 995 bool is_survivor_overflow, 996 uint tenuring_threshold, 997 size_t survivor_limit) { 998 assert(survivor_limit >= _space_alignment, 999 "survivor_limit too small"); 1000 assert((size_t)align_size_down(survivor_limit, _space_alignment) 1001 == survivor_limit, "survivor_limit not aligned"); 1002 1003 // This method is called even if the tenuring threshold and survivor 1004 // spaces are not adjusted so that the averages are sampled above. 1005 if (!UsePSAdaptiveSurvivorSizePolicy || 1006 !young_gen_policy_is_ready()) { 1007 return tenuring_threshold; 1008 } 1009 1010 // We'll decide whether to increase or decrease the tenuring 1011 // threshold based partly on the newly computed survivor size 1012 // (if we hit the maximum limit allowed, we'll always choose to 1013 // decrement the threshold). 1014 bool incr_tenuring_threshold = false; 1015 bool decr_tenuring_threshold = false; 1016 1017 set_decrement_tenuring_threshold_for_gc_cost(false); 1018 set_increment_tenuring_threshold_for_gc_cost(false); 1019 set_decrement_tenuring_threshold_for_survivor_limit(false); 1020 1021 if (!is_survivor_overflow) { 1022 // Keep running averages on how much survived 1023 1024 // We use the tenuring threshold to equalize the cost of major 1025 // and minor collections. 1026 // ThresholdTolerance is used to indicate how sensitive the 1027 // tenuring threshold is to differences in cost between the 1028 // collection types. 1029 1030 // Get the times of interest. This involves a little work, so 1031 // we cache the values here. 1032 const double major_cost = major_gc_cost(); 1033 const double minor_cost = minor_gc_cost(); 1034 1035 if (minor_cost > major_cost * _threshold_tolerance_percent) { 1036 // Minor times are getting too long; lower the threshold so 1037 // less survives and more is promoted. 1038 decr_tenuring_threshold = true; 1039 set_decrement_tenuring_threshold_for_gc_cost(true); 1040 } else if (major_cost > minor_cost * _threshold_tolerance_percent) { 1041 // Major times are too long, so we want less promotion. 1042 incr_tenuring_threshold = true; 1043 set_increment_tenuring_threshold_for_gc_cost(true); 1044 } 1045 1046 } else { 1047 // Survivor space overflow occurred, so promoted and survived are 1048 // not accurate. We'll make our best guess by combining survived 1049 // and promoted and count them as survivors. 1050 // 1051 // We'll lower the tenuring threshold to see if we can correct 1052 // things. Also, set the survivor size conservatively. We're 1053 // trying to avoid many overflows from occurring if defnew size 1054 // is just too small. 1055 1056 decr_tenuring_threshold = true; 1057 } 1058 1059 // The padded average also maintains a deviation from the average; 1060 // we use this to see how good of an estimate we have of what survived. 1061 // We're trying to pad the survivor size as little as possible without 1062 // overflowing the survivor spaces. 1063 size_t target_size = align_size_up((size_t)_avg_survived->padded_average(), 1064 _space_alignment); 1065 target_size = MAX2(target_size, _space_alignment); 1066 1067 if (target_size > survivor_limit) { 1068 // Target size is bigger than we can handle. Let's also reduce 1069 // the tenuring threshold. 1070 target_size = survivor_limit; 1071 decr_tenuring_threshold = true; 1072 set_decrement_tenuring_threshold_for_survivor_limit(true); 1073 } 1074 1075 // Finally, increment or decrement the tenuring threshold, as decided above. 1076 // We test for decrementing first, as we might have hit the target size 1077 // limit. 1078 if (decr_tenuring_threshold && !(AlwaysTenure || NeverTenure)) { 1079 if (tenuring_threshold > 1) { 1080 tenuring_threshold--; 1081 } 1082 } else if (incr_tenuring_threshold && !(AlwaysTenure || NeverTenure)) { 1083 if (tenuring_threshold < MaxTenuringThreshold) { 1084 tenuring_threshold++; 1085 } 1086 } 1087 1088 // We keep a running average of the amount promoted which is used 1089 // to decide when we should collect the old generation (when 1090 // the amount of old gen free space is less than what we expect to 1091 // promote). 1092 1093 log_trace(gc, ergo)("avg_survived: %f avg_deviation: %f", _avg_survived->average(), _avg_survived->deviation()); 1094 log_debug(gc, ergo)("avg_survived_padded_avg: %f", _avg_survived->padded_average()); 1095 1096 log_trace(gc, ergo)("avg_promoted_avg: %f avg_promoted_dev: %f", avg_promoted()->average(), avg_promoted()->deviation()); 1097 log_debug(gc, ergo)("avg_promoted_padded_avg: %f avg_pretenured_padded_avg: %f tenuring_thresh: %d target_size: " SIZE_FORMAT, 1098 avg_promoted()->padded_average(), 1099 _avg_pretenured->padded_average(), 1100 tenuring_threshold, target_size); 1101 1102 set_survivor_size(target_size); 1103 1104 return tenuring_threshold; 1105} 1106 1107void PSAdaptiveSizePolicy::update_averages(bool is_survivor_overflow, 1108 size_t survived, 1109 size_t promoted) { 1110 // Update averages 1111 if (!is_survivor_overflow) { 1112 // Keep running averages on how much survived 1113 _avg_survived->sample(survived); 1114 } else { 1115 size_t survived_guess = survived + promoted; 1116 _avg_survived->sample(survived_guess); 1117 } 1118 avg_promoted()->sample(promoted); 1119 1120 log_trace(gc, ergo)("AdaptiveSizePolicy::update_averages: survived: " SIZE_FORMAT " promoted: " SIZE_FORMAT " overflow: %s", 1121 survived, promoted, is_survivor_overflow ? "true" : "false"); 1122} 1123 1124bool PSAdaptiveSizePolicy::print() const { 1125 1126 if (!UseAdaptiveSizePolicy) { 1127 return false; 1128 } 1129 1130 if (AdaptiveSizePolicy::print()) { 1131 AdaptiveSizePolicy::print_tenuring_threshold(PSScavenge::tenuring_threshold()); 1132 return true; 1133 } 1134 1135 return false; 1136} 1137 1138#ifndef PRODUCT 1139 1140void TestOldFreeSpaceCalculation_test() { 1141 assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(100, 20) == 25, "Calculation of free memory failed"); 1142 assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(100, 50) == 100, "Calculation of free memory failed"); 1143 assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(100, 60) == 150, "Calculation of free memory failed"); 1144 assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(100, 75) == 300, "Calculation of free memory failed"); 1145 assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(400, 20) == 100, "Calculation of free memory failed"); 1146 assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(400, 50) == 400, "Calculation of free memory failed"); 1147 assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(400, 60) == 600, "Calculation of free memory failed"); 1148 assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(400, 75) == 1200, "Calculation of free memory failed"); 1149} 1150 1151#endif /* !PRODUCT */ 1152