src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp
Print this page
rev 2895 : 7113021: G1: automatically enable young gen size auto-tuning when -Xms==-Xmx
Summary: Use a percentage of -Xms as min and another percentage of -Xmx as max for the young gen size
Reviewed-by: tonyp
*** 81,90 ****
--- 81,153 ----
public MainBodySummary {
public:
virtual MainBodySummary* main_body_summary() { return this; }
};
+ // There are three command line options related to the young gen size:
+ // NewSize, MaxNewSize and NewRatio (There is also -Xmn, but that is
+ // just a short form for NewSize==MaxNewSize). G1 will use its internal
+ // heuristics to calculate the actual young gen size, so these options
+ // basically only limit the range within which G1 can pick a young gen
+ // size. Also, these are general options taking byte sizes. G1 will
+ // internally work with a number of regions instead. So, some rounding
+ // will occur.
+ //
+ // If nothing related to the the young gen size is set on the command
+ // line we should allow the young gen to be between 20% and 50% of the
+ // heap size. This means that every time the heap size changes the
+ // limits for the young gen size will be updated.
+ //
+ // If only -XX:NewSize is set we should use the specified value as the
+ // minimum size for young gen. Still using 50% of the heap as maximum.
+ //
+ // If only -XX:MaxNewSize is set we should use the specified value as the
+ // maximum size for young gen. Still using 20% of the heap as minimum.
+ //
+ // If -XX:NewSize and -XX:MaxNewSize are both specified we use these values.
+ // No updates when the heap size changes. There is a special case when
+ // NewSize==MaxNewSize. This is interpreted as "fixed" and will use a
+ // different heuristic for calculating the collection set when we do mixed
+ // collection.
+ //
+ // If only -XX:NewRatio is set we should use the specified ratio of the heap
+ // as both min and max. This will be interpreted as "fixed" just like the
+ // NewSize==MaxNewSize case above. But we will update the min and max
+ // everytime the heap size changes.
+ //
+ // NewSize and MaxNewSize override NewRatio. So, NewRatio is ignored if it is
+ // combined with either NewSize or MaxNewSize. (A warning message is printed.)
+ class G1YoungGenSizer : public CHeapObj {
+ private:
+ enum SizerKind {
+ SizerDefaults,
+ SizerNewSizeOnly,
+ SizerMaxNewSizeOnly,
+ SizerMaxAndNewSize,
+ SizerNewRatio
+ };
+ SizerKind _sizer_kind;
+ size_t _min_desired_young_length;
+ size_t _max_desired_young_length;
+ bool _adaptive_size;
+ size_t calculate_default_min_size(size_t new_number_of_heap_regions);
+ size_t calculate_default_max_size(size_t new_number_of_heap_regions);
+
+ public:
+ G1YoungGenSizer();
+ void heap_size_changed(size_t new_number_of_heap_regions);
+ size_t min_desired_young_length() {
+ return _min_desired_young_length;
+ }
+ size_t max_desired_young_length() {
+ return _max_desired_young_length;
+ }
+ bool adaptive_young_list_length() {
+ return _adaptive_size;
+ }
+ };
+
class G1CollectorPolicy: public CollectorPolicy {
private:
// either equal to the number of parallel threads, if ParallelGCThreads
// has been set, or 1 otherwise
int _parallel_gc_threads;
*** 165,177 ****
double* _par_last_gc_worker_other_times_ms;
// indicates whether we are in young or mixed GC mode
bool _gcs_are_young;
- // if true, then it tries to dynamically adjust the length of the
- // young list
- bool _adaptive_young_list_length;
size_t _young_list_target_length;
size_t _young_list_fixed_length;
size_t _prev_eden_capacity; // used for logging
// The max number of regions we can extend the eden by while the GC
--- 228,237 ----
*** 225,237 ****
TruncatedSeq* _cost_per_byte_ms_during_cm_seq;
TruncatedSeq* _young_gc_eff_seq;
! bool _using_new_ratio_calculations;
! size_t _min_desired_young_length; // as set on the command line or default calculations
! size_t _max_desired_young_length; // as set on the command line or default calculations
size_t _eden_cset_region_length;
size_t _survivor_cset_region_length;
size_t _old_cset_region_length;
--- 285,295 ----
TruncatedSeq* _cost_per_byte_ms_during_cm_seq;
TruncatedSeq* _young_gc_eff_seq;
! G1YoungGenSizer* _young_gen_sizer;
size_t _eden_cset_region_length;
size_t _survivor_cset_region_length;
size_t _old_cset_region_length;
*** 680,691 ****
size_t base_free_regions, double target_pause_time_ms);
// Count the number of bytes used in the CS.
void count_CS_bytes_used();
- void update_young_list_size_using_newratio(size_t number_of_heap_regions);
-
public:
G1CollectorPolicy();
virtual G1CollectorPolicy* as_g1_policy() { return this; }
--- 738,747 ----
*** 708,719 ****
}
// This should be called after the heap is resized.
void record_new_heap_size(size_t new_number_of_regions);
- public:
-
void init();
// Create jstat counters for the policy.
virtual void initialize_gc_policy_counters();
--- 764,773 ----
*** 996,1009 ****
void set_gcs_are_young(bool gcs_are_young) {
_gcs_are_young = gcs_are_young;
}
bool adaptive_young_list_length() {
! return _adaptive_young_list_length;
! }
! void set_adaptive_young_list_length(bool adaptive_young_list_length) {
! _adaptive_young_list_length = adaptive_young_list_length;
}
inline double get_gc_eff_factor() {
double ratio = _known_garbage_ratio;
--- 1050,1060 ----
void set_gcs_are_young(bool gcs_are_young) {
_gcs_are_young = gcs_are_young;
}
bool adaptive_young_list_length() {
! return _young_gen_sizer->adaptive_young_list_length();
}
inline double get_gc_eff_factor() {
double ratio = _known_garbage_ratio;