src/share/vm/runtime/arguments.cpp
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
hotspot Cdiff src/share/vm/runtime/arguments.cpp
src/share/vm/runtime/arguments.cpp
Print this page
rev 5803 : 8028391: Make the Min/MaxHeapFreeRatio flags manageable
Summary: Made the flags Min- and MaxHeapFreeRatio manageable, and implemented support for these flags in ParallalGC.
Reviewed-by: sla, mgerdin, brutisso
*** 1567,1576 ****
--- 1567,1586 ----
jio_fprintf(defaultStream::error_stream(),
"The Parallel GC can not be combined with -XX:ParallelGCThreads=0\n");
vm_exit(1);
}
+ if (UseAdaptiveSizePolicy) {
+ // We don't want to limit adaptive heap sizing's freedom to adjust the heap
+ // unless the user actually sets these flags.
+ if (FLAG_IS_DEFAULT(MinHeapFreeRatio)) {
+ FLAG_SET_DEFAULT(MinHeapFreeRatio, 0);
+ }
+ if (FLAG_IS_DEFAULT(MaxHeapFreeRatio)) {
+ FLAG_SET_DEFAULT(MaxHeapFreeRatio, 100);
+ }
+ }
// If InitialSurvivorRatio or MinSurvivorRatio were not specified, but the
// SurvivorRatio has been set, reset their default values to SurvivorRatio +
// 2. By doing this we make SurvivorRatio also work for Parallel Scavenger.
// See CR 6362902 for details.
*** 1842,1852 ****
name, val, min);
return false;
}
bool Arguments::verify_percentage(uintx value, const char* name) {
! if (value <= 100) {
return true;
}
jio_fprintf(defaultStream::error_stream(),
"%s of " UINTX_FORMAT " is invalid; must be between 0 and 100\n",
name, value);
--- 1852,1862 ----
name, val, min);
return false;
}
bool Arguments::verify_percentage(uintx value, const char* name) {
! if (is_percentage(value)) {
return true;
}
jio_fprintf(defaultStream::error_stream(),
"%s of " UINTX_FORMAT " is invalid; must be between 0 and 100\n",
name, value);
*** 1930,1939 ****
--- 1940,1977 ----
return false;
}
return count_p < 2 && count_t < 2;
}
+ bool Arguments::verify_MinHeapFreeRatio(FormatBuffer<80>& err_msg, uintx min_heap_free_ratio) {
+ if (!is_percentage(min_heap_free_ratio)) {
+ err_msg.print("MinHeapFreeRatio must have a value between 0 and 100");
+ return false;
+ }
+ if (min_heap_free_ratio > MaxHeapFreeRatio) {
+ err_msg.print("MinHeapFreeRatio (" UINTX_FORMAT ") must be less than or "
+ "equal to MaxHeapFreeRatio (" UINTX_FORMAT ")", min_heap_free_ratio,
+ MaxHeapFreeRatio);
+ return false;
+ }
+ return true;
+ }
+
+ bool Arguments::verify_MaxHeapFreeRatio(FormatBuffer<80>& err_msg, uintx max_heap_free_ratio) {
+ if (!is_percentage(max_heap_free_ratio)) {
+ err_msg.print("MaxHeapFreeRatio must have a value between 0 and 100");
+ return false;
+ }
+ if (max_heap_free_ratio < MinHeapFreeRatio) {
+ err_msg.print("MaxHeapFreeRatio (" UINTX_FORMAT ") must be greater than or "
+ "equal to MinHeapFreeRatio (" UINTX_FORMAT ")", max_heap_free_ratio,
+ MinHeapFreeRatio);
+ return false;
+ }
+ return true;
+ }
+
// Check consistency of GC selection
bool Arguments::check_gc_consistency() {
check_gclog_consistency();
bool status = true;
// Ensure that the user has not selected conflicting sets
*** 2035,2064 ****
}
status = status && verify_interval(AdaptiveSizePolicyWeight, 0, 100,
"AdaptiveSizePolicyWeight");
status = status && verify_percentage(ThresholdTolerance, "ThresholdTolerance");
- status = status && verify_percentage(MinHeapFreeRatio, "MinHeapFreeRatio");
- status = status && verify_percentage(MaxHeapFreeRatio, "MaxHeapFreeRatio");
// Divide by bucket size to prevent a large size from causing rollover when
// calculating amount of memory needed to be allocated for the String table.
status = status && verify_interval(StringTableSize, minimumStringTableSize,
(max_uintx / StringTable::bucket_size()), "StringTable size");
status = status && verify_interval(SymbolTableSize, minimumSymbolTableSize,
(max_uintx / SymbolTable::bucket_size()), "SymbolTable size");
! if (MinHeapFreeRatio > MaxHeapFreeRatio) {
! jio_fprintf(defaultStream::error_stream(),
! "MinHeapFreeRatio (" UINTX_FORMAT ") must be less than or "
! "equal to MaxHeapFreeRatio (" UINTX_FORMAT ")\n",
! MinHeapFreeRatio, MaxHeapFreeRatio);
status = false;
}
! // Keeping the heap 100% free is hard ;-) so limit it to 99%.
! MinHeapFreeRatio = MIN2(MinHeapFreeRatio, (uintx) 99);
// Min/MaxMetaspaceFreeRatio
status = status && verify_percentage(MinMetaspaceFreeRatio, "MinMetaspaceFreeRatio");
status = status && verify_percentage(MaxMetaspaceFreeRatio, "MaxMetaspaceFreeRatio");
--- 2073,2104 ----
}
status = status && verify_interval(AdaptiveSizePolicyWeight, 0, 100,
"AdaptiveSizePolicyWeight");
status = status && verify_percentage(ThresholdTolerance, "ThresholdTolerance");
// Divide by bucket size to prevent a large size from causing rollover when
// calculating amount of memory needed to be allocated for the String table.
status = status && verify_interval(StringTableSize, minimumStringTableSize,
(max_uintx / StringTable::bucket_size()), "StringTable size");
status = status && verify_interval(SymbolTableSize, minimumSymbolTableSize,
(max_uintx / SymbolTable::bucket_size()), "SymbolTable size");
! {
! // Using "else if" below to avoid printing two error messages if min > max.
! // This will also prevent us from reporting both min>100 and max>100 at the
! // same time, but that is less annoying than printing two identical errors IMHO.
! FormatBuffer<80> err_msg("");
! if (!verify_MinHeapFreeRatio(err_msg, MinHeapFreeRatio)) {
! jio_fprintf(defaultStream::error_stream(), "%s\n", err_msg.buffer());
! status = false;
! } else if (!verify_MaxHeapFreeRatio(err_msg, MaxHeapFreeRatio)) {
! jio_fprintf(defaultStream::error_stream(), "%s\n", err_msg.buffer());
status = false;
}
! }
// Min/MaxMetaspaceFreeRatio
status = status && verify_percentage(MinMetaspaceFreeRatio, "MinMetaspaceFreeRatio");
status = status && verify_percentage(MaxMetaspaceFreeRatio, "MaxMetaspaceFreeRatio");
*** 2687,2697 ****
FLAG_SET_CMDLINE(uintx, MaxHeapSize, (uintx)long_max_heap_size);
// Xmaxf
} else if (match_option(option, "-Xmaxf", &tail)) {
char* err;
int maxf = (int)(strtod(tail, &err) * 100);
! if (*err != '\0' || maxf < 0 || maxf > 100) {
jio_fprintf(defaultStream::error_stream(),
"Bad max heap free percentage size: %s\n",
option->optionString);
return JNI_EINVAL;
} else {
--- 2727,2737 ----
FLAG_SET_CMDLINE(uintx, MaxHeapSize, (uintx)long_max_heap_size);
// Xmaxf
} else if (match_option(option, "-Xmaxf", &tail)) {
char* err;
int maxf = (int)(strtod(tail, &err) * 100);
! if (*err != '\0' || *tail == '\0' || maxf < 0 || maxf > 100) {
jio_fprintf(defaultStream::error_stream(),
"Bad max heap free percentage size: %s\n",
option->optionString);
return JNI_EINVAL;
} else {
*** 2699,2709 ****
}
// Xminf
} else if (match_option(option, "-Xminf", &tail)) {
char* err;
int minf = (int)(strtod(tail, &err) * 100);
! if (*err != '\0' || minf < 0 || minf > 100) {
jio_fprintf(defaultStream::error_stream(),
"Bad min heap free percentage size: %s\n",
option->optionString);
return JNI_EINVAL;
} else {
--- 2739,2749 ----
}
// Xminf
} else if (match_option(option, "-Xminf", &tail)) {
char* err;
int minf = (int)(strtod(tail, &err) * 100);
! if (*err != '\0' || *tail == '\0' || minf < 0 || minf > 100) {
jio_fprintf(defaultStream::error_stream(),
"Bad min heap free percentage size: %s\n",
option->optionString);
return JNI_EINVAL;
} else {
*** 3644,3656 ****
#if INCLUDE_ALL_GCS
// Set per-collector flags
if (UseParallelGC || UseParallelOldGC) {
set_parallel_gc_flags();
! } else if (UseConcMarkSweepGC) { // should be done before ParNew check below
set_cms_and_parnew_gc_flags();
! } else if (UseParNewGC) { // skipped if CMS is set above
set_parnew_gc_flags();
} else if (UseG1GC) {
set_g1_gc_flags();
}
check_deprecated_gcs();
--- 3684,3696 ----
#if INCLUDE_ALL_GCS
// Set per-collector flags
if (UseParallelGC || UseParallelOldGC) {
set_parallel_gc_flags();
! } else if (UseConcMarkSweepGC) { // Should be done before ParNew check below
set_cms_and_parnew_gc_flags();
! } else if (UseParNewGC) { // Skipped if CMS is set above
set_parnew_gc_flags();
} else if (UseG1GC) {
set_g1_gc_flags();
}
check_deprecated_gcs();
*** 3660,3669 ****
--- 3700,3713 ----
warning("If the number of processors is expected to increase from one, then"
" you should configure the number of parallel GC threads appropriately"
" using -XX:ParallelGCThreads=N");
}
}
+ if (MinHeapFreeRatio == 100) {
+ // Keeping the heap 100% free is hard ;-) so limit it to 99%.
+ FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99);
+ }
#else // INCLUDE_ALL_GCS
assert(verify_serial_gc_flags(), "SerialGC unset");
#endif // INCLUDE_ALL_GCS
// Initialize Metaspace flags and alignments.
src/share/vm/runtime/arguments.cpp
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File