hotspot/src/share/vm/gc/parallel/psAdaptiveSizePolicy.hpp
author stefank
Wed, 05 Jul 2017 11:33:17 +0200
changeset 46625 edefffab74e2
parent 46619 a3919f5e8d2b
permissions -rw-r--r--
8183552: Move align functions to align.hpp Reviewed-by: stuefe, pliden
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 22555
diff changeset
     2
 * Copyright (c) 2002, 2015, 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
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 22555
diff changeset
    25
#ifndef SHARE_VM_GC_PARALLEL_PSADAPTIVESIZEPOLICY_HPP
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 22555
diff changeset
    26
#define SHARE_VM_GC_PARALLEL_PSADAPTIVESIZEPOLICY_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 22555
diff changeset
    28
#include "gc/shared/adaptiveSizePolicy.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 22555
diff changeset
    29
#include "gc/shared/gcCause.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 22555
diff changeset
    30
#include "gc/shared/gcStats.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 22555
diff changeset
    31
#include "gc/shared/gcUtil.hpp"
46625
edefffab74e2 8183552: Move align functions to align.hpp
stefank
parents: 46619
diff changeset
    32
#include "utilities/align.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// This class keeps statistical information and computes the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// optimal free space for both the young and old generation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// based on current application characteristics (based on gc cost
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
// and application footprint).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// It also computes an optimal tenuring threshold between the young
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
// and old generations, so as to equalize the cost of collections
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 21561
diff changeset
    41
