hotspot/src/share/vm/gc/g1/g1YoungGenSizer.hpp
author ehelin
Mon, 07 Mar 2016 10:36:22 +0100
changeset 37041 803d638420d5
child 37985 539c597ee0fa
permissions -rw-r--r--
8151365: Move G1YoungGenSizer to a separate file Reviewed-by: mgerdin, tschatzl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37041
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
     1
/*
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
     4
 *
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
     7
 * published by the Free Software Foundation.
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
     8
 *
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    13
 * accompanied this code).
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    14
 *
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    18
 *
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    21
 * questions.
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    22
 *
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    23
 */
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    24
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    25
#include "memory/allocation.hpp"
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    26
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    27
// There are three command line options related to the young gen size:
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    28
// NewSize, MaxNewSize and NewRatio (There is also -Xmn, but that is
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    29
// just a short form for NewSize==MaxNewSize). G1 will use its internal
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    30
// heuristics to calculate the actual young gen size, so these options
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    31
// basically only limit the range within which G1 can pick a young gen
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    32
// size. Also, these are general options taking byte sizes. G1 will
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    33
// internally work with a number of regions instead. So, some rounding
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    34
// will occur.
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    35
//
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    36
// If nothing related to the the young gen size is set on the command
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    37
// line we should allow the young gen to be between G1NewSizePercent
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    38
// and G1MaxNewSizePercent of the heap size. This means that every time
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    39
// the heap size changes, the limits for the young gen size will be
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    40
// recalculated.
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    41
//
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    42
// If only -XX:NewSize is set we should use the specified value as the
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    43
// minimum size for young gen. Still using G1MaxNewSizePercent of the
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    44
// heap as maximum.
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    45
//
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    46
// If only -XX:MaxNewSize is set we should use the specified value as the
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    47
// maximum size for young gen. Still using G1NewSizePercent of the heap
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    48
// as minimum.
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    49
//
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    50
// If -XX:NewSize and -XX:MaxNewSize are both specified we use these values.
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    51
// No updates when the heap size changes. There is a special case when
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    52
// NewSize==MaxNewSize. This is interpreted as "fixed" and will use a
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    53
// different heuristic for calculating the collection set when we do mixed
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    54
// collection.
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    55
//
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    56
// If only -XX:NewRatio is set we should use the specified ratio of the heap
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    57
// as both min and max. This will be interpreted as "fixed" just like the
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    58
// NewSize==MaxNewSize case above. But we will update the min and max
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    59
// every time the heap size changes.
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    60
//
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    61
// NewSize and MaxNewSize override NewRatio. So, NewRatio is ignored if it is
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    62
// combined with either NewSize or MaxNewSize. (A warning message is printed.)
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    63
class G1YoungGenSizer : public CHeapObj<mtGC> {
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    64
private:
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    65
  enum SizerKind {
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    66
    SizerDefaults,
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    67
    SizerNewSizeOnly,
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    68
    SizerMaxNewSizeOnly,
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    69
    SizerMaxAndNewSize,
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    70
    SizerNewRatio
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    71
  };
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    72
  SizerKind _sizer_kind;
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    73
  uint _min_desired_young_length;
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    74
  uint _max_desired_young_length;
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    75
  bool _adaptive_size;
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    76
  uint calculate_default_min_length(uint new_number_of_heap_regions);
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    77
  uint calculate_default_max_length(uint new_number_of_heap_regions);
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    78
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    79
  // Update the given values for minimum and maximum young gen length in regions
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    80
  // given the number of heap regions depending on the kind of sizing algorithm.
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    81
  void recalculate_min_max_young_length(uint number_of_heap_regions, uint* min_young_length, uint* max_young_length);
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    82
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    83
public:
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    84
  G1YoungGenSizer();
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    85
  // Calculate the maximum length of the young gen given the number of regions
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    86
  // depending on the sizing algorithm.
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    87
  uint max_young_length(uint number_of_heap_regions);
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    88
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    89
  void heap_size_changed(uint new_number_of_heap_regions);
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    90
  uint min_desired_young_length() {
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    91
    return _min_desired_young_length;
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    92
  }
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    93
  uint max_desired_young_length() {
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    94
    return _max_desired_young_length;
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    95
  }
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    96
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    97
  bool adaptive_young_list_length() const {
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    98
    return _adaptive_size;
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
    99
  }
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
   100
};
803d638420d5 8151365: Move G1YoungGenSizer to a separate file
ehelin
parents:
diff changeset
   101