8154745: Move default G1 pause time target setup to argument parsing

Reviewed-by: ehelin, sjohanss
This commit is contained in:
Mikael Gerdin 2016-04-19 14:53:32 +02:00
parent 7587fbdd30
commit 91b2afa99d
4 changed files with 32 additions and 39 deletions

View File

@ -47,43 +47,6 @@ G1CollectorPolicy::G1CollectorPolicy() {
// unaligned values for the heap. // unaligned values for the heap.
HeapRegion::setup_heap_region_size(InitialHeapSize, MaxHeapSize); HeapRegion::setup_heap_region_size(InitialHeapSize, MaxHeapSize);
HeapRegionRemSet::setup_remset_size(); HeapRegionRemSet::setup_remset_size();
// Below, we might need to calculate the pause time target based on
// the pause interval. When we do so we are going to give G1 maximum
// flexibility and allow it to do pauses when it needs to. So, we'll
// arrange that the pause interval to be pause time target + 1 to
// ensure that a) the pause time target is maximized with respect to
// the pause interval and b) we maintain the invariant that pause
// time target < pause interval. If the user does not want this
// maximum flexibility, they will have to set the pause interval
// explicitly.
// First make sure that, if either parameter is set, its value is
// reasonable.
guarantee(MaxGCPauseMillis >= 1, "Range checking for MaxGCPauseMillis should guarantee that value is >= 1");
// Then, if the pause time target parameter was not set, set it to
// the default value.
if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) {
if (FLAG_IS_DEFAULT(GCPauseIntervalMillis)) {
// The default pause time target in G1 is 200ms
FLAG_SET_DEFAULT(MaxGCPauseMillis, 200);
} else {
// We do not allow the pause interval to be set without the
// pause time target
vm_exit_during_initialization("GCPauseIntervalMillis cannot be set "
"without setting MaxGCPauseMillis");
}
}
// Then, if the interval parameter was not set, set it according to
// the pause time target (this will also deal with the case when the
// pause time target is the default value).
if (FLAG_IS_DEFAULT(GCPauseIntervalMillis)) {
FLAG_SET_DEFAULT(GCPauseIntervalMillis, MaxGCPauseMillis + 1);
}
guarantee(GCPauseIntervalMillis >= 1, "Constraint for GCPauseIntervalMillis should guarantee that value is >= 1");
guarantee(GCPauseIntervalMillis > MaxGCPauseMillis, "Constraint for GCPauseIntervalMillis should guarantee that GCPauseIntervalMillis > MaxGCPauseMillis");
} }
void G1CollectorPolicy::initialize_alignments() { void G1CollectorPolicy::initialize_alignments() {

View File

@ -2116,6 +2116,28 @@ void Arguments::set_g1_gc_flags() {
FLAG_SET_DEFAULT(GCTimeRatio, 12); FLAG_SET_DEFAULT(GCTimeRatio, 12);
} }
// Below, we might need to calculate the pause time interval based on
// the pause target. When we do so we are going to give G1 maximum
// flexibility and allow it to do pauses when it needs to. So, we'll
// arrange that the pause interval to be pause time target + 1 to
// ensure that a) the pause time target is maximized with respect to
// the pause interval and b) we maintain the invariant that pause
// time target < pause interval. If the user does not want this
// maximum flexibility, they will have to set the pause interval
// explicitly.
if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) {
// The default pause time target in G1 is 200ms
FLAG_SET_DEFAULT(MaxGCPauseMillis, 200);
}
// Then, if the interval parameter was not set, set it according to
// the pause time target (this will also deal with the case when the
// pause time target is the default value).
if (FLAG_IS_DEFAULT(GCPauseIntervalMillis)) {
FLAG_SET_DEFAULT(GCPauseIntervalMillis, MaxGCPauseMillis + 1);
}
log_trace(gc)("MarkStackSize: %uk MarkStackSizeMax: %uk", (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K)); log_trace(gc)("MarkStackSize: %uk MarkStackSizeMax: %uk", (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
log_trace(gc)("ConcGCThreads: %u", ConcGCThreads); log_trace(gc)("ConcGCThreads: %u", ConcGCThreads);
} }

View File

@ -599,6 +599,14 @@ Flag::Error GCPauseIntervalMillisConstraintFunc(uintx value, bool verbose) {
value); value);
return Flag::VIOLATES_CONSTRAINT; return Flag::VIOLATES_CONSTRAINT;
} }
if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) {
CommandLineError::print(verbose,
"GCPauseIntervalMillis cannot be set "
"without setting MaxGCPauseMillis\n");
return Flag::VIOLATES_CONSTRAINT;
}
if (value <= MaxGCPauseMillis) { if (value <= MaxGCPauseMillis) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"GCPauseIntervalMillis (" UINTX_FORMAT ") must be " "GCPauseIntervalMillis (" UINTX_FORMAT ") must be "

View File

@ -2221,11 +2221,11 @@ public:
"Adaptive size policy maximum GC pause time goal in millisecond, "\ "Adaptive size policy maximum GC pause time goal in millisecond, "\
"or (G1 Only) the maximum GC time per MMU time slice") \ "or (G1 Only) the maximum GC time per MMU time slice") \
range(1, max_uintx - 1) \ range(1, max_uintx - 1) \
constraint(MaxGCPauseMillisConstraintFunc,AfterMemoryInit) \ constraint(MaxGCPauseMillisConstraintFunc,AfterErgo) \
\ \
product(uintx, GCPauseIntervalMillis, 0, \ product(uintx, GCPauseIntervalMillis, 0, \
"Time slice for MMU specification") \ "Time slice for MMU specification") \
constraint(GCPauseIntervalMillisConstraintFunc,AfterMemoryInit) \ constraint(GCPauseIntervalMillisConstraintFunc,AfterErgo) \
\ \
product(uintx, MaxGCMinorPauseMillis, max_uintx, \ product(uintx, MaxGCMinorPauseMillis, max_uintx, \
"Adaptive size policy maximum GC minor pause time goal " \ "Adaptive size policy maximum GC minor pause time goal " \