< prev index next >

src/hotspot/share/gc/g1/g1YoungGenSizer.hpp

Print this page




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_GC_G1_G1YOUNGGENSIZER_HPP
  26 #define SHARE_GC_G1_G1YOUNGGENSIZER_HPP
  27 

  28 #include "utilities/globalDefinitions.hpp"
  29 
  30 // There are three command line options related to the young gen size:
  31 // NewSize, MaxNewSize and NewRatio (There is also -Xmn, but that is
  32 // just a short form for NewSize==MaxNewSize). G1 will use its internal
  33 // heuristics to calculate the actual young gen size, so these options
  34 // basically only limit the range within which G1 can pick a young gen
  35 // size. Also, these are general options taking byte sizes. G1 will
  36 // internally work with a number of regions instead. So, some rounding
  37 // will occur.
  38 //
  39 // If nothing related to the the young gen size is set on the command
  40 // line we should allow the young gen to be between G1NewSizePercent
  41 // and G1MaxNewSizePercent of the heap size. This means that every time
  42 // the heap size changes, the limits for the young gen size will be
  43 // recalculated.
  44 //
  45 // If only -XX:NewSize is set we should use the specified value as the
  46 // minimum size for young gen. Still using G1MaxNewSizePercent of the
  47 // heap as maximum.


  59 // If only -XX:NewRatio is set we should use the specified ratio of the heap
  60 // as both min and max. This will be interpreted as "fixed" just like the
  61 // NewSize==MaxNewSize case above. But we will update the min and max
  62 // every time the heap size changes.
  63 //
  64 // NewSize and MaxNewSize override NewRatio. So, NewRatio is ignored if it is
  65 // combined with either NewSize or MaxNewSize. (A warning message is printed.)
  66 class G1YoungGenSizer : public CHeapObj<mtGC> {
  67 private:
  68   enum SizerKind {
  69     SizerDefaults,
  70     SizerNewSizeOnly,
  71     SizerMaxNewSizeOnly,
  72     SizerMaxAndNewSize,
  73     SizerNewRatio
  74   };
  75   SizerKind _sizer_kind;
  76 
  77   // False when using a fixed young generation size due to command-line options,
  78   // true otherwise.
  79   bool _use_adaptive_sizing;
  80 
  81   uint calculate_default_min_length(uint new_number_of_heap_regions);
  82   uint calculate_default_max_length(uint new_number_of_heap_regions);
  83 
  84   // Update the given values for minimum and maximum young gen length in regions
  85   // given the number of heap regions depending on the kind of sizing algorithm.
  86   void recalculate_min_max_young_length(uint number_of_heap_regions, uint* min_young_length, uint* max_young_length);
  87 
  88 protected:
  89   uint _min_desired_young_length;
  90   uint _max_desired_young_length;
  91 
  92 public:
  93   G1YoungGenSizer();
  94   // Calculate the maximum length of the young gen given the number of regions
  95   // depending on the sizing algorithm.
  96   virtual void adjust_max_new_size(uint number_of_heap_regions);
  97 
  98   virtual void heap_size_changed(uint new_number_of_heap_regions);
  99   uint min_desired_young_length() const {
 100     return _min_desired_young_length;
 101   }
 102   uint max_desired_young_length() const {
 103     return _max_desired_young_length;
 104   }
 105 
 106   bool use_adaptive_young_list_length() const {
 107     return _use_adaptive_sizing;
 108   }
 109 
 110   static G1YoungGenSizer* create_gen_sizer();
 111 };
 112 
 113 #endif // SHARE_GC_G1_G1YOUNGGENSIZER_HPP


   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_GC_G1_G1YOUNGGENSIZER_HPP
  26 #define SHARE_GC_G1_G1YOUNGGENSIZER_HPP
  27 
  28 #include "gc/g1/g1CollectorPolicy.hpp"
  29 #include "utilities/globalDefinitions.hpp"
  30 
  31 // There are three command line options related to the young gen size:
  32 // NewSize, MaxNewSize and NewRatio (There is also -Xmn, but that is
  33 // just a short form for NewSize==MaxNewSize). G1 will use its internal
  34 // heuristics to calculate the actual young gen size, so these options
  35 // basically only limit the range within which G1 can pick a young gen
  36 // size. Also, these are general options taking byte sizes. G1 will
  37 // internally work with a number of regions instead. So, some rounding
  38 // will occur.
  39 //
  40 // If nothing related to the the young gen size is set on the command
  41 // line we should allow the young gen to be between G1NewSizePercent
  42 // and G1MaxNewSizePercent of the heap size. This means that every time
  43 // the heap size changes, the limits for the young gen size will be
  44 // recalculated.
  45 //
  46 // If only -XX:NewSize is set we should use the specified value as the
  47 // minimum size for young gen. Still using G1MaxNewSizePercent of the
  48 // heap as maximum.


  60 // If only -XX:NewRatio is set we should use the specified ratio of the heap
  61 // as both min and max. This will be interpreted as "fixed" just like the
  62 // NewSize==MaxNewSize case above. But we will update the min and max
  63 // every time the heap size changes.
  64 //
  65 // NewSize and MaxNewSize override NewRatio. So, NewRatio is ignored if it is
  66 // combined with either NewSize or MaxNewSize. (A warning message is printed.)
  67 class G1YoungGenSizer : public CHeapObj<mtGC> {
  68 private:
  69   enum SizerKind {
  70     SizerDefaults,
  71     SizerNewSizeOnly,
  72     SizerMaxNewSizeOnly,
  73     SizerMaxAndNewSize,
  74     SizerNewRatio
  75   };
  76   SizerKind _sizer_kind;
  77 
  78   // False when using a fixed young generation size due to command-line options,
  79   // true otherwise.
  80   bool _adaptive_size;
  81 
  82   uint calculate_default_min_length(uint new_number_of_heap_regions);
  83   uint calculate_default_max_length(uint new_number_of_heap_regions);
  84 
  85   // Update the given values for minimum and maximum young gen length in regions
  86   // given the number of heap regions depending on the kind of sizing algorithm.
  87   void recalculate_min_max_young_length(uint number_of_heap_regions, uint* min_young_length, uint* max_young_length);
  88 
  89 protected:
  90   uint _min_desired_young_length;
  91   uint _max_desired_young_length;
  92 
  93 public:
  94   G1YoungGenSizer();
  95   // Calculate the maximum length of the young gen given the number of regions
  96   // depending on the sizing algorithm.
  97   virtual void adjust_max_new_size(uint number_of_heap_regions);
  98 
  99   virtual void heap_size_changed(uint new_number_of_heap_regions);
 100   uint min_desired_young_length() const {
 101     return _min_desired_young_length;
 102   }
 103   uint max_desired_young_length() const {
 104     return _max_desired_young_length;
 105   }
 106 
 107   bool adaptive_young_list_length() const {
 108     return _adaptive_size;
 109   }
 110 
 111   static G1YoungGenSizer* create_gen_sizer(G1CollectorPolicy* policy);
 112 };
 113 
 114 #endif // SHARE_GC_G1_G1YOUNGGENSIZER_HPP
< prev index next >