hotspot/src/share/vm/gc_implementation/shared/adaptiveSizePolicy.hpp
author jwilhelm
Thu, 23 Jan 2014 14:47:23 +0100
changeset 22551 9bf46d16dcc6
parent 13963 e5b53c306fb5
child 25485 9c3d427eed01
permissions -rw-r--r--
8025856: Fix typos in the GC code Summary: Fix about 440 typos in comments in the VM code Reviewed-by: mgerdin, tschatzl, coleenp, kmo, jcoomes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
13963
e5b53c306fb5 7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents: 13925
diff changeset
     2
 * Copyright (c) 2004, 2012, 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
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef SHARE_VM_GC_IMPLEMENTATION_SHARED_ADAPTIVESIZEPOLICY_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_GC_IMPLEMENTATION_SHARED_ADAPTIVESIZEPOLICY_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "gc_implementation/shared/gcUtil.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "gc_interface/collectedHeap.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "gc_interface/gcCause.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "memory/allocation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#include "memory/universe.hpp"
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
// size of the heap.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
// Forward decls
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
class elapsedTimer;
5343
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 1
diff changeset
    39
class CollectorPolicy;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 11174
diff changeset
    41
class AdaptiveSizePolicy : public CHeapObj<mtGC> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
 friend class GCAdaptivePolicyCounters;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
 friend class PSGCAdaptivePolicyCounters;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
 friend class CMSGCAdaptivePolicyCounters;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  enum GCPolicyKind {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
    _gc_adaptive_size_policy,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
    _gc_ps_adaptive_size_policy,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    _gc_cms_adaptive_size_policy
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  virtual GCPolicyKind kind() const { return _gc_adaptive_size_policy; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  enum SizePolicyTrueValues {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    decrease_old_gen_for_throughput_true = -7,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    decrease_young_gen_for_througput_true = -6,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
    increase_old_gen_for_min_pauses_true = -5,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
    decrease_old_gen_for_min_pauses_true = -4,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    decrease_young_gen_for_maj_pauses_true = -3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
    increase_young_gen_for_min_pauses_true = -2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
    increase_old_gen_for_maj_pauses_true = -1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    decrease_young_gen_for_min_pauses_true = 1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
    decrease_old_gen_for_maj_pauses_true = 2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
    increase_young_gen_for_maj_pauses_true = 3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    increase_old_gen_for_throughput_true = 4,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
    increase_young_gen_for_througput_true = 5,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    decrease_young_gen_for_footprint_true = 6,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
    decrease_old_gen_for_footprint_true = 7,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
    decide_at_full_gc_true = 8
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  // Goal for the fraction of the total time during which application
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 13963
diff changeset
    77
  // threads run
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  const double _throughput_goal;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  // Last calculated sizes, in bytes, and aligned
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  size_t _eden_size;        // calculated eden free space in bytes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  size_t _promo_size;       // calculated cms gen free space in bytes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  size_t _survivor_size;    // calculated survivor size in bytes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 13963
diff changeset
    86
  // This is a hint for the heap:  we've detected that GC times
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  // are taking longer than GCTimeLimit allows.
5343
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 1
diff changeset
    88
  bool _gc_overhead_limit_exceeded;
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 1
diff changeset
    89
  // Use for diagnostics only.  If UseGCOverheadLimit is false,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  // this variable is still set.
5343
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 1
diff changeset
    91
  bool _print_gc_overhead_limit_would_be_exceeded;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  // Count of consecutive GC that have exceeded the
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 13963
diff changeset
    93
  // GC time limit criterion
5343
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 1
diff changeset
    94
  uint _gc_overhead_limit_count;
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 1
diff changeset
    95
  // This flag signals that GCTimeLimit is being exceeded
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 13963
diff changeset
    96
  // but may not have done so for the required number of consecutive
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 13963
diff changeset
    97
  // collections
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  // Minor collection timers used to determine both
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 13963
diff changeset
   100
  // pause and interval times for collections
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  static elapsedTimer _minor_timer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  // Major collection timers, used to determine both
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  // pause and interval times for collections
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  static elapsedTimer _major_timer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  // Time statistics
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  AdaptivePaddedAverage*   _avg_minor_pause;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  AdaptiveWeightedAverage* _avg_minor_interval;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  AdaptiveWeightedAverage* _avg_minor_gc_cost;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  AdaptiveWeightedAverage* _avg_major_interval;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  AdaptiveWeightedAverage* _avg_major_gc_cost;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  // Footprint statistics
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  AdaptiveWeightedAverage* _avg_young_live;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  AdaptiveWeightedAverage* _avg_eden_live;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  AdaptiveWeightedAverage* _avg_old_live;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  // Statistics for survivor space calculation for young generation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  AdaptivePaddedAverage*   _avg_survived;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 13963
diff changeset
   123
  // Objects that have been directly allocated in the old generation
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  AdaptivePaddedNoZeroDevAverage*   _avg_pretenured;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  // Variable for estimating the major and minor pause times.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  // These variables represent linear least-squares fits of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  // the data.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  //   minor pause time vs. old gen size
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  LinearLeastSquareFit* _minor_pause_old_estimator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  //   minor pause time vs. young gen size
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  LinearLeastSquareFit* _minor_pause_young_estimator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  // Variables for estimating the major and minor collection costs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  //   minor collection time vs. young gen size
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  LinearLeastSquareFit* _minor_collection_estimator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  //   major collection time vs. cms gen size
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  LinearLeastSquareFit* _major_collection_estimator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  // These record the most recent collection times.  They
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  // are available as an alternative to using the averages
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  // for making ergonomic decisions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  double _latest_minor_mutator_interval_seconds;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 13963
diff changeset
   145
  // Allowed difference between major and minor GC times, used
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 13963
diff changeset
   146
  // for computing tenuring_threshold
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  const double _threshold_tolerance_percent;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 13963
diff changeset
   149
  const double _gc_pause_goal_sec; // Goal for maximum GC pause
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  // Flag indicating that the adaptive policy is ready to use
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  bool _young_gen_policy_is_ready;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 13963
diff changeset
   154
  // Decrease/increase the young generation for minor pause time
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  int _change_young_gen_for_min_pauses;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 13963
diff changeset
   157
  // Decrease/increase the old generation for major pause time
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  int _change_old_gen_for_maj_pauses;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 13963
diff changeset
   160
  //   change old generation for throughput
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  int _change_old_gen_for_throughput;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  //   change young generation for throughput
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  int _change_young_gen_for_throughput;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  // Flag indicating that the policy would
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 13963
diff changeset
   167
  //   increase the tenuring threshold because of the total major GC cost
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 13963
diff changeset
   168
  //   is greater than the total minor GC cost
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  bool _increment_tenuring_threshold_for_gc_cost;
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 13963
diff changeset
   170
  //   decrease the tenuring threshold because of the the total minor GC
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 13963
diff changeset
   171
  //   cost is greater than the total major GC cost
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  bool _decrement_tenuring_threshold_for_gc_cost;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  //   decrease due to survivor size limit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  bool _decrement_tenuring_threshold_for_survivor_limit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  //   decrease generation sizes for footprint
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  int _decrease_for_footprint;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  // Set if the ergonomic decisions were made at a full GC.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  int _decide_at_full_gc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  // Changing the generation sizing depends on the data that is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  // gathered about the effects of changes on the pause times and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  // throughput.  These variable count the number of data points
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 13963
diff changeset
   185
  // gathered.  The policy may use these counters as a threshold
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  // for reliable data.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  julong _young_gen_change_for_minor_throughput;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  julong _old_gen_change_for_major_throughput;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   190
  static const uint GCWorkersPerJavaThread  = 2;
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   191
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  // Accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  double gc_pause_goal_sec() const { return _gc_pause_goal_sec; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  // The value returned is unitless:  it's the proportion of time
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  // spent in a particular collection type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  // An interval time will be 0.0 if a collection type hasn't occurred yet.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  // The 1.4.2 implementation put a floor on the values of major_gc_cost
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  // and minor_gc_cost.  This was useful because of the way major_gc_cost
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  // and minor_gc_cost was used in calculating the sizes of the generations.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  // Do not use a floor in this implementation because any finite value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  // will put a limit on the throughput that can be achieved and any
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  // throughput goal above that limit will drive the generations sizes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  // to extremes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  double major_gc_cost() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
    return MAX2(0.0F, _avg_major_gc_cost->average());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  // The value returned is unitless:  it's the proportion of time
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  // spent in a particular collection type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  // An interval time will be 0.0 if a collection type hasn't occurred yet.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  // The 1.4.2 implementation put a floor on the values of major_gc_cost
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  // and minor_gc_cost.  This was useful because of the way major_gc_cost
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  // and minor_gc_cost was used in calculating the sizes of the generations.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  // Do not use a floor in this implementation because any finite value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  // will put a limit on the throughput that can be achieved and any
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  // throughput goal above that limit will drive the generations sizes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  // to extremes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  double minor_gc_cost() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
    return MAX2(0.0F, _avg_minor_gc_cost->average());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  // Because we're dealing with averages, gc_cost() can be
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  // larger than 1.0 if just the sum of the minor cost the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  // the major cost is used.  Worse than that is the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  // fact that the minor cost and the major cost each
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 13963
diff changeset
   228
  // tend toward 1.0 in the extreme of high GC costs.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  // Limit the value of gc_cost to 1.0 so that the mutator
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  // cost stays non-negative.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  virtual double gc_cost() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
    double result = MIN2(1.0, minor_gc_cost() + major_gc_cost());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
    assert(result >= 0.0, "Both minor and major costs are non-negative");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  // Elapsed time since the last major collection.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  virtual double time_since_major_gc() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  // Average interval between major collections to be used
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 13963
diff changeset
   241
  // in calculating the decaying major GC cost.  An overestimate
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  // of this time would be a conservative estimate because
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  // this time is used to decide if the major GC cost
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  // should be decayed (i.e., if the time since the last
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 13963
diff changeset
   245
  // major GC is long compared to the time returned here,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  // then the major GC cost will be decayed).  See the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  // implementations for the specifics.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  virtual double major_gc_interval_average_for_decay() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
    return _avg_major_interval->average();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 13963
diff changeset
   252
  // Return the cost of the GC where the major GC cost
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  // has been decayed based on the time since the last
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  // major collection.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  double decaying_gc_cost() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 13963
diff changeset
   257
  // Decay the major GC cost.  Use this only for decisions on
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  // whether to adjust, not to determine by how much to adjust.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  // This approximation is crude and may not be good enough for the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  // latter.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  double decaying_major_gc_cost() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  // Return the mutator cost using the decayed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  // GC cost.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  double adjusted_mutator_cost() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
    double result = 1.0 - decaying_gc_cost();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
    assert(result >= 0.0, "adjusted mutator cost calculation is incorrect");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  virtual double mutator_cost() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
    double result = 1.0 - gc_cost();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
    assert(result >= 0.0, "mutator cost calculation is incorrect");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  bool young_gen_policy_is_ready() { return _young_gen_policy_is_ready; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  void update_minor_pause_young_estimator(double minor_pause_in_ms);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  virtual void update_minor_pause_old_estimator(double minor_pause_in_ms) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
    // This is not meaningful for all policies but needs to be present
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
    // to use minor_collection_end() in its current form.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  virtual size_t eden_increment(size_t cur_eden);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  virtual size_t eden_increment(size_t cur_eden, uint percent_change);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  virtual size_t eden_decrement(size_t cur_eden);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  virtual size_t promo_increment(size_t cur_eden);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  virtual size_t promo_increment(size_t cur_eden, uint percent_change);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  virtual size_t promo_decrement(size_t cur_eden);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  virtual void clear_generation_free_space_flags();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  int change_old_gen_for_throughput() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
    return _change_old_gen_for_throughput;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  void set_change_old_gen_for_throughput(int v) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
    _change_old_gen_for_throughput = v;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  int change_young_gen_for_throughput() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
    return _change_young_gen_for_throughput;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  void set_change_young_gen_for_throughput(int v) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
    _change_young_gen_for_throughput = v;
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 change_old_gen_for_maj_pauses() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
    return _change_old_gen_for_maj_pauses;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  void set_change_old_gen_for_maj_pauses(int v) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
    _change_old_gen_for_maj_pauses = v;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  bool decrement_tenuring_threshold_for_gc_cost() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
    return _decrement_tenuring_threshold_for_gc_cost;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  void set_decrement_tenuring_threshold_for_gc_cost(bool v) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
    _decrement_tenuring_threshold_for_gc_cost = v;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  bool increment_tenuring_threshold_for_gc_cost() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
    return _increment_tenuring_threshold_for_gc_cost;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  void set_increment_tenuring_threshold_for_gc_cost(bool v) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
    _increment_tenuring_threshold_for_gc_cost = v;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
  bool decrement_tenuring_threshold_for_survivor_limit() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
    return _decrement_tenuring_threshold_for_survivor_limit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  void set_decrement_tenuring_threshold_for_survivor_limit(bool v) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
    _decrement_tenuring_threshold_for_survivor_limit = v;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  // Return true if the policy suggested a change.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  bool tenuring_threshold_change() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   336
  static bool _debug_perturbation;
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   337
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  AdaptiveSizePolicy(size_t init_eden_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
                     size_t init_promo_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
                     size_t init_survivor_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
                     double gc_pause_goal_sec,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
                     uint gc_cost_ratio);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   345
  // Return number default  GC threads to use in the next GC.
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   346
  static int calc_default_active_workers(uintx total_workers,
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   347
                                         const uintx min_workers,
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   348
                                         uintx active_workers,
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   349
                                         uintx application_workers);
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   350
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   351
  // Return number of GC threads to use in the next GC.
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   352
  // This is called sparingly so as not to change the
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   353
  // number of GC workers gratuitously.
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   354
  //   For ParNew collections
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   355
  //   For PS scavenge and ParOld collections
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   356
  //   For G1 evacuation pauses (subject to update)
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   357
  // Other collection phases inherit the number of
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   358
  // GC workers from the calls above.  For example,
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   359
  // a CMS parallel remark uses the same number of GC
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   360
  // workers as the most recent ParNew collection.
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   361
  static int calc_active_workers(uintx total_workers,
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   362
                                 uintx active_workers,
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   363
                                 uintx application_workers);
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   364
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   365
  // Return number of GC threads to use in the next concurrent GC phase.
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   366
  static int calc_active_conc_workers(uintx total_workers,
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   367
                                      uintx active_workers,
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   368
                                      uintx application_workers);
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   369
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
  bool is_gc_cms_adaptive_size_policy() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
    return kind() == _gc_cms_adaptive_size_policy;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  bool is_gc_ps_adaptive_size_policy() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
    return kind() == _gc_ps_adaptive_size_policy;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
  AdaptivePaddedAverage*   avg_minor_pause() const { return _avg_minor_pause; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  AdaptiveWeightedAverage* avg_minor_interval() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
    return _avg_minor_interval;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
  AdaptiveWeightedAverage* avg_minor_gc_cost() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
    return _avg_minor_gc_cost;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  AdaptiveWeightedAverage* avg_major_gc_cost() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
    return _avg_major_gc_cost;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
  AdaptiveWeightedAverage* avg_young_live() const { return _avg_young_live; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
  AdaptiveWeightedAverage* avg_eden_live() const { return _avg_eden_live; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
  AdaptiveWeightedAverage* avg_old_live() const { return _avg_old_live; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  AdaptivePaddedAverage*  avg_survived() const { return _avg_survived; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  AdaptivePaddedNoZeroDevAverage*  avg_pretenured() { return _avg_pretenured; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  // Methods indicating events of interest to the adaptive size policy,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
  // called by GC algorithms. It is the responsibility of users of this
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
  // policy to call these methods at the correct times!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  virtual void minor_collection_begin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
  virtual void minor_collection_end(GCCause::Cause gc_cause);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  virtual LinearLeastSquareFit* minor_pause_old_estimator() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
    return _minor_pause_old_estimator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
  LinearLeastSquareFit* minor_pause_young_estimator() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
    return _minor_pause_young_estimator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
  LinearLeastSquareFit* minor_collection_estimator() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
    return _minor_collection_estimator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  LinearLeastSquareFit* major_collection_estimator() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
    return _major_collection_estimator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  float minor_pause_young_slope() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
    return _minor_pause_young_estimator->slope();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
  float minor_collection_slope() { return _minor_collection_estimator->slope();}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  float major_collection_slope() { return _major_collection_estimator->slope();}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  float minor_pause_old_slope() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
    return _minor_pause_old_estimator->slope();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
  void set_eden_size(size_t new_size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
    _eden_size = new_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
  void set_survivor_size(size_t new_size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
    _survivor_size = new_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  size_t calculated_eden_size_in_bytes() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
    return _eden_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  size_t calculated_promo_size_in_bytes() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
    return _promo_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
  size_t calculated_survivor_size_in_bytes() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
    return _survivor_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
  // This is a hint for the heap:  we've detected that gc times
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
  // are taking longer than GCTimeLimit allows.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
  // Most heaps will choose to throw an OutOfMemoryError when
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
  // this occurs but it is up to the heap to request this information
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  // of the policy
5343
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 1
diff changeset
   451
  bool gc_overhead_limit_exceeded() {
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 1
diff changeset
   452
    return _gc_overhead_limit_exceeded;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
  }
5343
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 1
diff changeset
   454
  void set_gc_overhead_limit_exceeded(bool v) {
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 1
diff changeset
   455
    _gc_overhead_limit_exceeded = v;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
5343
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 1
diff changeset
   458
  // Tests conditions indicate the GC overhead limit is being approached.
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 1
diff changeset
   459
  bool gc_overhead_limit_near() {
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 1
diff changeset
   460
    return gc_overhead_limit_count() >=
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 1
diff changeset
   461
        (AdaptiveSizePolicyGCTimeLimitThreshold - 1);
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 1
diff changeset
   462
  }
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 1
diff changeset
   463
  uint gc_overhead_limit_count() { return _gc_overhead_limit_count; }
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 1
diff changeset
   464
  void reset_gc_overhead_limit_count() { _gc_overhead_limit_count = 0; }
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 1
diff changeset
   465
  void inc_gc_overhead_limit_count() { _gc_overhead_limit_count++; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
  // accessors for flags recording the decisions to resize the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  // generations to meet the pause goal.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  int change_young_gen_for_min_pauses() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
    return _change_young_gen_for_min_pauses;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
  void set_change_young_gen_for_min_pauses(int v) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
    _change_young_gen_for_min_pauses = v;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
  void set_decrease_for_footprint(int v) { _decrease_for_footprint = v; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
  int decrease_for_footprint() const { return _decrease_for_footprint; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
  int decide_at_full_gc() { return _decide_at_full_gc; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
  void set_decide_at_full_gc(int v) { _decide_at_full_gc = v; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
5343
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 1
diff changeset
   480
  // Check the conditions for an out-of-memory due to excessive GC time.
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 1
diff changeset
   481
  // Set _gc_overhead_limit_exceeded if all the conditions have been met.
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 1
diff changeset
   482
  void check_gc_overhead_limit(size_t young_live,
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 1
diff changeset
   483
                               size_t eden_live,
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 1
diff changeset
   484
                               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
   485
                               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
   486
                               bool   is_full_gc,
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 1
diff changeset
   487
                               GCCause::Cause gc_cause,
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 1
diff changeset
   488
                               CollectorPolicy* collector_policy);
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 1
diff changeset
   489
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
  // Printing support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  virtual bool print_adaptive_size_policy_on(outputStream* st) const;
13925
37f75ba502b1 8000351: Tenuring threshold should be unsigned
jwilhelm
parents: 13195
diff changeset
   492
  bool print_adaptive_size_policy_on(outputStream* st,
37f75ba502b1 8000351: Tenuring threshold should be unsigned
jwilhelm
parents: 13195
diff changeset
   493
                                     uint tenuring_threshold) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
// Class that can be used to print information about the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
// adaptive size policy at intervals specified by
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
// AdaptiveSizePolicyOutputInterval.  Only print information
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
// if an adaptive size policy is in use.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
class AdaptiveSizePolicyOutput : StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
  AdaptiveSizePolicy* _size_policy;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
  bool _do_print;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
  bool print_test(uint count) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
    // A count of zero is a special value that indicates that the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
    // interval test should be ignored.  An interval is of zero is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
    // a special value that indicates that the interval test should
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
    // always fail (never do the print based on the interval test).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
    return PrintGCDetails &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
           UseAdaptiveSizePolicy &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
           (UseParallelGC || UseConcMarkSweepGC) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
           (AdaptiveSizePolicyOutputInterval > 0) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
           ((count == 0) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
             ((count % AdaptiveSizePolicyOutputInterval) == 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
  // The special value of a zero count can be used to ignore
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
  // the count test.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
  AdaptiveSizePolicyOutput(uint count) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
    if (UseAdaptiveSizePolicy && (AdaptiveSizePolicyOutputInterval > 0)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
      CollectedHeap* heap = Universe::heap();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
      _size_policy = heap->size_policy();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
      _do_print = print_test(count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
      _size_policy = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
      _do_print = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
  AdaptiveSizePolicyOutput(AdaptiveSizePolicy* size_policy,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
                           uint count) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
    _size_policy(size_policy) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
    if (UseAdaptiveSizePolicy && (AdaptiveSizePolicyOutputInterval > 0)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
      _do_print = print_test(count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
      _do_print = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
  ~AdaptiveSizePolicyOutput() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
    if (_do_print) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
      assert(UseAdaptiveSizePolicy, "Should not be in use");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
      _size_policy->print_adaptive_size_policy_on(gclog_or_tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   544
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   545
#endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_ADAPTIVESIZEPOLICY_HPP