// of those generations, as well as optimal survivor space sizes
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
// for the young generation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
// While this class is specifically intended for a generational system
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
// consisting of a young gen (containing an Eden and two semi-spaces)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
// and a tenured gen, as well as a perm gen for reflective data, it
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
// makes NO references to specific generations.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
// 05/02/2003 Update
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
// The 1.5 policy makes use of data gathered for the costs of GC on
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
// specific generations.  That data does reference specific
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
// generation.  Also diagnostics specific to generations have
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
// been added.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
// Forward decls
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
class elapsedTimer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
class PSAdaptiveSizePolicy : public AdaptiveSizePolicy {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
 friend class PSGCAdaptivePolicyCounters;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  // These values are used to record decisions made during the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  // policy.  For example, if the young generation was decreased
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  // to decrease the GC cost of minor collections the value
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  // decrease_young_gen_for_throughput_true is used.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  // Last calculated sizes, in bytes, and aligned
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  // NEEDS_CLEANUP should use sizes.hpp,  but it works in ints, not size_t's
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  // Time statistics
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  AdaptivePaddedAverage* _avg_major_pause;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  // Footprint statistics
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  AdaptiveWeightedAverage* _avg_base_footprint;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  // Statistical data gathered for GC
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  GCStats _gc_stats;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  size_t _survivor_size_limit;   // Limit in bytes of survivor size
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  const double _collection_cost_margin_fraction;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  // Variable for estimating the major and minor pause times.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  // These variables represent linear least-squares fits of
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  // the data.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  //   major pause time vs. old gen size
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  LinearLeastSquareFit* _major_pause_old_estimator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  //   major pause time vs. young gen size
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  LinearLeastSquareFit* _major_pause_young_estimator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  // These record the most recent collection times.  They
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  // are available as an alternative to using the averages
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  // for making ergonomic decisions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  double _latest_major_mutator_interval_seconds;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
21561
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents: 20317
diff changeset
    95
  const size_t _space_alignment; // alignment for eden, survivors
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  const double _gc_minor_pause_goal_sec;    // goal for maximum minor gc pause
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  // The amount of live data in the heap at the last full GC, used
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  // as a baseline to help us determine when we need to perform the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  // next full GC.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  size_t _live_at_last_full_gc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  // decrease/increase the old generation for minor pause time
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  int _change_old_gen_for_min_pauses;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  // increase/decrease the young generation for major pause time
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  int _change_young_gen_for_maj_pauses;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  // Flag indicating that the adaptive policy is ready to use
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  bool _old_gen_policy_is_ready;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  // Changing the generation sizing depends on the data that is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  // gathered about the effects of changes on the pause times and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  // throughput.  These variable count the number of data points
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 21561
diff changeset
   117
  // gathered.  The policy may use these counters as a threshold
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  // for reliable data.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  julong _young_gen_change_for_major_pause_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  // To facilitate faster growth at start up, supplement the normal
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  // growth percentage for the young gen eden and the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  // old gen space for promotion with these value which decay
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  // with increasing collections.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  uint _young_gen_size_increment_supplement;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  uint _old_gen_size_increment_supplement;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  // The number of bytes absorbed from eden into the old gen by moving the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  // boundary over live data.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  size_t _bytes_absorbed_from_eden;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  // Accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  AdaptivePaddedAverage* avg_major_pause() const { return _avg_major_pause; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  double gc_minor_pause_goal_sec() const { return _gc_minor_pause_goal_sec; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
17393
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 13925
diff changeset
   138
  void adjust_eden_for_minor_pause_time(bool is_full_gc,
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 13925
diff changeset
   139
                                   size_t* desired_eden_size_ptr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  // Change the generation sizes to achieve a GC pause time goal
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  // Returned sizes are not necessarily aligned.
17393
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 13925
diff changeset
   142
  void adjust_promo_for_pause_time(bool is_full_gc,
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 13925
diff changeset
   143
                         size_t* desired_promo_size_ptr,
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 13925
diff changeset
   144
                         size_t* desired_eden_size_ptr);
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 13925
diff changeset
   145
  void adjust_eden_for_pause_time(bool is_full_gc,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
                         size_t* desired_promo_size_ptr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
                         size_t* desired_eden_size_ptr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  // Change the generation sizes to achieve an application throughput goal
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  // Returned sizes are not necessarily aligned.
17393
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 13925
diff changeset
   150
  void adjust_promo_for_throughput(bool is_full_gc,
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 13925
diff changeset
   151
                             size_t* desired_promo_size_ptr);
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 13925
diff changeset
   152
  void adjust_eden_for_throughput(bool is_full_gc,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
                             size_t* desired_eden_size_ptr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  // Change the generation sizes to achieve minimum footprint
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  // Returned sizes are not aligned.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  size_t adjust_promo_for_footprint(size_t desired_promo_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
                                    size_t desired_total);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  size_t adjust_eden_for_footprint(size_t desired_promo_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
                                   size_t desired_total);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  // Size in bytes for an increment or decrement of eden.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  virtual size_t eden_increment(size_t cur_eden, uint percent_change);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  virtual size_t eden_decrement(size_t cur_eden);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  size_t eden_decrement_aligned_down(size_t cur_eden);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  size_t eden_increment_with_supplement_aligned_up(size_t cur_eden);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  // Size in bytes for an increment or decrement of the promotion area
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  virtual size_t promo_increment(size_t cur_promo, uint percent_change);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  virtual size_t promo_decrement(size_t cur_promo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  size_t promo_decrement_aligned_down(size_t cur_promo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  size_t promo_increment_with_supplement_aligned_up(size_t cur_promo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  // Returns a change that has been scaled down.  Result
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  // is not aligned.  (If useful, move to some shared
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  // location.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  size_t scale_down(size_t change, double part, double total);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  // Time accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  // Footprint accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  size_t live_space() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
    return (size_t)(avg_base_footprint()->average() +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
                    avg_young_live()->average() +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
                    avg_old_live()->average());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  size_t free_space() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
    return _eden_size + _promo_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  void set_promo_size(size_t new_size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
    _promo_size = new_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  void set_survivor_size(size_t new_size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
    _survivor_size = new_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  // Update estimators
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  void update_minor_pause_old_estimator(double minor_pause_in_ms);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  virtual GCPolicyKind kind() const { return _gc_ps_adaptive_size_policy; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  // Use by ASPSYoungGen and ASPSOldGen to limit boundary moving.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  size_t eden_increment_aligned_up(size_t cur_eden);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  size_t eden_increment_aligned_down(size_t cur_eden);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  size_t promo_increment_aligned_up(size_t cur_promo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  size_t promo_increment_aligned_down(size_t cur_promo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  virtual size_t eden_increment(size_t cur_eden);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  virtual size_t promo_increment(size_t cur_promo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  // Accessors for use by performance counters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  AdaptivePaddedNoZeroDevAverage*  avg_promoted() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
    return _gc_stats.avg_promoted();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  AdaptiveWeightedAverage* avg_base_footprint() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
    return _avg_base_footprint;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  // Input arguments are initial free space sizes for young and old
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  // generations, the initial survivor space size, the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  // alignment values and the pause & throughput goals.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  // NEEDS_CLEANUP this is a singleton object
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  PSAdaptiveSizePolicy(size_t init_eden_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
                       size_t init_promo_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
                       size_t init_survivor_size,
21561
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents: 20317
diff changeset
   229
                       size_t space_alignment,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
                       double gc_pause_goal_sec,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
                       double gc_minor_pause_goal_sec,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
                       uint gc_time_ratio);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  // Methods indicating events of interest to the adaptive size policy,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  // called by GC algorithms. It is the responsibility of users of this
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  // policy to call these methods at the correct times!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  void major_collection_begin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  void major_collection_end(size_t amount_live, GCCause::Cause gc_cause);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  void tenured_allocation(size_t size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
    _avg_pretenured->sample(size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  // Accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  // NEEDS_CLEANUP   should use sizes.hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
22555
ea32f6c51d08 8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents: 22551
diff changeset
   247
  static size_t calculate_free_based_on_live(size_t live, uintx ratio_as_percentage);
ea32f6c51d08 8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents: 22551
diff changeset
   248
ea32f6c51d08 8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents: 22551
diff changeset
   249
  size_t calculated_old_free_size_in_bytes() const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  size_t average_old_live_in_bytes() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
    return (size_t) avg_old_live()->average();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  size_t average_promoted_in_bytes() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
    return (size_t)avg_promoted()->average();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  size_t padded_average_promoted_in_bytes() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
    return (size_t)avg_promoted()->padded_average();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  int change_young_gen_for_maj_pauses() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
    return _change_young_gen_for_maj_pauses;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  void set_change_young_gen_for_maj_pauses(int v) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
    _change_young_gen_for_maj_pauses = v;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
  int change_old_gen_for_min_pauses() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
    return _change_old_gen_for_min_pauses;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  void set_change_old_gen_for_min_pauses(int v) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
    _change_old_gen_for_min_pauses = v;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  // Return true if the old generation size was changed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  // to try to reach a pause time goal.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  bool old_gen_changed_for_pauses() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
    bool result = _change_old_gen_for_maj_pauses != 0 ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
                  _change_old_gen_for_min_pauses != 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
  // Return true if the young generation size was changed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  // to try to reach a pause time goal.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  bool young_gen_changed_for_pauses() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
    bool result = _change_young_gen_for_min_pauses != 0 ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
                  _change_young_gen_for_maj_pauses != 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  // end flags for pause goal
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  // Return true if the old generation size was changed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  // to try to reach a throughput goal.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  bool old_gen_changed_for_throughput() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
    bool result = _change_old_gen_for_throughput != 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  // Return true if the young generation size was changed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  // to try to reach a throughput goal.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  bool young_gen_changed_for_throughput() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
    bool result = _change_young_gen_for_throughput != 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  int decrease_for_footprint() { return _decrease_for_footprint; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  // Accessors for estimators.  The slope of the linear fit is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  // currently all that is used for making decisions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  LinearLeastSquareFit* major_pause_old_estimator() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
    return _major_pause_old_estimator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  LinearLeastSquareFit* major_pause_young_estimator() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
    return _major_pause_young_estimator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
  virtual void clear_generation_free_space_flags();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
  float major_pause_old_slope() { return _major_pause_old_estimator->slope(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  float major_pause_young_slope() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
    return _major_pause_young_estimator->slope();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  float major_collection_slope() { return _major_collection_estimator->slope();}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  bool old_gen_policy_is_ready() { return _old_gen_policy_is_ready; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  // Given the amount of live data in the heap, should we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  // perform a Full GC?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  bool should_full_GC(size_t live_in_old_gen);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
17393
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 13925
diff changeset
   337
  // Calculates optimal (free) space sizes for both the young and old
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  // generations.  Stores results in _eden_size and _promo_size.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  // Takes current used space in all generations as input, as well
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  // as an indication if a full gc has just been performed, for use
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  // in deciding if an OOM error should be thrown.
17842
0d11fa49f81f 8007762: Rename a bunch of methods in size policy across collectors
tamao
parents: 17393
diff changeset
   342
  void compute_generations_free_space(size_t young_live,
0d11fa49f81f 8007762: Rename a bunch of methods in size policy across collectors
tamao
parents: 17393
diff changeset
   343
                                      size_t eden_live,
0d11fa49f81f 8007762: Rename a bunch of methods in size policy across collectors
tamao
parents: 17393
diff changeset
   344
                                      size_t old_live,
0d11fa49f81f 8007762: Rename a bunch of methods in size policy across collectors
tamao
parents: 17393
diff changeset
   345
                                      size_t cur_eden,  // current eden in bytes
0d11fa49f81f 8007762: Rename a bunch of methods in size policy across collectors
tamao
parents: 17393
diff changeset
   346
                                      size_t max_old_gen_size,
0d11fa49f81f 8007762: Rename a bunch of methods in size policy across collectors
tamao
parents: 17393
diff changeset
   347
                                      size_t max_eden_size,
0d11fa49f81f 8007762: Rename a bunch of methods in size policy across collectors
tamao
parents: 17393
diff changeset
   348
                                      bool   is_full_gc);
17393
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 13925
diff changeset
   349
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 13925
diff changeset
   350
  void compute_eden_space_size(size_t young_live,
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 13925
diff changeset
   351
                               size_t eden_live,
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 13925
diff changeset
   352
                               size_t cur_eden,  // current eden in bytes
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 13925
diff changeset
   353
                               size_t max_eden_size,
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 13925
diff changeset
   354
                               bool   is_full_gc);
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 13925
diff changeset
   355
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 13925
diff changeset
   356
  void compute_old_gen_free_space(size_t old_live,
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 13925
diff changeset
   357
                                             size_t cur_eden,  // current eden in bytes
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 13925
diff changeset
   358
                                             size_t max_old_gen_size,
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 13925
diff changeset
   359
                                             bool   is_full_gc);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  // Calculates new survivor space size;  returns a new tenuring threshold
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
  // value. Stores new survivor size in _survivor_size.
13925
37f75ba502b1 8000351: Tenuring threshold should be unsigned
jwilhelm
parents: 13728
diff changeset
   363
  uint compute_survivor_space_size_and_threshold(bool   is_survivor_overflow,
37f75ba502b1 8000351: Tenuring threshold should be unsigned
jwilhelm
parents: 13728
diff changeset
   364
                                                 uint    tenuring_threshold,
37f75ba502b1 8000351: Tenuring threshold should be unsigned
jwilhelm
parents: 13728
diff changeset
   365
                                                 size_t survivor_limit);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
  // Return the maximum size of a survivor space if the young generation were of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  // size gen_size.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
  size_t max_survivor_size(size_t gen_size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
    // Never allow the target survivor size to grow more than MinSurvivorRatio
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
    // of the young generation size.  We cannot grow into a two semi-space
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
    // system, with Eden zero sized.  Even if the survivor space grows, from()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
    // might grow by moving the bottom boundary "down" -- so from space will
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
    // remain almost full anyway (top() will be near end(), but there will be a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
    // large filler object at the bottom).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
    const size_t sz = gen_size / MinSurvivorRatio;
21561
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents: 20317
diff changeset
   377
    const size_t alignment = _space_alignment;
46619
a3919f5e8d2b 8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents: 35061
diff changeset
   378
    return sz > alignment ? align_down(sz, alignment) : alignment;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
  size_t live_at_last_full_gc() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
    return _live_at_last_full_gc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  size_t bytes_absorbed_from_eden() const { return _bytes_absorbed_from_eden; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
  void   reset_bytes_absorbed_from_eden() { _bytes_absorbed_from_eden = 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  void set_bytes_absorbed_from_eden(size_t val) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
    _bytes_absorbed_from_eden = val;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  // Update averages that are always used (even
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  // if adaptive sizing is turned off).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  void update_averages(bool is_survivor_overflow,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
                       size_t survived,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
                       size_t promoted);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
  // Printing support
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33227
diff changeset
   399
  virtual bool print() const;
17393
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 13925
diff changeset
   400
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 13925
diff changeset
   401
  // Decay the supplemental growth additive.
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 13925
diff changeset
   402
  void decay_supplemental_growth(bool is_full_gc);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   404
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 22555
diff changeset
   405
#endif // SHARE_VM_GC_PARALLEL_PSADAPTIVESIZEPOLICY_HPP