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