mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-23 12:34:32 +02:00
8149820: Move G1YoungGenSizer to g1CollectorPolicy.cpp
Reviewed-by: jwilhelm, tbenson
This commit is contained in:
parent
cbdc1d3061
commit
65bfc48af1
2 changed files with 105 additions and 100 deletions
|
@ -293,30 +293,84 @@ void G1CollectorPolicy::initialize_alignments() {
|
||||||
_heap_alignment = MAX3(card_table_alignment, _space_alignment, page_size);
|
_heap_alignment = MAX3(card_table_alignment, _space_alignment, page_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void G1CollectorPolicy::initialize_flags() {
|
|
||||||
if (G1HeapRegionSize != HeapRegion::GrainBytes) {
|
|
||||||
FLAG_SET_ERGO(size_t, G1HeapRegionSize, HeapRegion::GrainBytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SurvivorRatio < 1) {
|
|
||||||
vm_exit_during_initialization("Invalid survivor ratio specified");
|
|
||||||
}
|
|
||||||
CollectorPolicy::initialize_flags();
|
|
||||||
_young_gen_sizer = new G1YoungGenSizer(); // Must be after call to initialize_flags
|
|
||||||
}
|
|
||||||
|
|
||||||
void G1CollectorPolicy::post_heap_initialize() {
|
|
||||||
uintx max_regions = G1CollectedHeap::heap()->max_regions();
|
|
||||||
size_t max_young_size = (size_t)_young_gen_sizer->max_young_length(max_regions) * HeapRegion::GrainBytes;
|
|
||||||
if (max_young_size != MaxNewSize) {
|
|
||||||
FLAG_SET_ERGO(size_t, MaxNewSize, max_young_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
_ihop_control = create_ihop_control();
|
|
||||||
}
|
|
||||||
|
|
||||||
G1CollectorState* G1CollectorPolicy::collector_state() const { return _g1->collector_state(); }
|
G1CollectorState* G1CollectorPolicy::collector_state() const { return _g1->collector_state(); }
|
||||||
|
|
||||||
|
// 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 G1NewSizePercent
|
||||||
|
// and G1MaxNewSizePercent of the heap size. This means that every time
|
||||||
|
// the heap size changes, the limits for the young gen size will be
|
||||||
|
// recalculated.
|
||||||
|
//
|
||||||
|
// If only -XX:NewSize is set we should use the specified value as the
|
||||||
|
// minimum size for young gen. Still using G1MaxNewSizePercent 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 G1NewSizePercent 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
|
||||||
|
// every time 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<mtGC> {
|
||||||
|
private:
|
||||||
|
enum SizerKind {
|
||||||
|
SizerDefaults,
|
||||||
|
SizerNewSizeOnly,
|
||||||
|
SizerMaxNewSizeOnly,
|
||||||
|
SizerMaxAndNewSize,
|
||||||
|
SizerNewRatio
|
||||||
|
};
|
||||||
|
SizerKind _sizer_kind;
|
||||||
|
uint _min_desired_young_length;
|
||||||
|
uint _max_desired_young_length;
|
||||||
|
bool _adaptive_size;
|
||||||
|
uint calculate_default_min_length(uint new_number_of_heap_regions);
|
||||||
|
uint calculate_default_max_length(uint new_number_of_heap_regions);
|
||||||
|
|
||||||
|
// Update the given values for minimum and maximum young gen length in regions
|
||||||
|
// given the number of heap regions depending on the kind of sizing algorithm.
|
||||||
|
void recalculate_min_max_young_length(uint number_of_heap_regions, uint* min_young_length, uint* max_young_length);
|
||||||
|
|
||||||
|
public:
|
||||||
|
G1YoungGenSizer();
|
||||||
|
// Calculate the maximum length of the young gen given the number of regions
|
||||||
|
// depending on the sizing algorithm.
|
||||||
|
uint max_young_length(uint number_of_heap_regions);
|
||||||
|
|
||||||
|
void heap_size_changed(uint new_number_of_heap_regions);
|
||||||
|
uint min_desired_young_length() {
|
||||||
|
return _min_desired_young_length;
|
||||||
|
}
|
||||||
|
uint max_desired_young_length() {
|
||||||
|
return _max_desired_young_length;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool adaptive_young_list_length() const {
|
||||||
|
return _adaptive_size;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
G1YoungGenSizer::G1YoungGenSizer() : _sizer_kind(SizerDefaults), _adaptive_size(true),
|
G1YoungGenSizer::G1YoungGenSizer() : _sizer_kind(SizerDefaults), _adaptive_size(true),
|
||||||
_min_desired_young_length(0), _max_desired_young_length(0) {
|
_min_desired_young_length(0), _max_desired_young_length(0) {
|
||||||
if (FLAG_IS_CMDLINE(NewRatio)) {
|
if (FLAG_IS_CMDLINE(NewRatio)) {
|
||||||
|
@ -412,6 +466,29 @@ void G1YoungGenSizer::heap_size_changed(uint new_number_of_heap_regions) {
|
||||||
&_max_desired_young_length);
|
&_max_desired_young_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void G1CollectorPolicy::post_heap_initialize() {
|
||||||
|
uintx max_regions = G1CollectedHeap::heap()->max_regions();
|
||||||
|
size_t max_young_size = (size_t)_young_gen_sizer->max_young_length(max_regions) * HeapRegion::GrainBytes;
|
||||||
|
if (max_young_size != MaxNewSize) {
|
||||||
|
FLAG_SET_ERGO(size_t, MaxNewSize, max_young_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
_ihop_control = create_ihop_control();
|
||||||
|
}
|
||||||
|
|
||||||
|
void G1CollectorPolicy::initialize_flags() {
|
||||||
|
if (G1HeapRegionSize != HeapRegion::GrainBytes) {
|
||||||
|
FLAG_SET_ERGO(size_t, G1HeapRegionSize, HeapRegion::GrainBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SurvivorRatio < 1) {
|
||||||
|
vm_exit_during_initialization("Invalid survivor ratio specified");
|
||||||
|
}
|
||||||
|
CollectorPolicy::initialize_flags();
|
||||||
|
_young_gen_sizer = new G1YoungGenSizer(); // Must be after call to initialize_flags
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void G1CollectorPolicy::init() {
|
void G1CollectorPolicy::init() {
|
||||||
// Set aside an initial future to_space.
|
// Set aside an initial future to_space.
|
||||||
_g1 = G1CollectedHeap::heap();
|
_g1 = G1CollectedHeap::heap();
|
||||||
|
@ -1601,6 +1678,10 @@ bool G1CollectorPolicy::can_expand_young_list() const {
|
||||||
return young_list_length < young_list_max_length;
|
return young_list_length < young_list_max_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool G1CollectorPolicy::adaptive_young_list_length() const {
|
||||||
|
return _young_gen_sizer->adaptive_young_list_length();
|
||||||
|
}
|
||||||
|
|
||||||
void G1CollectorPolicy::update_max_gc_locker_expansion() {
|
void G1CollectorPolicy::update_max_gc_locker_expansion() {
|
||||||
uint expansion_region_num = 0;
|
uint expansion_region_num = 0;
|
||||||
if (GCLockerEdenExpansionPercent > 0) {
|
if (GCLockerEdenExpansionPercent > 0) {
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
class HeapRegion;
|
class HeapRegion;
|
||||||
class CollectionSetChooser;
|
class CollectionSetChooser;
|
||||||
class G1IHOPControl;
|
class G1IHOPControl;
|
||||||
|
class G1YoungGenSizer;
|
||||||
|
|
||||||
// TraceYoungGenTime collects data on _both_ young and mixed evacuation pauses
|
// TraceYoungGenTime collects data on _both_ young and mixed evacuation pauses
|
||||||
// (the latter may contain non-young regions - i.e. regions that are
|
// (the latter may contain non-young regions - i.e. regions that are
|
||||||
|
@ -90,81 +91,6 @@ class TraceOldGenTimeData : public CHeapObj<mtGC> {
|
||||||
void print() const;
|
void print() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 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 G1NewSizePercent
|
|
||||||
// and G1MaxNewSizePercent of the heap size. This means that every time
|
|
||||||
// the heap size changes, the limits for the young gen size will be
|
|
||||||
// recalculated.
|
|
||||||
//
|
|
||||||
// If only -XX:NewSize is set we should use the specified value as the
|
|
||||||
// minimum size for young gen. Still using G1MaxNewSizePercent 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 G1NewSizePercent 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
|
|
||||||
// every time 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<mtGC> {
|
|
||||||
private:
|
|
||||||
enum SizerKind {
|
|
||||||
SizerDefaults,
|
|
||||||
SizerNewSizeOnly,
|
|
||||||
SizerMaxNewSizeOnly,
|
|
||||||
SizerMaxAndNewSize,
|
|
||||||
SizerNewRatio
|
|
||||||
};
|
|
||||||
SizerKind _sizer_kind;
|
|
||||||
uint _min_desired_young_length;
|
|
||||||
uint _max_desired_young_length;
|
|
||||||
bool _adaptive_size;
|
|
||||||
uint calculate_default_min_length(uint new_number_of_heap_regions);
|
|
||||||
uint calculate_default_max_length(uint new_number_of_heap_regions);
|
|
||||||
|
|
||||||
// Update the given values for minimum and maximum young gen length in regions
|
|
||||||
// given the number of heap regions depending on the kind of sizing algorithm.
|
|
||||||
void recalculate_min_max_young_length(uint number_of_heap_regions, uint* min_young_length, uint* max_young_length);
|
|
||||||
|
|
||||||
public:
|
|
||||||
G1YoungGenSizer();
|
|
||||||
// Calculate the maximum length of the young gen given the number of regions
|
|
||||||
// depending on the sizing algorithm.
|
|
||||||
uint max_young_length(uint number_of_heap_regions);
|
|
||||||
|
|
||||||
void heap_size_changed(uint new_number_of_heap_regions);
|
|
||||||
uint min_desired_young_length() {
|
|
||||||
return _min_desired_young_length;
|
|
||||||
}
|
|
||||||
uint max_desired_young_length() {
|
|
||||||
return _max_desired_young_length;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool adaptive_young_list_length() const {
|
|
||||||
return _adaptive_size;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class G1CollectorPolicy: public CollectorPolicy {
|
class G1CollectorPolicy: public CollectorPolicy {
|
||||||
private:
|
private:
|
||||||
G1IHOPControl* _ihop_control;
|
G1IHOPControl* _ihop_control;
|
||||||
|
@ -784,9 +710,7 @@ public:
|
||||||
return _young_list_max_length;
|
return _young_list_max_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool adaptive_young_list_length() const {
|
bool adaptive_young_list_length() const;
|
||||||
return _young_gen_sizer->adaptive_young_list_length();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool should_process_references() const {
|
virtual bool should_process_references() const {
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue