src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.cpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.cpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,1344 @@
     1.4 +/*
     1.5 + * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#include "precompiled.hpp"
    1.29 +#include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
    1.30 +#include "gc_implementation/parallelScavenge/psAdaptiveSizePolicy.hpp"
    1.31 +#include "gc_implementation/parallelScavenge/psGCAdaptivePolicyCounters.hpp"
    1.32 +#include "gc_implementation/parallelScavenge/psScavenge.hpp"
    1.33 +#include "gc_implementation/shared/gcPolicyCounters.hpp"
    1.34 +#include "gc_interface/gcCause.hpp"
    1.35 +#include "memory/collectorPolicy.hpp"
    1.36 +#include "runtime/timer.hpp"
    1.37 +#include "utilities/top.hpp"
    1.38 +
    1.39 +#include <math.h>
    1.40 +
    1.41 +PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
    1.42 +
    1.43 +PSAdaptiveSizePolicy::PSAdaptiveSizePolicy(size_t init_eden_size,
    1.44 +                                           size_t init_promo_size,
    1.45 +                                           size_t init_survivor_size,
    1.46 +                                           size_t space_alignment,
    1.47 +                                           double gc_pause_goal_sec,
    1.48 +                                           double gc_minor_pause_goal_sec,
    1.49 +                                           uint gc_cost_ratio) :
    1.50 +     AdaptiveSizePolicy(init_eden_size,
    1.51 +                        init_promo_size,
    1.52 +                        init_survivor_size,
    1.53 +                        gc_pause_goal_sec,
    1.54 +                        gc_cost_ratio),
    1.55 +     _collection_cost_margin_fraction(AdaptiveSizePolicyCollectionCostMargin / 100.0),
    1.56 +     _space_alignment(space_alignment),
    1.57 +     _live_at_last_full_gc(init_promo_size),
    1.58 +     _gc_minor_pause_goal_sec(gc_minor_pause_goal_sec),
    1.59 +     _latest_major_mutator_interval_seconds(0),
    1.60 +     _young_gen_change_for_major_pause_count(0)
    1.61 +{
    1.62 +  // Sizing policy statistics
    1.63 +  _avg_major_pause    =
    1.64 +    new AdaptivePaddedAverage(AdaptiveTimeWeight, PausePadding);
    1.65 +  _avg_minor_interval = new AdaptiveWeightedAverage(AdaptiveTimeWeight);
    1.66 +  _avg_major_interval = new AdaptiveWeightedAverage(AdaptiveTimeWeight);
    1.67 +
    1.68 +  _avg_base_footprint = new AdaptiveWeightedAverage(AdaptiveSizePolicyWeight);
    1.69 +  _major_pause_old_estimator =
    1.70 +    new LinearLeastSquareFit(AdaptiveSizePolicyWeight);
    1.71 +  _major_pause_young_estimator =
    1.72 +    new LinearLeastSquareFit(AdaptiveSizePolicyWeight);
    1.73 +  _major_collection_estimator =
    1.74 +    new LinearLeastSquareFit(AdaptiveSizePolicyWeight);
    1.75 +
    1.76 +  _young_gen_size_increment_supplement = YoungGenerationSizeSupplement;
    1.77 +  _old_gen_size_increment_supplement = TenuredGenerationSizeSupplement;
    1.78 +
    1.79 +  // Start the timers
    1.80 +  _major_timer.start();
    1.81 +
    1.82 +  _old_gen_policy_is_ready = false;
    1.83 +}
    1.84 +
    1.85 +size_t PSAdaptiveSizePolicy::calculate_free_based_on_live(size_t live, uintx ratio_as_percentage) {
    1.86 +  // We want to calculate how much free memory there can be based on the
    1.87 +  // amount of live data currently in the old gen. Using the formula:
    1.88 +  // ratio * (free + live) = free
    1.89 +  // Some equation solving later we get:
    1.90 +  // free = (live * ratio) / (1 - ratio)
    1.91 +
    1.92 +  const double ratio = ratio_as_percentage / 100.0;
    1.93 +  const double ratio_inverse = 1.0 - ratio;
    1.94 +  const double tmp = live * ratio;
    1.95 +  size_t free = (size_t)(tmp / ratio_inverse);
    1.96 +
    1.97 +  return free;
    1.98 +}
    1.99 +
   1.100 +size_t PSAdaptiveSizePolicy::calculated_old_free_size_in_bytes() const {
   1.101 +  size_t free_size = (size_t)(_promo_size + avg_promoted()->padded_average());
   1.102 +  size_t live = ParallelScavengeHeap::heap()->old_gen()->used_in_bytes();
   1.103 +
   1.104 +  if (MinHeapFreeRatio != 0) {
   1.105 +    size_t min_free = calculate_free_based_on_live(live, MinHeapFreeRatio);
   1.106 +    free_size = MAX2(free_size, min_free);
   1.107 +  }
   1.108 +
   1.109 +  if (MaxHeapFreeRatio != 100) {
   1.110 +    size_t max_free = calculate_free_based_on_live(live, MaxHeapFreeRatio);
   1.111 +    free_size = MIN2(max_free, free_size);
   1.112 +  }
   1.113 +
   1.114 +  return free_size;
   1.115 +}
   1.116 +
   1.117 +void PSAdaptiveSizePolicy::major_collection_begin() {
   1.118 +  // Update the interval time
   1.119 +  _major_timer.stop();
   1.120 +  // Save most recent collection time
   1.121 +  _latest_major_mutator_interval_seconds = _major_timer.seconds();
   1.122 +  _major_timer.reset();
   1.123 +  _major_timer.start();
   1.124 +}
   1.125 +
   1.126 +void PSAdaptiveSizePolicy::update_minor_pause_old_estimator(
   1.127 +    double minor_pause_in_ms) {
   1.128 +  double promo_size_in_mbytes = ((double)_promo_size)/((double)M);
   1.129 +  _minor_pause_old_estimator->update(promo_size_in_mbytes,
   1.130 +    minor_pause_in_ms);
   1.131 +}
   1.132 +
   1.133 +void PSAdaptiveSizePolicy::major_collection_end(size_t amount_live,
   1.134 +  GCCause::Cause gc_cause) {
   1.135 +  // Update the pause time.
   1.136 +  _major_timer.stop();
   1.137 +
   1.138 +  if (gc_cause != GCCause::_java_lang_system_gc ||
   1.139 +      UseAdaptiveSizePolicyWithSystemGC) {
   1.140 +    double major_pause_in_seconds = _major_timer.seconds();
   1.141 +    double major_pause_in_ms = major_pause_in_seconds * MILLIUNITS;
   1.142 +
   1.143 +    // Sample for performance counter
   1.144 +    _avg_major_pause->sample(major_pause_in_seconds);
   1.145 +
   1.146 +    // Cost of collection (unit-less)
   1.147 +    double collection_cost = 0.0;
   1.148 +    if ((_latest_major_mutator_interval_seconds > 0.0) &&
   1.149 +        (major_pause_in_seconds > 0.0)) {
   1.150 +      double interval_in_seconds =
   1.151 +        _latest_major_mutator_interval_seconds + major_pause_in_seconds;
   1.152 +      collection_cost =
   1.153 +        major_pause_in_seconds / interval_in_seconds;
   1.154 +      avg_major_gc_cost()->sample(collection_cost);
   1.155 +
   1.156 +      // Sample for performance counter
   1.157 +      _avg_major_interval->sample(interval_in_seconds);
   1.158 +    }
   1.159 +
   1.160 +    // Calculate variables used to estimate pause time vs. gen sizes
   1.161 +    double eden_size_in_mbytes = ((double)_eden_size)/((double)M);
   1.162 +    double promo_size_in_mbytes = ((double)_promo_size)/((double)M);
   1.163 +    _major_pause_old_estimator->update(promo_size_in_mbytes,
   1.164 +      major_pause_in_ms);
   1.165 +    _major_pause_young_estimator->update(eden_size_in_mbytes,
   1.166 +      major_pause_in_ms);
   1.167 +
   1.168 +    if (PrintAdaptiveSizePolicy && Verbose) {
   1.169 +      gclog_or_tty->print("psAdaptiveSizePolicy::major_collection_end: "
   1.170 +        "major gc cost: %f  average: %f", collection_cost,
   1.171 +        avg_major_gc_cost()->average());
   1.172 +      gclog_or_tty->print_cr("  major pause: %f major period %f",
   1.173 +        major_pause_in_ms,
   1.174 +        _latest_major_mutator_interval_seconds * MILLIUNITS);
   1.175 +    }
   1.176 +
   1.177 +    // Calculate variable used to estimate collection cost vs. gen sizes
   1.178 +    assert(collection_cost >= 0.0, "Expected to be non-negative");
   1.179 +    _major_collection_estimator->update(promo_size_in_mbytes,
   1.180 +        collection_cost);
   1.181 +  }
   1.182 +
   1.183 +  // Update the amount live at the end of a full GC
   1.184 +  _live_at_last_full_gc = amount_live;
   1.185 +
   1.186 +  // The policy does not have enough data until at least some major collections
   1.187 +  // have been done.
   1.188 +  if (_avg_major_pause->count() >= AdaptiveSizePolicyReadyThreshold) {
   1.189 +    _old_gen_policy_is_ready = true;
   1.190 +  }
   1.191 +
   1.192 +  // Interval times use this timer to measure the interval that
   1.193 +  // the mutator runs.  Reset after the GC pause has been measured.
   1.194 +  _major_timer.reset();
   1.195 +  _major_timer.start();
   1.196 +}
   1.197 +
   1.198 +// If the remaining free space in the old generation is less that
   1.199 +// that expected to be needed by the next collection, do a full
   1.200 +// collection now.
   1.201 +bool PSAdaptiveSizePolicy::should_full_GC(size_t old_free_in_bytes) {
   1.202 +
   1.203 +  // A similar test is done in the scavenge's should_attempt_scavenge().  If
   1.204 +  // this is changed, decide if that test should also be changed.
   1.205 +  bool result = padded_average_promoted_in_bytes() > (float) old_free_in_bytes;
   1.206 +  if (PrintGCDetails && Verbose) {
   1.207 +    if (result) {
   1.208 +      gclog_or_tty->print("  full after scavenge: ");
   1.209 +    } else {
   1.210 +      gclog_or_tty->print("  no full after scavenge: ");
   1.211 +    }
   1.212 +    gclog_or_tty->print_cr(" average_promoted " SIZE_FORMAT
   1.213 +      " padded_average_promoted " SIZE_FORMAT
   1.214 +      " free in old gen " SIZE_FORMAT,
   1.215 +      (size_t) average_promoted_in_bytes(),
   1.216 +      (size_t) padded_average_promoted_in_bytes(),
   1.217 +      old_free_in_bytes);
   1.218 +  }
   1.219 +  return result;
   1.220 +}
   1.221 +
   1.222 +void PSAdaptiveSizePolicy::clear_generation_free_space_flags() {
   1.223 +
   1.224 +  AdaptiveSizePolicy::clear_generation_free_space_flags();
   1.225 +
   1.226 +  set_change_old_gen_for_min_pauses(0);
   1.227 +
   1.228 +  set_change_young_gen_for_maj_pauses(0);
   1.229 +}
   1.230 +
   1.231 +// If this is not a full GC, only test and modify the young generation.
   1.232 +
   1.233 +void PSAdaptiveSizePolicy::compute_generations_free_space(
   1.234 +                                           size_t young_live,
   1.235 +                                           size_t eden_live,
   1.236 +                                           size_t old_live,
   1.237 +                                           size_t cur_eden,
   1.238 +                                           size_t max_old_gen_size,
   1.239 +                                           size_t max_eden_size,
   1.240 +                                           bool   is_full_gc) {
   1.241 +  compute_eden_space_size(young_live,
   1.242 +                          eden_live,
   1.243 +                          cur_eden,
   1.244 +                          max_eden_size,
   1.245 +                          is_full_gc);
   1.246 +
   1.247 +  compute_old_gen_free_space(old_live,
   1.248 +                             cur_eden,
   1.249 +                             max_old_gen_size,
   1.250 +                             is_full_gc);
   1.251 +}
   1.252 +
   1.253 +void PSAdaptiveSizePolicy::compute_eden_space_size(
   1.254 +                                           size_t young_live,
   1.255 +                                           size_t eden_live,
   1.256 +                                           size_t cur_eden,
   1.257 +                                           size_t max_eden_size,
   1.258 +                                           bool   is_full_gc) {
   1.259 +
   1.260 +  // Update statistics
   1.261 +  // Time statistics are updated as we go, update footprint stats here
   1.262 +  _avg_base_footprint->sample(BaseFootPrintEstimate);
   1.263 +  avg_young_live()->sample(young_live);
   1.264 +  avg_eden_live()->sample(eden_live);
   1.265 +
   1.266 +  // This code used to return if the policy was not ready , i.e.,
   1.267 +  // policy_is_ready() returning false.  The intent was that
   1.268 +  // decisions below needed major collection times and so could
   1.269 +  // not be made before two major collections.  A consequence was
   1.270 +  // adjustments to the young generation were not done until after
   1.271 +  // two major collections even if the minor collections times
   1.272 +  // exceeded the requested goals.  Now let the young generation
   1.273 +  // adjust for the minor collection times.  Major collection times
   1.274 +  // will be zero for the first collection and will naturally be
   1.275 +  // ignored.  Tenured generation adjustments are only made at the
   1.276 +  // full collections so until the second major collection has
   1.277 +  // been reached, no tenured generation adjustments will be made.
   1.278 +
   1.279 +  // Until we know better, desired promotion size uses the last calculation
   1.280 +  size_t desired_promo_size = _promo_size;
   1.281 +
   1.282 +  // Start eden at the current value.  The desired value that is stored
   1.283 +  // in _eden_size is not bounded by constraints of the heap and can
   1.284 +  // run away.
   1.285 +  //
   1.286 +  // As expected setting desired_eden_size to the current
   1.287 +  // value of desired_eden_size as a starting point
   1.288 +  // caused desired_eden_size to grow way too large and caused
   1.289 +  // an overflow down stream.  It may have improved performance in
   1.290 +  // some case but is dangerous.
   1.291 +  size_t desired_eden_size = cur_eden;
   1.292 +
   1.293 +  // Cache some values. There's a bit of work getting these, so
   1.294 +  // we might save a little time.
   1.295 +  const double major_cost = major_gc_cost();
   1.296 +  const double minor_cost = minor_gc_cost();
   1.297 +
   1.298 +  // This method sets the desired eden size.  That plus the
   1.299 +  // desired survivor space sizes sets the desired young generation
   1.300 +  // size.  This methods does not know what the desired survivor
   1.301 +  // size is but expects that other policy will attempt to make
   1.302 +  // the survivor sizes compatible with the live data in the
   1.303 +  // young generation.  This limit is an estimate of the space left
   1.304 +  // in the young generation after the survivor spaces have been
   1.305 +  // subtracted out.
   1.306 +  size_t eden_limit = max_eden_size;
   1.307 +
   1.308 +  const double gc_cost_limit = GCTimeLimit/100.0;
   1.309 +
   1.310 +  // Which way should we go?
   1.311 +  // if pause requirement is not met
   1.312 +  //   adjust size of any generation with average paus exceeding
   1.313 +  //   the pause limit.  Adjust one pause at a time (the larger)
   1.314 +  //   and only make adjustments for the major pause at full collections.
   1.315 +  // else if throughput requirement not met
   1.316 +  //   adjust the size of the generation with larger gc time.  Only
   1.317 +  //   adjust one generation at a time.
   1.318 +  // else
   1.319 +  //   adjust down the total heap size.  Adjust down the larger of the
   1.320 +  //   generations.
   1.321 +
   1.322 +  // Add some checks for a threshold for a change.  For example,
   1.323 +  // a change less than the necessary alignment is probably not worth
   1.324 +  // attempting.
   1.325 +
   1.326 +
   1.327 +  if ((_avg_minor_pause->padded_average() > gc_pause_goal_sec()) ||
   1.328 +      (_avg_major_pause->padded_average() > gc_pause_goal_sec())) {
   1.329 +    //
   1.330 +    // Check pauses
   1.331 +    //
   1.332 +    // Make changes only to affect one of the pauses (the larger)
   1.333 +    // at a time.
   1.334 +    adjust_eden_for_pause_time(is_full_gc, &desired_promo_size, &desired_eden_size);
   1.335 +
   1.336 +  } else if (_avg_minor_pause->padded_average() > gc_minor_pause_goal_sec()) {
   1.337 +    // Adjust only for the minor pause time goal
   1.338 +    adjust_eden_for_minor_pause_time(is_full_gc, &desired_eden_size);
   1.339 +
   1.340 +  } else if(adjusted_mutator_cost() < _throughput_goal) {
   1.341 +    // This branch used to require that (mutator_cost() > 0.0 in 1.4.2.
   1.342 +    // This sometimes resulted in skipping to the minimize footprint
   1.343 +    // code.  Change this to try and reduce GC time if mutator time is
   1.344 +    // negative for whatever reason.  Or for future consideration,
   1.345 +    // bail out of the code if mutator time is negative.
   1.346 +    //
   1.347 +    // Throughput
   1.348 +    //
   1.349 +    assert(major_cost >= 0.0, "major cost is < 0.0");
   1.350 +    assert(minor_cost >= 0.0, "minor cost is < 0.0");
   1.351 +    // Try to reduce the GC times.
   1.352 +    adjust_eden_for_throughput(is_full_gc, &desired_eden_size);
   1.353 +
   1.354 +  } else {
   1.355 +
   1.356 +    // Be conservative about reducing the footprint.
   1.357 +    //   Do a minimum number of major collections first.
   1.358 +    //   Have reasonable averages for major and minor collections costs.
   1.359 +    if (UseAdaptiveSizePolicyFootprintGoal &&
   1.360 +        young_gen_policy_is_ready() &&
   1.361 +        avg_major_gc_cost()->average() >= 0.0 &&
   1.362 +        avg_minor_gc_cost()->average() >= 0.0) {
   1.363 +      size_t desired_sum = desired_eden_size + desired_promo_size;
   1.364 +      desired_eden_size = adjust_eden_for_footprint(desired_eden_size, desired_sum);
   1.365 +    }
   1.366 +  }
   1.367 +
   1.368 +  // Note we make the same tests as in the code block below;  the code
   1.369 +  // seems a little easier to read with the printing in another block.
   1.370 +  if (PrintAdaptiveSizePolicy) {
   1.371 +    if (desired_eden_size > eden_limit) {
   1.372 +      gclog_or_tty->print_cr(
   1.373 +            "PSAdaptiveSizePolicy::compute_eden_space_size limits:"
   1.374 +            " desired_eden_size: " SIZE_FORMAT
   1.375 +            " old_eden_size: " SIZE_FORMAT
   1.376 +            " eden_limit: " SIZE_FORMAT
   1.377 +            " cur_eden: " SIZE_FORMAT
   1.378 +            " max_eden_size: " SIZE_FORMAT
   1.379 +            " avg_young_live: " SIZE_FORMAT,
   1.380 +            desired_eden_size, _eden_size, eden_limit, cur_eden,
   1.381 +            max_eden_size, (size_t)avg_young_live()->average());
   1.382 +    }
   1.383 +    if (gc_cost() > gc_cost_limit) {
   1.384 +      gclog_or_tty->print_cr(
   1.385 +            "PSAdaptiveSizePolicy::compute_eden_space_size: gc time limit"
   1.386 +            " gc_cost: %f "
   1.387 +            " GCTimeLimit: %d",
   1.388 +            gc_cost(), GCTimeLimit);
   1.389 +    }
   1.390 +  }
   1.391 +
   1.392 +  // Align everything and make a final limit check
   1.393 +  desired_eden_size  = align_size_up(desired_eden_size, _space_alignment);
   1.394 +  desired_eden_size  = MAX2(desired_eden_size, _space_alignment);
   1.395 +
   1.396 +  eden_limit  = align_size_down(eden_limit, _space_alignment);
   1.397 +
   1.398 +  // And one last limit check, now that we've aligned things.
   1.399 +  if (desired_eden_size > eden_limit) {
   1.400 +    // If the policy says to get a larger eden but
   1.401 +    // is hitting the limit, don't decrease eden.
   1.402 +    // This can lead to a general drifting down of the
   1.403 +    // eden size.  Let the tenuring calculation push more
   1.404 +    // into the old gen.
   1.405 +    desired_eden_size = MAX2(eden_limit, cur_eden);
   1.406 +  }
   1.407 +
   1.408 +  if (PrintAdaptiveSizePolicy) {
   1.409 +    // Timing stats
   1.410 +    gclog_or_tty->print(
   1.411 +               "PSAdaptiveSizePolicy::compute_eden_space_size: costs"
   1.412 +               " minor_time: %f"
   1.413 +               " major_cost: %f"
   1.414 +               " mutator_cost: %f"
   1.415 +               " throughput_goal: %f",
   1.416 +               minor_gc_cost(), major_gc_cost(), mutator_cost(),
   1.417 +               _throughput_goal);
   1.418 +
   1.419 +    // We give more details if Verbose is set
   1.420 +    if (Verbose) {
   1.421 +      gclog_or_tty->print( " minor_pause: %f"
   1.422 +                  " major_pause: %f"
   1.423 +                  " minor_interval: %f"
   1.424 +                  " major_interval: %f"
   1.425 +                  " pause_goal: %f",
   1.426 +                  _avg_minor_pause->padded_average(),
   1.427 +                  _avg_major_pause->padded_average(),
   1.428 +                  _avg_minor_interval->average(),
   1.429 +                  _avg_major_interval->average(),
   1.430 +                  gc_pause_goal_sec());
   1.431 +    }
   1.432 +
   1.433 +    // Footprint stats
   1.434 +    gclog_or_tty->print( " live_space: " SIZE_FORMAT
   1.435 +                " free_space: " SIZE_FORMAT,
   1.436 +                live_space(), free_space());
   1.437 +    // More detail
   1.438 +    if (Verbose) {
   1.439 +      gclog_or_tty->print( " base_footprint: " SIZE_FORMAT
   1.440 +                  " avg_young_live: " SIZE_FORMAT
   1.441 +                  " avg_old_live: " SIZE_FORMAT,
   1.442 +                  (size_t)_avg_base_footprint->average(),
   1.443 +                  (size_t)avg_young_live()->average(),
   1.444 +                  (size_t)avg_old_live()->average());
   1.445 +    }
   1.446 +
   1.447 +    // And finally, our old and new sizes.
   1.448 +    gclog_or_tty->print(" old_eden_size: " SIZE_FORMAT
   1.449 +               " desired_eden_size: " SIZE_FORMAT,
   1.450 +               _eden_size, desired_eden_size);
   1.451 +    gclog_or_tty->cr();
   1.452 +  }
   1.453 +
   1.454 +  set_eden_size(desired_eden_size);
   1.455 +}
   1.456 +
   1.457 +void PSAdaptiveSizePolicy::compute_old_gen_free_space(
   1.458 +                                           size_t old_live,
   1.459 +                                           size_t cur_eden,
   1.460 +                                           size_t max_old_gen_size,
   1.461 +                                           bool   is_full_gc) {
   1.462 +
   1.463 +  // Update statistics
   1.464 +  // Time statistics are updated as we go, update footprint stats here
   1.465 +  if (is_full_gc) {
   1.466 +    // old_live is only accurate after a full gc
   1.467 +    avg_old_live()->sample(old_live);
   1.468 +  }
   1.469 +
   1.470 +  // This code used to return if the policy was not ready , i.e.,
   1.471 +  // policy_is_ready() returning false.  The intent was that
   1.472 +  // decisions below needed major collection times and so could
   1.473 +  // not be made before two major collections.  A consequence was
   1.474 +  // adjustments to the young generation were not done until after
   1.475 +  // two major collections even if the minor collections times
   1.476 +  // exceeded the requested goals.  Now let the young generation
   1.477 +  // adjust for the minor collection times.  Major collection times
   1.478 +  // will be zero for the first collection and will naturally be
   1.479 +  // ignored.  Tenured generation adjustments are only made at the
   1.480 +  // full collections so until the second major collection has
   1.481 +  // been reached, no tenured generation adjustments will be made.
   1.482 +
   1.483 +  // Until we know better, desired promotion size uses the last calculation
   1.484 +  size_t desired_promo_size = _promo_size;
   1.485 +
   1.486 +  // Start eden at the current value.  The desired value that is stored
   1.487 +  // in _eden_size is not bounded by constraints of the heap and can
   1.488 +  // run away.
   1.489 +  //
   1.490 +  // As expected setting desired_eden_size to the current
   1.491 +  // value of desired_eden_size as a starting point
   1.492 +  // caused desired_eden_size to grow way too large and caused
   1.493 +  // an overflow down stream.  It may have improved performance in
   1.494 +  // some case but is dangerous.
   1.495 +  size_t desired_eden_size = cur_eden;
   1.496 +
   1.497 +  // Cache some values. There's a bit of work getting these, so
   1.498 +  // we might save a little time.
   1.499 +  const double major_cost = major_gc_cost();
   1.500 +  const double minor_cost = minor_gc_cost();
   1.501 +
   1.502 +  // Limits on our growth
   1.503 +  size_t promo_limit = (size_t)(max_old_gen_size - avg_old_live()->average());
   1.504 +
   1.505 +  // But don't force a promo size below the current promo size. Otherwise,
   1.506 +  // the promo size will shrink for no good reason.
   1.507 +  promo_limit = MAX2(promo_limit, _promo_size);
   1.508 +
   1.509 +  const double gc_cost_limit = GCTimeLimit/100.0;
   1.510 +
   1.511 +  // Which way should we go?
   1.512 +  // if pause requirement is not met
   1.513 +  //   adjust size of any generation with average paus exceeding
   1.514 +  //   the pause limit.  Adjust one pause at a time (the larger)
   1.515 +  //   and only make adjustments for the major pause at full collections.
   1.516 +  // else if throughput requirement not met
   1.517 +  //   adjust the size of the generation with larger gc time.  Only
   1.518 +  //   adjust one generation at a time.
   1.519 +  // else
   1.520 +  //   adjust down the total heap size.  Adjust down the larger of the
   1.521 +  //   generations.
   1.522 +
   1.523 +  // Add some checks for a threshhold for a change.  For example,
   1.524 +  // a change less than the necessary alignment is probably not worth
   1.525 +  // attempting.
   1.526 +
   1.527 +  if ((_avg_minor_pause->padded_average() > gc_pause_goal_sec()) ||
   1.528 +      (_avg_major_pause->padded_average() > gc_pause_goal_sec())) {
   1.529 +    //
   1.530 +    // Check pauses
   1.531 +    //
   1.532 +    // Make changes only to affect one of the pauses (the larger)
   1.533 +    // at a time.
   1.534 +    if (is_full_gc) {
   1.535 +      set_decide_at_full_gc(decide_at_full_gc_true);
   1.536 +      adjust_promo_for_pause_time(is_full_gc, &desired_promo_size, &desired_eden_size);
   1.537 +    }
   1.538 +  } else if (_avg_minor_pause->padded_average() > gc_minor_pause_goal_sec()) {
   1.539 +    // Adjust only for the minor pause time goal
   1.540 +    adjust_promo_for_minor_pause_time(is_full_gc, &desired_promo_size, &desired_eden_size);
   1.541 +  } else if(adjusted_mutator_cost() < _throughput_goal) {
   1.542 +    // This branch used to require that (mutator_cost() > 0.0 in 1.4.2.
   1.543 +    // This sometimes resulted in skipping to the minimize footprint
   1.544 +    // code.  Change this to try and reduce GC time if mutator time is
   1.545 +    // negative for whatever reason.  Or for future consideration,
   1.546 +    // bail out of the code if mutator time is negative.
   1.547 +    //
   1.548 +    // Throughput
   1.549 +    //
   1.550 +    assert(major_cost >= 0.0, "major cost is < 0.0");
   1.551 +    assert(minor_cost >= 0.0, "minor cost is < 0.0");
   1.552 +    // Try to reduce the GC times.
   1.553 +    if (is_full_gc) {
   1.554 +      set_decide_at_full_gc(decide_at_full_gc_true);
   1.555 +      adjust_promo_for_throughput(is_full_gc, &desired_promo_size);
   1.556 +    }
   1.557 +  } else {
   1.558 +
   1.559 +    // Be conservative about reducing the footprint.
   1.560 +    //   Do a minimum number of major collections first.
   1.561 +    //   Have reasonable averages for major and minor collections costs.
   1.562 +    if (UseAdaptiveSizePolicyFootprintGoal &&
   1.563 +        young_gen_policy_is_ready() &&
   1.564 +        avg_major_gc_cost()->average() >= 0.0 &&
   1.565 +        avg_minor_gc_cost()->average() >= 0.0) {
   1.566 +      if (is_full_gc) {
   1.567 +        set_decide_at_full_gc(decide_at_full_gc_true);
   1.568 +        size_t desired_sum = desired_eden_size + desired_promo_size;
   1.569 +        desired_promo_size = adjust_promo_for_footprint(desired_promo_size, desired_sum);
   1.570 +      }
   1.571 +    }
   1.572 +  }
   1.573 +
   1.574 +  // Note we make the same tests as in the code block below;  the code
   1.575 +  // seems a little easier to read with the printing in another block.
   1.576 +  if (PrintAdaptiveSizePolicy) {
   1.577 +    if (desired_promo_size > promo_limit)  {
   1.578 +      // "free_in_old_gen" was the original value for used for promo_limit
   1.579 +      size_t free_in_old_gen = (size_t)(max_old_gen_size - avg_old_live()->average());
   1.580 +      gclog_or_tty->print_cr(
   1.581 +            "PSAdaptiveSizePolicy::compute_old_gen_free_space limits:"
   1.582 +            " desired_promo_size: " SIZE_FORMAT
   1.583 +            " promo_limit: " SIZE_FORMAT
   1.584 +            " free_in_old_gen: " SIZE_FORMAT
   1.585 +            " max_old_gen_size: " SIZE_FORMAT
   1.586 +            " avg_old_live: " SIZE_FORMAT,
   1.587 +            desired_promo_size, promo_limit, free_in_old_gen,
   1.588 +            max_old_gen_size, (size_t) avg_old_live()->average());
   1.589 +    }
   1.590 +    if (gc_cost() > gc_cost_limit) {
   1.591 +      gclog_or_tty->print_cr(
   1.592 +            "PSAdaptiveSizePolicy::compute_old_gen_free_space: gc time limit"
   1.593 +            " gc_cost: %f "
   1.594 +            " GCTimeLimit: %d",
   1.595 +            gc_cost(), GCTimeLimit);
   1.596 +    }
   1.597 +  }
   1.598 +
   1.599 +  // Align everything and make a final limit check
   1.600 +  desired_promo_size = align_size_up(desired_promo_size, _space_alignment);
   1.601 +  desired_promo_size = MAX2(desired_promo_size, _space_alignment);
   1.602 +
   1.603 +  promo_limit = align_size_down(promo_limit, _space_alignment);
   1.604 +
   1.605 +  // And one last limit check, now that we've aligned things.
   1.606 +  desired_promo_size = MIN2(desired_promo_size, promo_limit);
   1.607 +
   1.608 +  if (PrintAdaptiveSizePolicy) {
   1.609 +    // Timing stats
   1.610 +    gclog_or_tty->print(
   1.611 +               "PSAdaptiveSizePolicy::compute_old_gen_free_space: costs"
   1.612 +               " minor_time: %f"
   1.613 +               " major_cost: %f"
   1.614 +               " mutator_cost: %f"
   1.615 +               " throughput_goal: %f",
   1.616 +               minor_gc_cost(), major_gc_cost(), mutator_cost(),
   1.617 +               _throughput_goal);
   1.618 +
   1.619 +    // We give more details if Verbose is set
   1.620 +    if (Verbose) {
   1.621 +      gclog_or_tty->print( " minor_pause: %f"
   1.622 +                  " major_pause: %f"
   1.623 +                  " minor_interval: %f"
   1.624 +                  " major_interval: %f"
   1.625 +                  " pause_goal: %f",
   1.626 +                  _avg_minor_pause->padded_average(),
   1.627 +                  _avg_major_pause->padded_average(),
   1.628 +                  _avg_minor_interval->average(),
   1.629 +                  _avg_major_interval->average(),
   1.630 +                  gc_pause_goal_sec());
   1.631 +    }
   1.632 +
   1.633 +    // Footprint stats
   1.634 +    gclog_or_tty->print( " live_space: " SIZE_FORMAT
   1.635 +                " free_space: " SIZE_FORMAT,
   1.636 +                live_space(), free_space());
   1.637 +    // More detail
   1.638 +    if (Verbose) {
   1.639 +      gclog_or_tty->print( " base_footprint: " SIZE_FORMAT
   1.640 +                  " avg_young_live: " SIZE_FORMAT
   1.641 +                  " avg_old_live: " SIZE_FORMAT,
   1.642 +                  (size_t)_avg_base_footprint->average(),
   1.643 +                  (size_t)avg_young_live()->average(),
   1.644 +                  (size_t)avg_old_live()->average());
   1.645 +    }
   1.646 +
   1.647 +    // And finally, our old and new sizes.
   1.648 +    gclog_or_tty->print(" old_promo_size: " SIZE_FORMAT
   1.649 +               " desired_promo_size: " SIZE_FORMAT,
   1.650 +               _promo_size, desired_promo_size);
   1.651 +    gclog_or_tty->cr();
   1.652 +  }
   1.653 +
   1.654 +  set_promo_size(desired_promo_size);
   1.655 +}
   1.656 +
   1.657 +void PSAdaptiveSizePolicy::decay_supplemental_growth(bool is_full_gc) {
   1.658 +  // Decay the supplemental increment?  Decay the supplement growth
   1.659 +  // factor even if it is not used.  It is only meant to give a boost
   1.660 +  // to the initial growth and if it is not used, then it was not
   1.661 +  // needed.
   1.662 +  if (is_full_gc) {
   1.663 +    // Don't wait for the threshold value for the major collections.  If
   1.664 +    // here, the supplemental growth term was used and should decay.
   1.665 +    if ((_avg_major_pause->count() % TenuredGenerationSizeSupplementDecay)
   1.666 +        == 0) {
   1.667 +      _old_gen_size_increment_supplement =
   1.668 +        _old_gen_size_increment_supplement >> 1;
   1.669 +    }
   1.670 +  } else {
   1.671 +    if ((_avg_minor_pause->count() >= AdaptiveSizePolicyReadyThreshold) &&
   1.672 +        (_avg_minor_pause->count() % YoungGenerationSizeSupplementDecay) == 0) {
   1.673 +      _young_gen_size_increment_supplement =
   1.674 +        _young_gen_size_increment_supplement >> 1;
   1.675 +    }
   1.676 +  }
   1.677 +}
   1.678 +
   1.679 +void PSAdaptiveSizePolicy::adjust_promo_for_minor_pause_time(bool is_full_gc,
   1.680 +    size_t* desired_promo_size_ptr, size_t* desired_eden_size_ptr) {
   1.681 +
   1.682 +  if (PSAdjustTenuredGenForMinorPause) {
   1.683 +    if (is_full_gc) {
   1.684 +      set_decide_at_full_gc(decide_at_full_gc_true);
   1.685 +    }
   1.686 +    // If the desired eden size is as small as it will get,
   1.687 +    // try to adjust the old gen size.
   1.688 +    if (*desired_eden_size_ptr <= _space_alignment) {
   1.689 +      // Vary the old gen size to reduce the young gen pause.  This
   1.690 +      // may not be a good idea.  This is just a test.
   1.691 +      if (minor_pause_old_estimator()->decrement_will_decrease()) {
   1.692 +        set_change_old_gen_for_min_pauses(decrease_old_gen_for_min_pauses_true);
   1.693 +        *desired_promo_size_ptr =
   1.694 +          _promo_size - promo_decrement_aligned_down(*desired_promo_size_ptr);
   1.695 +      } else {
   1.696 +        set_change_old_gen_for_min_pauses(increase_old_gen_for_min_pauses_true);
   1.697 +        size_t promo_heap_delta =
   1.698 +          promo_increment_with_supplement_aligned_up(*desired_promo_size_ptr);
   1.699 +        if ((*desired_promo_size_ptr + promo_heap_delta) >
   1.700 +            *desired_promo_size_ptr) {
   1.701 +          *desired_promo_size_ptr =
   1.702 +            _promo_size + promo_heap_delta;
   1.703 +        }
   1.704 +      }
   1.705 +    }
   1.706 +  }
   1.707 +}
   1.708 +
   1.709 +void PSAdaptiveSizePolicy::adjust_eden_for_minor_pause_time(bool is_full_gc,
   1.710 +    size_t* desired_eden_size_ptr) {
   1.711 +
   1.712 +  // Adjust the young generation size to reduce pause time of
   1.713 +  // of collections.
   1.714 +  //
   1.715 +  // The AdaptiveSizePolicyInitializingSteps test is not used
   1.716 +  // here.  It has not seemed to be needed but perhaps should
   1.717 +  // be added for consistency.
   1.718 +  if (minor_pause_young_estimator()->decrement_will_decrease()) {
   1.719 +        // reduce eden size
   1.720 +    set_change_young_gen_for_min_pauses(
   1.721 +          decrease_young_gen_for_min_pauses_true);
   1.722 +    *desired_eden_size_ptr = *desired_eden_size_ptr -
   1.723 +      eden_decrement_aligned_down(*desired_eden_size_ptr);
   1.724 +    } else {
   1.725 +      // EXPERIMENTAL ADJUSTMENT
   1.726 +      // Only record that the estimator indicated such an action.
   1.727 +      // *desired_eden_size_ptr = *desired_eden_size_ptr + eden_heap_delta;
   1.728 +      set_change_young_gen_for_min_pauses(
   1.729 +          increase_young_gen_for_min_pauses_true);
   1.730 +  }
   1.731 +}
   1.732 +
   1.733 +void PSAdaptiveSizePolicy::adjust_promo_for_pause_time(bool is_full_gc,
   1.734 +                                             size_t* desired_promo_size_ptr,
   1.735 +                                             size_t* desired_eden_size_ptr) {
   1.736 +
   1.737 +  size_t promo_heap_delta = 0;
   1.738 +  // Add some checks for a threshold for a change.  For example,
   1.739 +  // a change less than the required alignment is probably not worth
   1.740 +  // attempting.
   1.741 +
   1.742 +  if (_avg_minor_pause->padded_average() > _avg_major_pause->padded_average()) {
   1.743 +    adjust_promo_for_minor_pause_time(is_full_gc, desired_promo_size_ptr, desired_eden_size_ptr);
   1.744 +    // major pause adjustments
   1.745 +  } else if (is_full_gc) {
   1.746 +    // Adjust for the major pause time only at full gc's because the
   1.747 +    // affects of a change can only be seen at full gc's.
   1.748 +
   1.749 +    // Reduce old generation size to reduce pause?
   1.750 +    if (major_pause_old_estimator()->decrement_will_decrease()) {
   1.751 +      // reduce old generation size
   1.752 +      set_change_old_gen_for_maj_pauses(decrease_old_gen_for_maj_pauses_true);
   1.753 +      promo_heap_delta = promo_decrement_aligned_down(*desired_promo_size_ptr);
   1.754 +      *desired_promo_size_ptr = _promo_size - promo_heap_delta;
   1.755 +    } else {
   1.756 +      // EXPERIMENTAL ADJUSTMENT
   1.757 +      // Only record that the estimator indicated such an action.
   1.758 +      // *desired_promo_size_ptr = _promo_size +
   1.759 +      //   promo_increment_aligned_up(*desired_promo_size_ptr);
   1.760 +      set_change_old_gen_for_maj_pauses(increase_old_gen_for_maj_pauses_true);
   1.761 +    }
   1.762 +  }
   1.763 +
   1.764 +  if (PrintAdaptiveSizePolicy && Verbose) {
   1.765 +    gclog_or_tty->print_cr(
   1.766 +      "PSAdaptiveSizePolicy::adjust_promo_for_pause_time "
   1.767 +      "adjusting gen sizes for major pause (avg %f goal %f). "
   1.768 +      "desired_promo_size " SIZE_FORMAT " promo delta " SIZE_FORMAT,
   1.769 +      _avg_major_pause->average(), gc_pause_goal_sec(),
   1.770 +      *desired_promo_size_ptr, promo_heap_delta);
   1.771 +  }
   1.772 +}
   1.773 +
   1.774 +void PSAdaptiveSizePolicy::adjust_eden_for_pause_time(bool is_full_gc,
   1.775 +                                             size_t* desired_promo_size_ptr,
   1.776 +                                             size_t* desired_eden_size_ptr) {
   1.777 +
   1.778 +  size_t eden_heap_delta = 0;
   1.779 +  // Add some checks for a threshold for a change.  For example,
   1.780 +  // a change less than the required alignment is probably not worth
   1.781 +  // attempting.
   1.782 +  if (_avg_minor_pause->padded_average() > _avg_major_pause->padded_average()) {
   1.783 +    adjust_eden_for_minor_pause_time(is_full_gc,
   1.784 +                                desired_eden_size_ptr);
   1.785 +    // major pause adjustments
   1.786 +  } else if (is_full_gc) {
   1.787 +    // Adjust for the major pause time only at full gc's because the
   1.788 +    // affects of a change can only be seen at full gc's.
   1.789 +    if (PSAdjustYoungGenForMajorPause) {
   1.790 +      // If the promo size is at the minimum (i.e., the old gen
   1.791 +      // size will not actually decrease), consider changing the
   1.792 +      // young gen size.
   1.793 +      if (*desired_promo_size_ptr < _space_alignment) {
   1.794 +        // If increasing the young generation will decrease the old gen
   1.795 +        // pause, do it.
   1.796 +        // During startup there is noise in the statistics for deciding
   1.797 +        // on whether to increase or decrease the young gen size.  For
   1.798 +        // some number of iterations, just try to increase the young
   1.799 +        // gen size if the major pause is too long to try and establish
   1.800 +        // good statistics for later decisions.
   1.801 +        if (major_pause_young_estimator()->increment_will_decrease() ||
   1.802 +          (_young_gen_change_for_major_pause_count
   1.803 +            <= AdaptiveSizePolicyInitializingSteps)) {
   1.804 +          set_change_young_gen_for_maj_pauses(
   1.805 +          increase_young_gen_for_maj_pauses_true);
   1.806 +          eden_heap_delta = eden_increment_aligned_up(*desired_eden_size_ptr);
   1.807 +          *desired_eden_size_ptr = _eden_size + eden_heap_delta;
   1.808 +          _young_gen_change_for_major_pause_count++;
   1.809 +        } else {
   1.810 +          // Record that decreasing the young gen size would decrease
   1.811 +          // the major pause
   1.812 +          set_change_young_gen_for_maj_pauses(
   1.813 +            decrease_young_gen_for_maj_pauses_true);
   1.814 +          eden_heap_delta = eden_decrement_aligned_down(*desired_eden_size_ptr);
   1.815 +          *desired_eden_size_ptr = _eden_size - eden_heap_delta;
   1.816 +        }
   1.817 +      }
   1.818 +    }
   1.819 +  }
   1.820 +
   1.821 +  if (PrintAdaptiveSizePolicy && Verbose) {
   1.822 +    gclog_or_tty->print_cr(
   1.823 +      "PSAdaptiveSizePolicy::adjust_eden_for_pause_time "
   1.824 +      "adjusting gen sizes for major pause (avg %f goal %f). "
   1.825 +      "desired_eden_size " SIZE_FORMAT " eden delta " SIZE_FORMAT,
   1.826 +      _avg_major_pause->average(), gc_pause_goal_sec(),
   1.827 +      *desired_eden_size_ptr, eden_heap_delta);
   1.828 +  }
   1.829 +}
   1.830 +
   1.831 +void PSAdaptiveSizePolicy::adjust_promo_for_throughput(bool is_full_gc,
   1.832 +                                             size_t* desired_promo_size_ptr) {
   1.833 +
   1.834 +  // Add some checks for a threshold for a change.  For example,
   1.835 +  // a change less than the required alignment is probably not worth
   1.836 +  // attempting.
   1.837 +
   1.838 +  if ((gc_cost() + mutator_cost()) == 0.0) {
   1.839 +    return;
   1.840 +  }
   1.841 +
   1.842 +  if (PrintAdaptiveSizePolicy && Verbose) {
   1.843 +    gclog_or_tty->print("\nPSAdaptiveSizePolicy::adjust_promo_for_throughput("
   1.844 +      "is_full: %d, promo: " SIZE_FORMAT "): ",
   1.845 +      is_full_gc, *desired_promo_size_ptr);
   1.846 +    gclog_or_tty->print_cr("mutator_cost %f  major_gc_cost %f "
   1.847 +      "minor_gc_cost %f", mutator_cost(), major_gc_cost(), minor_gc_cost());
   1.848 +  }
   1.849 +
   1.850 +  // Tenured generation
   1.851 +  if (is_full_gc) {
   1.852 +    // Calculate the change to use for the tenured gen.
   1.853 +    size_t scaled_promo_heap_delta = 0;
   1.854 +    // Can the increment to the generation be scaled?
   1.855 +    if (gc_cost() >= 0.0 && major_gc_cost() >= 0.0) {
   1.856 +      size_t promo_heap_delta =
   1.857 +        promo_increment_with_supplement_aligned_up(*desired_promo_size_ptr);
   1.858 +      double scale_by_ratio = major_gc_cost() / gc_cost();
   1.859 +      scaled_promo_heap_delta =
   1.860 +        (size_t) (scale_by_ratio * (double) promo_heap_delta);
   1.861 +      if (PrintAdaptiveSizePolicy && Verbose) {
   1.862 +        gclog_or_tty->print_cr(
   1.863 +          "Scaled tenured increment: " SIZE_FORMAT " by %f down to "
   1.864 +          SIZE_FORMAT,
   1.865 +          promo_heap_delta, scale_by_ratio, scaled_promo_heap_delta);
   1.866 +      }
   1.867 +    } else if (major_gc_cost() >= 0.0) {
   1.868 +      // Scaling is not going to work.  If the major gc time is the
   1.869 +      // larger, give it a full increment.
   1.870 +      if (major_gc_cost() >= minor_gc_cost()) {
   1.871 +        scaled_promo_heap_delta =
   1.872 +          promo_increment_with_supplement_aligned_up(*desired_promo_size_ptr);
   1.873 +      }
   1.874 +    } else {
   1.875 +      // Don't expect to get here but it's ok if it does
   1.876 +      // in the product build since the delta will be 0
   1.877 +      // and nothing will change.
   1.878 +      assert(false, "Unexpected value for gc costs");
   1.879 +    }
   1.880 +
   1.881 +    switch (AdaptiveSizeThroughPutPolicy) {
   1.882 +      case 1:
   1.883 +        // Early in the run the statistics might not be good.  Until
   1.884 +        // a specific number of collections have been, use the heuristic
   1.885 +        // that a larger generation size means lower collection costs.
   1.886 +        if (major_collection_estimator()->increment_will_decrease() ||
   1.887 +           (_old_gen_change_for_major_throughput
   1.888 +            <= AdaptiveSizePolicyInitializingSteps)) {
   1.889 +          // Increase tenured generation size to reduce major collection cost
   1.890 +          if ((*desired_promo_size_ptr + scaled_promo_heap_delta) >
   1.891 +              *desired_promo_size_ptr) {
   1.892 +            *desired_promo_size_ptr = _promo_size + scaled_promo_heap_delta;
   1.893 +          }
   1.894 +          set_change_old_gen_for_throughput(
   1.895 +              increase_old_gen_for_throughput_true);
   1.896 +              _old_gen_change_for_major_throughput++;
   1.897 +        } else {
   1.898 +          // EXPERIMENTAL ADJUSTMENT
   1.899 +          // Record that decreasing the old gen size would decrease
   1.900 +          // the major collection cost but don't do it.
   1.901 +          // *desired_promo_size_ptr = _promo_size -
   1.902 +          //   promo_decrement_aligned_down(*desired_promo_size_ptr);
   1.903 +          set_change_old_gen_for_throughput(
   1.904 +                decrease_old_gen_for_throughput_true);
   1.905 +        }
   1.906 +
   1.907 +        break;
   1.908 +      default:
   1.909 +        // Simplest strategy
   1.910 +        if ((*desired_promo_size_ptr + scaled_promo_heap_delta) >
   1.911 +            *desired_promo_size_ptr) {
   1.912 +          *desired_promo_size_ptr = *desired_promo_size_ptr +
   1.913 +            scaled_promo_heap_delta;
   1.914 +        }
   1.915 +        set_change_old_gen_for_throughput(
   1.916 +          increase_old_gen_for_throughput_true);
   1.917 +        _old_gen_change_for_major_throughput++;
   1.918 +    }
   1.919 +
   1.920 +    if (PrintAdaptiveSizePolicy && Verbose) {
   1.921 +      gclog_or_tty->print_cr(
   1.922 +          "adjusting tenured gen for throughput (avg %f goal %f). "
   1.923 +          "desired_promo_size " SIZE_FORMAT " promo_delta " SIZE_FORMAT ,
   1.924 +          mutator_cost(), _throughput_goal,
   1.925 +          *desired_promo_size_ptr, scaled_promo_heap_delta);
   1.926 +    }
   1.927 +  }
   1.928 +}
   1.929 +
   1.930 +void PSAdaptiveSizePolicy::adjust_eden_for_throughput(bool is_full_gc,
   1.931 +                                             size_t* desired_eden_size_ptr) {
   1.932 +
   1.933 +  // Add some checks for a threshold for a change.  For example,
   1.934 +  // a change less than the required alignment is probably not worth
   1.935 +  // attempting.
   1.936 +
   1.937 +  if ((gc_cost() + mutator_cost()) == 0.0) {
   1.938 +    return;
   1.939 +  }
   1.940 +
   1.941 +  if (PrintAdaptiveSizePolicy && Verbose) {
   1.942 +    gclog_or_tty->print("\nPSAdaptiveSizePolicy::adjust_eden_for_throughput("
   1.943 +      "is_full: %d, cur_eden: " SIZE_FORMAT "): ",
   1.944 +      is_full_gc, *desired_eden_size_ptr);
   1.945 +    gclog_or_tty->print_cr("mutator_cost %f  major_gc_cost %f "
   1.946 +      "minor_gc_cost %f", mutator_cost(), major_gc_cost(), minor_gc_cost());
   1.947 +  }
   1.948 +
   1.949 +  // Young generation
   1.950 +  size_t scaled_eden_heap_delta = 0;
   1.951 +  // Can the increment to the generation be scaled?
   1.952 +  if (gc_cost() >= 0.0 && minor_gc_cost() >= 0.0) {
   1.953 +    size_t eden_heap_delta =
   1.954 +      eden_increment_with_supplement_aligned_up(*desired_eden_size_ptr);
   1.955 +    double scale_by_ratio = minor_gc_cost() / gc_cost();
   1.956 +    assert(scale_by_ratio <= 1.0 && scale_by_ratio >= 0.0, "Scaling is wrong");
   1.957 +    scaled_eden_heap_delta =
   1.958 +      (size_t) (scale_by_ratio * (double) eden_heap_delta);
   1.959 +    if (PrintAdaptiveSizePolicy && Verbose) {
   1.960 +      gclog_or_tty->print_cr(
   1.961 +        "Scaled eden increment: " SIZE_FORMAT " by %f down to "
   1.962 +        SIZE_FORMAT,
   1.963 +        eden_heap_delta, scale_by_ratio, scaled_eden_heap_delta);
   1.964 +    }
   1.965 +  } else if (minor_gc_cost() >= 0.0) {
   1.966 +    // Scaling is not going to work.  If the minor gc time is the
   1.967 +    // larger, give it a full increment.
   1.968 +    if (minor_gc_cost() > major_gc_cost()) {
   1.969 +      scaled_eden_heap_delta =
   1.970 +        eden_increment_with_supplement_aligned_up(*desired_eden_size_ptr);
   1.971 +    }
   1.972 +  } else {
   1.973 +    // Don't expect to get here but it's ok if it does
   1.974 +    // in the product build since the delta will be 0
   1.975 +    // and nothing will change.
   1.976 +    assert(false, "Unexpected value for gc costs");
   1.977 +  }
   1.978 +
   1.979 +  // Use a heuristic for some number of collections to give
   1.980 +  // the averages time to settle down.
   1.981 +  switch (AdaptiveSizeThroughPutPolicy) {
   1.982 +    case 1:
   1.983 +      if (minor_collection_estimator()->increment_will_decrease() ||
   1.984 +        (_young_gen_change_for_minor_throughput
   1.985 +          <= AdaptiveSizePolicyInitializingSteps)) {
   1.986 +        // Expand young generation size to reduce frequency of
   1.987 +        // of collections.
   1.988 +        if ((*desired_eden_size_ptr + scaled_eden_heap_delta) >
   1.989 +            *desired_eden_size_ptr) {
   1.990 +          *desired_eden_size_ptr =
   1.991 +            *desired_eden_size_ptr + scaled_eden_heap_delta;
   1.992 +        }
   1.993 +        set_change_young_gen_for_throughput(
   1.994 +          increase_young_gen_for_througput_true);
   1.995 +        _young_gen_change_for_minor_throughput++;
   1.996 +      } else {
   1.997 +        // EXPERIMENTAL ADJUSTMENT
   1.998 +        // Record that decreasing the young gen size would decrease
   1.999 +        // the minor collection cost but don't do it.
  1.1000 +        // *desired_eden_size_ptr = _eden_size -
  1.1001 +        //   eden_decrement_aligned_down(*desired_eden_size_ptr);
  1.1002 +        set_change_young_gen_for_throughput(
  1.1003 +          decrease_young_gen_for_througput_true);
  1.1004 +      }
  1.1005 +          break;
  1.1006 +    default:
  1.1007 +      if ((*desired_eden_size_ptr + scaled_eden_heap_delta) >
  1.1008 +          *desired_eden_size_ptr) {
  1.1009 +        *desired_eden_size_ptr =
  1.1010 +          *desired_eden_size_ptr + scaled_eden_heap_delta;
  1.1011 +      }
  1.1012 +      set_change_young_gen_for_throughput(
  1.1013 +        increase_young_gen_for_througput_true);
  1.1014 +      _young_gen_change_for_minor_throughput++;
  1.1015 +  }
  1.1016 +
  1.1017 +  if (PrintAdaptiveSizePolicy && Verbose) {
  1.1018 +    gclog_or_tty->print_cr(
  1.1019 +        "adjusting eden for throughput (avg %f goal %f). desired_eden_size "
  1.1020 +        SIZE_FORMAT " eden delta " SIZE_FORMAT "\n",
  1.1021 +      mutator_cost(), _throughput_goal,
  1.1022 +        *desired_eden_size_ptr, scaled_eden_heap_delta);
  1.1023 +  }
  1.1024 +}
  1.1025 +
  1.1026 +size_t PSAdaptiveSizePolicy::adjust_promo_for_footprint(
  1.1027 +    size_t desired_promo_size, size_t desired_sum) {
  1.1028 +  assert(desired_promo_size <= desired_sum, "Inconsistent parameters");
  1.1029 +  set_decrease_for_footprint(decrease_old_gen_for_footprint_true);
  1.1030 +
  1.1031 +  size_t change = promo_decrement(desired_promo_size);
  1.1032 +  change = scale_down(change, desired_promo_size, desired_sum);
  1.1033 +
  1.1034 +  size_t reduced_size = desired_promo_size - change;
  1.1035 +
  1.1036 +  if (PrintAdaptiveSizePolicy && Verbose) {
  1.1037 +    gclog_or_tty->print_cr(
  1.1038 +      "AdaptiveSizePolicy::adjust_promo_for_footprint "
  1.1039 +      "adjusting tenured gen for footprint. "
  1.1040 +      "starting promo size " SIZE_FORMAT
  1.1041 +      " reduced promo size " SIZE_FORMAT
  1.1042 +      " promo delta " SIZE_FORMAT,
  1.1043 +      desired_promo_size, reduced_size, change );
  1.1044 +  }
  1.1045 +
  1.1046 +  assert(reduced_size <= desired_promo_size, "Inconsistent result");
  1.1047 +  return reduced_size;
  1.1048 +}
  1.1049 +
  1.1050 +size_t PSAdaptiveSizePolicy::adjust_eden_for_footprint(
  1.1051 +  size_t desired_eden_size, size_t desired_sum) {
  1.1052 +  assert(desired_eden_size <= desired_sum, "Inconsistent parameters");
  1.1053 +  set_decrease_for_footprint(decrease_young_gen_for_footprint_true);
  1.1054 +
  1.1055 +  size_t change = eden_decrement(desired_eden_size);
  1.1056 +  change = scale_down(change, desired_eden_size, desired_sum);
  1.1057 +
  1.1058 +  size_t reduced_size = desired_eden_size - change;
  1.1059 +
  1.1060 +  if (PrintAdaptiveSizePolicy && Verbose) {
  1.1061 +    gclog_or_tty->print_cr(
  1.1062 +      "AdaptiveSizePolicy::adjust_eden_for_footprint "
  1.1063 +      "adjusting eden for footprint. "
  1.1064 +      " starting eden size " SIZE_FORMAT
  1.1065 +      " reduced eden size " SIZE_FORMAT
  1.1066 +      " eden delta " SIZE_FORMAT,
  1.1067 +      desired_eden_size, reduced_size, change);
  1.1068 +  }
  1.1069 +
  1.1070 +  assert(reduced_size <= desired_eden_size, "Inconsistent result");
  1.1071 +  return reduced_size;
  1.1072 +}
  1.1073 +
  1.1074 +// Scale down "change" by the factor
  1.1075 +//      part / total
  1.1076 +// Don't align the results.
  1.1077 +
  1.1078 +size_t PSAdaptiveSizePolicy::scale_down(size_t change,
  1.1079 +                                        double part,
  1.1080 +                                        double total) {
  1.1081 +  assert(part <= total, "Inconsistent input");
  1.1082 +  size_t reduced_change = change;
  1.1083 +  if (total > 0) {
  1.1084 +    double fraction =  part / total;
  1.1085 +    reduced_change = (size_t) (fraction * (double) change);
  1.1086 +  }
  1.1087 +  assert(reduced_change <= change, "Inconsistent result");
  1.1088 +  return reduced_change;
  1.1089 +}
  1.1090 +
  1.1091 +size_t PSAdaptiveSizePolicy::eden_increment(size_t cur_eden,
  1.1092 +                                            uint percent_change) {
  1.1093 +  size_t eden_heap_delta;
  1.1094 +  eden_heap_delta = cur_eden / 100 * percent_change;
  1.1095 +  return eden_heap_delta;
  1.1096 +}
  1.1097 +
  1.1098 +size_t PSAdaptiveSizePolicy::eden_increment(size_t cur_eden) {
  1.1099 +  return eden_increment(cur_eden, YoungGenerationSizeIncrement);
  1.1100 +}
  1.1101 +
  1.1102 +size_t PSAdaptiveSizePolicy::eden_increment_aligned_up(size_t cur_eden) {
  1.1103 +  size_t result = eden_increment(cur_eden, YoungGenerationSizeIncrement);
  1.1104 +  return align_size_up(result, _space_alignment);
  1.1105 +}
  1.1106 +
  1.1107 +size_t PSAdaptiveSizePolicy::eden_increment_aligned_down(size_t cur_eden) {
  1.1108 +  size_t result = eden_increment(cur_eden);
  1.1109 +  return align_size_down(result, _space_alignment);
  1.1110 +}
  1.1111 +
  1.1112 +size_t PSAdaptiveSizePolicy::eden_increment_with_supplement_aligned_up(
  1.1113 +  size_t cur_eden) {
  1.1114 +  size_t result = eden_increment(cur_eden,
  1.1115 +    YoungGenerationSizeIncrement + _young_gen_size_increment_supplement);
  1.1116 +  return align_size_up(result, _space_alignment);
  1.1117 +}
  1.1118 +
  1.1119 +size_t PSAdaptiveSizePolicy::eden_decrement_aligned_down(size_t cur_eden) {
  1.1120 +  size_t eden_heap_delta = eden_decrement(cur_eden);
  1.1121 +  return align_size_down(eden_heap_delta, _space_alignment);
  1.1122 +}
  1.1123 +
  1.1124 +size_t PSAdaptiveSizePolicy::eden_decrement(size_t cur_eden) {
  1.1125 +  size_t eden_heap_delta = eden_increment(cur_eden) /
  1.1126 +    AdaptiveSizeDecrementScaleFactor;
  1.1127 +  return eden_heap_delta;
  1.1128 +}
  1.1129 +
  1.1130 +size_t PSAdaptiveSizePolicy::promo_increment(size_t cur_promo,
  1.1131 +                                             uint percent_change) {
  1.1132 +  size_t promo_heap_delta;
  1.1133 +  promo_heap_delta = cur_promo / 100 * percent_change;
  1.1134 +  return promo_heap_delta;
  1.1135 +}
  1.1136 +
  1.1137 +size_t PSAdaptiveSizePolicy::promo_increment(size_t cur_promo) {
  1.1138 +  return promo_increment(cur_promo, TenuredGenerationSizeIncrement);
  1.1139 +}
  1.1140 +
  1.1141 +size_t PSAdaptiveSizePolicy::promo_increment_aligned_up(size_t cur_promo) {
  1.1142 +  size_t result =  promo_increment(cur_promo, TenuredGenerationSizeIncrement);
  1.1143 +  return align_size_up(result, _space_alignment);
  1.1144 +}
  1.1145 +
  1.1146 +size_t PSAdaptiveSizePolicy::promo_increment_aligned_down(size_t cur_promo) {
  1.1147 +  size_t result =  promo_increment(cur_promo, TenuredGenerationSizeIncrement);
  1.1148 +  return align_size_down(result, _space_alignment);
  1.1149 +}
  1.1150 +
  1.1151 +size_t PSAdaptiveSizePolicy::promo_increment_with_supplement_aligned_up(
  1.1152 +  size_t cur_promo) {
  1.1153 +  size_t result =  promo_increment(cur_promo,
  1.1154 +    TenuredGenerationSizeIncrement + _old_gen_size_increment_supplement);
  1.1155 +  return align_size_up(result, _space_alignment);
  1.1156 +}
  1.1157 +
  1.1158 +size_t PSAdaptiveSizePolicy::promo_decrement_aligned_down(size_t cur_promo) {
  1.1159 +  size_t promo_heap_delta = promo_decrement(cur_promo);
  1.1160 +  return align_size_down(promo_heap_delta, _space_alignment);
  1.1161 +}
  1.1162 +
  1.1163 +size_t PSAdaptiveSizePolicy::promo_decrement(size_t cur_promo) {
  1.1164 +  size_t promo_heap_delta = promo_increment(cur_promo);
  1.1165 +  promo_heap_delta = promo_heap_delta / AdaptiveSizeDecrementScaleFactor;
  1.1166 +  return promo_heap_delta;
  1.1167 +}
  1.1168 +
  1.1169 +uint PSAdaptiveSizePolicy::compute_survivor_space_size_and_threshold(
  1.1170 +                                             bool is_survivor_overflow,
  1.1171 +                                             uint tenuring_threshold,
  1.1172 +                                             size_t survivor_limit) {
  1.1173 +  assert(survivor_limit >= _space_alignment,
  1.1174 +         "survivor_limit too small");
  1.1175 +  assert((size_t)align_size_down(survivor_limit, _space_alignment)
  1.1176 +         == survivor_limit, "survivor_limit not aligned");
  1.1177 +
  1.1178 +  // This method is called even if the tenuring threshold and survivor
  1.1179 +  // spaces are not adjusted so that the averages are sampled above.
  1.1180 +  if (!UsePSAdaptiveSurvivorSizePolicy ||
  1.1181 +      !young_gen_policy_is_ready()) {
  1.1182 +    return tenuring_threshold;
  1.1183 +  }
  1.1184 +
  1.1185 +  // We'll decide whether to increase or decrease the tenuring
  1.1186 +  // threshold based partly on the newly computed survivor size
  1.1187 +  // (if we hit the maximum limit allowed, we'll always choose to
  1.1188 +  // decrement the threshold).
  1.1189 +  bool incr_tenuring_threshold = false;
  1.1190 +  bool decr_tenuring_threshold = false;
  1.1191 +
  1.1192 +  set_decrement_tenuring_threshold_for_gc_cost(false);
  1.1193 +  set_increment_tenuring_threshold_for_gc_cost(false);
  1.1194 +  set_decrement_tenuring_threshold_for_survivor_limit(false);
  1.1195 +
  1.1196 +  if (!is_survivor_overflow) {
  1.1197 +    // Keep running averages on how much survived
  1.1198 +
  1.1199 +    // We use the tenuring threshold to equalize the cost of major
  1.1200 +    // and minor collections.
  1.1201 +    // ThresholdTolerance is used to indicate how sensitive the
  1.1202 +    // tenuring threshold is to differences in cost betweent the
  1.1203 +    // collection types.
  1.1204 +
  1.1205 +    // Get the times of interest. This involves a little work, so
  1.1206 +    // we cache the values here.
  1.1207 +    const double major_cost = major_gc_cost();
  1.1208 +    const double minor_cost = minor_gc_cost();
  1.1209 +
  1.1210 +    if (minor_cost > major_cost * _threshold_tolerance_percent) {
  1.1211 +      // Minor times are getting too long;  lower the threshold so
  1.1212 +      // less survives and more is promoted.
  1.1213 +      decr_tenuring_threshold = true;
  1.1214 +      set_decrement_tenuring_threshold_for_gc_cost(true);
  1.1215 +    } else if (major_cost > minor_cost * _threshold_tolerance_percent) {
  1.1216 +      // Major times are too long, so we want less promotion.
  1.1217 +      incr_tenuring_threshold = true;
  1.1218 +      set_increment_tenuring_threshold_for_gc_cost(true);
  1.1219 +    }
  1.1220 +
  1.1221 +  } else {
  1.1222 +    // Survivor space overflow occurred, so promoted and survived are
  1.1223 +    // not accurate. We'll make our best guess by combining survived
  1.1224 +    // and promoted and count them as survivors.
  1.1225 +    //
  1.1226 +    // We'll lower the tenuring threshold to see if we can correct
  1.1227 +    // things. Also, set the survivor size conservatively. We're
  1.1228 +    // trying to avoid many overflows from occurring if defnew size
  1.1229 +    // is just too small.
  1.1230 +
  1.1231 +    decr_tenuring_threshold = true;
  1.1232 +  }
  1.1233 +
  1.1234 +  // The padded average also maintains a deviation from the average;
  1.1235 +  // we use this to see how good of an estimate we have of what survived.
  1.1236 +  // We're trying to pad the survivor size as little as possible without
  1.1237 +  // overflowing the survivor spaces.
  1.1238 +  size_t target_size = align_size_up((size_t)_avg_survived->padded_average(),
  1.1239 +                                     _space_alignment);
  1.1240 +  target_size = MAX2(target_size, _space_alignment);
  1.1241 +
  1.1242 +  if (target_size > survivor_limit) {
  1.1243 +    // Target size is bigger than we can handle. Let's also reduce
  1.1244 +    // the tenuring threshold.
  1.1245 +    target_size = survivor_limit;
  1.1246 +    decr_tenuring_threshold = true;
  1.1247 +    set_decrement_tenuring_threshold_for_survivor_limit(true);
  1.1248 +  }
  1.1249 +
  1.1250 +  // Finally, increment or decrement the tenuring threshold, as decided above.
  1.1251 +  // We test for decrementing first, as we might have hit the target size
  1.1252 +  // limit.
  1.1253 +  if (decr_tenuring_threshold && !(AlwaysTenure || NeverTenure)) {
  1.1254 +    if (tenuring_threshold > 1) {
  1.1255 +      tenuring_threshold--;
  1.1256 +    }
  1.1257 +  } else if (incr_tenuring_threshold && !(AlwaysTenure || NeverTenure)) {
  1.1258 +    if (tenuring_threshold < MaxTenuringThreshold) {
  1.1259 +      tenuring_threshold++;
  1.1260 +    }
  1.1261 +  }
  1.1262 +
  1.1263 +  // We keep a running average of the amount promoted which is used
  1.1264 +  // to decide when we should collect the old generation (when
  1.1265 +  // the amount of old gen free space is less than what we expect to
  1.1266 +  // promote).
  1.1267 +
  1.1268 +  if (PrintAdaptiveSizePolicy) {
  1.1269 +    // A little more detail if Verbose is on
  1.1270 +    if (Verbose) {
  1.1271 +      gclog_or_tty->print( "  avg_survived: %f"
  1.1272 +                  "  avg_deviation: %f",
  1.1273 +                  _avg_survived->average(),
  1.1274 +                  _avg_survived->deviation());
  1.1275 +    }
  1.1276 +
  1.1277 +    gclog_or_tty->print( "  avg_survived_padded_avg: %f",
  1.1278 +                _avg_survived->padded_average());
  1.1279 +
  1.1280 +    if (Verbose) {
  1.1281 +      gclog_or_tty->print( "  avg_promoted_avg: %f"
  1.1282 +                  "  avg_promoted_dev: %f",
  1.1283 +                  avg_promoted()->average(),
  1.1284 +                  avg_promoted()->deviation());
  1.1285 +    }
  1.1286 +
  1.1287 +    gclog_or_tty->print_cr( "  avg_promoted_padded_avg: %f"
  1.1288 +                "  avg_pretenured_padded_avg: %f"
  1.1289 +                "  tenuring_thresh: %d"
  1.1290 +                "  target_size: " SIZE_FORMAT,
  1.1291 +                avg_promoted()->padded_average(),
  1.1292 +                _avg_pretenured->padded_average(),
  1.1293 +                tenuring_threshold, target_size);
  1.1294 +  }
  1.1295 +
  1.1296 +  set_survivor_size(target_size);
  1.1297 +
  1.1298 +  return tenuring_threshold;
  1.1299 +}
  1.1300 +
  1.1301 +void PSAdaptiveSizePolicy::update_averages(bool is_survivor_overflow,
  1.1302 +                                           size_t survived,
  1.1303 +                                           size_t promoted) {
  1.1304 +  // Update averages
  1.1305 +  if (!is_survivor_overflow) {
  1.1306 +    // Keep running averages on how much survived
  1.1307 +    _avg_survived->sample(survived);
  1.1308 +  } else {
  1.1309 +    size_t survived_guess = survived + promoted;
  1.1310 +    _avg_survived->sample(survived_guess);
  1.1311 +  }
  1.1312 +  avg_promoted()->sample(promoted + _avg_pretenured->padded_average());
  1.1313 +
  1.1314 +  if (PrintAdaptiveSizePolicy) {
  1.1315 +    gclog_or_tty->print_cr(
  1.1316 +                  "AdaptiveSizePolicy::update_averages:"
  1.1317 +                  "  survived: "  SIZE_FORMAT
  1.1318 +                  "  promoted: "  SIZE_FORMAT
  1.1319 +                  "  overflow: %s",
  1.1320 +                  survived, promoted, is_survivor_overflow ? "true" : "false");
  1.1321 +  }
  1.1322 +}
  1.1323 +
  1.1324 +bool PSAdaptiveSizePolicy::print_adaptive_size_policy_on(outputStream* st)
  1.1325 +  const {
  1.1326 +
  1.1327 +  if (!UseAdaptiveSizePolicy) return false;
  1.1328 +
  1.1329 +  return AdaptiveSizePolicy::print_adaptive_size_policy_on(
  1.1330 +                          st,
  1.1331 +                          PSScavenge::tenuring_threshold());
  1.1332 +}
  1.1333 +
  1.1334 +#ifndef PRODUCT
  1.1335 +
  1.1336 +void TestOldFreeSpaceCalculation_test() {
  1.1337 +  assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(100, 20) == 25, "Calculation of free memory failed");
  1.1338 +  assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(100, 50) == 100, "Calculation of free memory failed");
  1.1339 +  assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(100, 60) == 150, "Calculation of free memory failed");
  1.1340 +  assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(100, 75) == 300, "Calculation of free memory failed");
  1.1341 +  assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(400, 20) == 100, "Calculation of free memory failed");
  1.1342 +  assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(400, 50) == 400, "Calculation of free memory failed");
  1.1343 +  assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(400, 60) == 600, "Calculation of free memory failed");
  1.1344 +  assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(400, 75) == 1200, "Calculation of free memory failed");
  1.1345 +}
  1.1346 +
  1.1347 +#endif /* !PRODUCT */

mercurial