Fri, 07 May 2010 13:14:41 -0400
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
Summary: First, change the guarantee to raising a vm error. Second, set the interval dynamically, and based on the pause time target, if it is not set explicitly.
Reviewed-by: ysr, johnc
1.1 --- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp Thu Jun 10 08:27:35 2010 -0700 1.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp Fri May 07 13:14:41 2010 -0400 1.3 @@ -274,10 +274,64 @@ 1.4 1.5 // </NEW PREDICTION> 1.6 1.7 + // Below, we might need to calculate the pause time target based on 1.8 + // the pause interval. When we do so we are going to give G1 maximum 1.9 + // flexibility and allow it to do pauses when it needs to. So, we'll 1.10 + // arrange that the pause interval to be pause time target + 1 to 1.11 + // ensure that a) the pause time target is maximized with respect to 1.12 + // the pause interval and b) we maintain the invariant that pause 1.13 + // time target < pause interval. If the user does not want this 1.14 + // maximum flexibility, they will have to set the pause interval 1.15 + // explicitly. 1.16 + 1.17 + // First make sure that, if either parameter is set, its value is 1.18 + // reasonable. 1.19 + if (!FLAG_IS_DEFAULT(MaxGCPauseMillis)) { 1.20 + if (MaxGCPauseMillis < 1) { 1.21 + vm_exit_during_initialization("MaxGCPauseMillis should be " 1.22 + "greater than 0"); 1.23 + } 1.24 + } 1.25 + if (!FLAG_IS_DEFAULT(GCPauseIntervalMillis)) { 1.26 + if (GCPauseIntervalMillis < 1) { 1.27 + vm_exit_during_initialization("GCPauseIntervalMillis should be " 1.28 + "greater than 0"); 1.29 + } 1.30 + } 1.31 + 1.32 + // Then, if the pause time target parameter was not set, set it to 1.33 + // the default value. 1.34 + if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) { 1.35 + if (FLAG_IS_DEFAULT(GCPauseIntervalMillis)) { 1.36 + // The default pause time target in G1 is 200ms 1.37 + FLAG_SET_DEFAULT(MaxGCPauseMillis, 200); 1.38 + } else { 1.39 + // We do not allow the pause interval to be set without the 1.40 + // pause time target 1.41 + vm_exit_during_initialization("GCPauseIntervalMillis cannot be set " 1.42 + "without setting MaxGCPauseMillis"); 1.43 + } 1.44 + } 1.45 + 1.46 + // Then, if the interval parameter was not set, set it according to 1.47 + // the pause time target (this will also deal with the case when the 1.48 + // pause time target is the default value). 1.49 + if (FLAG_IS_DEFAULT(GCPauseIntervalMillis)) { 1.50 + FLAG_SET_DEFAULT(GCPauseIntervalMillis, MaxGCPauseMillis + 1); 1.51 + } 1.52 + 1.53 + // Finally, make sure that the two parameters are consistent. 1.54 + if (MaxGCPauseMillis >= GCPauseIntervalMillis) { 1.55 + char buffer[256]; 1.56 + jio_snprintf(buffer, 256, 1.57 + "MaxGCPauseMillis (%u) should be less than " 1.58 + "GCPauseIntervalMillis (%u)", 1.59 + MaxGCPauseMillis, GCPauseIntervalMillis); 1.60 + vm_exit_during_initialization(buffer); 1.61 + } 1.62 + 1.63 + double max_gc_time = (double) MaxGCPauseMillis / 1000.0; 1.64 double time_slice = (double) GCPauseIntervalMillis / 1000.0; 1.65 - double max_gc_time = (double) MaxGCPauseMillis / 1000.0; 1.66 - guarantee(max_gc_time < time_slice, 1.67 - "Max GC time should not be greater than the time slice"); 1.68 _mmu_tracker = new G1MMUTrackerQueue(time_slice, max_gc_time); 1.69 _sigma = (double) G1ConfidencePercent / 100.0; 1.70
2.1 --- a/src/share/vm/runtime/arguments.cpp Thu Jun 10 08:27:35 2010 -0700 2.2 +++ b/src/share/vm/runtime/arguments.cpp Fri May 07 13:14:41 2010 -0400 2.3 @@ -1376,11 +1376,6 @@ 2.4 } 2.5 no_shared_spaces(); 2.6 2.7 - // Set the maximum pause time goal to be a reasonable default. 2.8 - if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) { 2.9 - FLAG_SET_DEFAULT(MaxGCPauseMillis, 200); 2.10 - } 2.11 - 2.12 if (FLAG_IS_DEFAULT(MarkStackSize)) { 2.13 FLAG_SET_DEFAULT(MarkStackSize, 128 * TASKQUEUE_SIZE); 2.14 }
3.1 --- a/src/share/vm/runtime/globals.hpp Thu Jun 10 08:27:35 2010 -0700 3.2 +++ b/src/share/vm/runtime/globals.hpp Fri May 07 13:14:41 2010 -0400 3.3 @@ -1975,7 +1975,7 @@ 3.4 "Adaptive size policy maximum GC pause time goal in msec, " \ 3.5 "or (G1 Only) the max. GC time per MMU time slice") \ 3.6 \ 3.7 - product(intx, GCPauseIntervalMillis, 500, \ 3.8 + product(uintx, GCPauseIntervalMillis, 0, \ 3.9 "Time slice for MMU specification") \ 3.10 \ 3.11 product(uintx, MaxGCMinorPauseMillis, max_uintx, \