mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 10:04:42 +02:00
8186248: Allow more flexibility in selecting Heap % of available RAM
Reviewed-by: dholmes, drwhite
This commit is contained in:
parent
c9523af5e9
commit
ed869998dd
6 changed files with 52 additions and 17 deletions
|
@ -379,6 +379,9 @@ static SpecialFlag const special_jvm_flags[] = {
|
||||||
{ "MaxGCMinorPauseMillis", JDK_Version::jdk(8), JDK_Version::undefined(), JDK_Version::undefined() },
|
{ "MaxGCMinorPauseMillis", JDK_Version::jdk(8), JDK_Version::undefined(), JDK_Version::undefined() },
|
||||||
{ "UseConcMarkSweepGC", JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() },
|
{ "UseConcMarkSweepGC", JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() },
|
||||||
{ "MonitorInUseLists", JDK_Version::jdk(10),JDK_Version::undefined(), JDK_Version::undefined() },
|
{ "MonitorInUseLists", JDK_Version::jdk(10),JDK_Version::undefined(), JDK_Version::undefined() },
|
||||||
|
{ "MaxRAMFraction", JDK_Version::jdk(10), JDK_Version::undefined(), JDK_Version::undefined() },
|
||||||
|
{ "MinRAMFraction", JDK_Version::jdk(10), JDK_Version::undefined(), JDK_Version::undefined() },
|
||||||
|
{ "InitialRAMFraction", JDK_Version::jdk(10), JDK_Version::undefined(), JDK_Version::undefined() },
|
||||||
|
|
||||||
// --- Deprecated alias flags (see also aliased_jvm_flags) - sorted by obsolete_in then expired_in:
|
// --- Deprecated alias flags (see also aliased_jvm_flags) - sorted by obsolete_in then expired_in:
|
||||||
{ "DefaultMaxRAMFraction", JDK_Version::jdk(8), JDK_Version::undefined(), JDK_Version::undefined() },
|
{ "DefaultMaxRAMFraction", JDK_Version::jdk(8), JDK_Version::undefined(), JDK_Version::undefined() },
|
||||||
|
@ -2069,20 +2072,33 @@ void Arguments::set_heap_size() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert deprecated flags
|
||||||
|
if (FLAG_IS_DEFAULT(MaxRAMPercentage) &&
|
||||||
|
!FLAG_IS_DEFAULT(MaxRAMFraction))
|
||||||
|
MaxRAMPercentage = 100.0 / MaxRAMFraction;
|
||||||
|
|
||||||
|
if (FLAG_IS_DEFAULT(MinRAMPercentage) &&
|
||||||
|
!FLAG_IS_DEFAULT(MinRAMFraction))
|
||||||
|
MinRAMPercentage = 100.0 / MinRAMFraction;
|
||||||
|
|
||||||
|
if (FLAG_IS_DEFAULT(InitialRAMPercentage) &&
|
||||||
|
!FLAG_IS_DEFAULT(InitialRAMFraction))
|
||||||
|
InitialRAMPercentage = 100.0 / InitialRAMFraction;
|
||||||
|
|
||||||
// If the maximum heap size has not been set with -Xmx,
|
// If the maximum heap size has not been set with -Xmx,
|
||||||
// then set it as fraction of the size of physical memory,
|
// then set it as fraction of the size of physical memory,
|
||||||
// respecting the maximum and minimum sizes of the heap.
|
// respecting the maximum and minimum sizes of the heap.
|
||||||
if (FLAG_IS_DEFAULT(MaxHeapSize)) {
|
if (FLAG_IS_DEFAULT(MaxHeapSize)) {
|
||||||
julong reasonable_max = phys_mem / MaxRAMFraction;
|
julong reasonable_max = (julong)((phys_mem * MaxRAMPercentage) / 100);
|
||||||
|
if (phys_mem <= (julong)((MaxHeapSize * MinRAMPercentage) / 100)) {
|
||||||
if (phys_mem <= MaxHeapSize * MinRAMFraction) {
|
|
||||||
// Small physical memory, so use a minimum fraction of it for the heap
|
// Small physical memory, so use a minimum fraction of it for the heap
|
||||||
reasonable_max = phys_mem / MinRAMFraction;
|
reasonable_max = (julong)((phys_mem * MinRAMPercentage) / 100);
|
||||||
} else {
|
} else {
|
||||||
// Not-small physical memory, so require a heap at least
|
// Not-small physical memory, so require a heap at least
|
||||||
// as large as MaxHeapSize
|
// as large as MaxHeapSize
|
||||||
reasonable_max = MAX2(reasonable_max, (julong)MaxHeapSize);
|
reasonable_max = MAX2(reasonable_max, (julong)MaxHeapSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!FLAG_IS_DEFAULT(ErgoHeapSizeLimit) && ErgoHeapSizeLimit != 0) {
|
if (!FLAG_IS_DEFAULT(ErgoHeapSizeLimit) && ErgoHeapSizeLimit != 0) {
|
||||||
// Limit the heap size to ErgoHeapSizeLimit
|
// Limit the heap size to ErgoHeapSizeLimit
|
||||||
reasonable_max = MIN2(reasonable_max, (julong)ErgoHeapSizeLimit);
|
reasonable_max = MIN2(reasonable_max, (julong)ErgoHeapSizeLimit);
|
||||||
|
@ -2135,7 +2151,7 @@ void Arguments::set_heap_size() {
|
||||||
reasonable_minimum = limit_by_allocatable_memory(reasonable_minimum);
|
reasonable_minimum = limit_by_allocatable_memory(reasonable_minimum);
|
||||||
|
|
||||||
if (InitialHeapSize == 0) {
|
if (InitialHeapSize == 0) {
|
||||||
julong reasonable_initial = phys_mem / InitialRAMFraction;
|
julong reasonable_initial = (julong)((phys_mem * InitialRAMPercentage) / 100);
|
||||||
|
|
||||||
reasonable_initial = MAX3(reasonable_initial, reasonable_minimum, (julong)min_heap_size());
|
reasonable_initial = MAX3(reasonable_initial, reasonable_minimum, (julong)min_heap_size());
|
||||||
reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize);
|
reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize);
|
||||||
|
|
|
@ -2037,7 +2037,7 @@ public:
|
||||||
\
|
\
|
||||||
product(size_t, ErgoHeapSizeLimit, 0, \
|
product(size_t, ErgoHeapSizeLimit, 0, \
|
||||||
"Maximum ergonomically set heap size (in bytes); zero means use " \
|
"Maximum ergonomically set heap size (in bytes); zero means use " \
|
||||||
"MaxRAM / MaxRAMFraction") \
|
"MaxRAM * MaxRAMPercentage / 100") \
|
||||||
range(0, max_uintx) \
|
range(0, max_uintx) \
|
||||||
\
|
\
|
||||||
experimental(bool, UseCGroupMemoryLimitForHeap, false, \
|
experimental(bool, UseCGroupMemoryLimitForHeap, false, \
|
||||||
|
@ -2046,18 +2046,34 @@ public:
|
||||||
\
|
\
|
||||||
product(uintx, MaxRAMFraction, 4, \
|
product(uintx, MaxRAMFraction, 4, \
|
||||||
"Maximum fraction (1/n) of real memory used for maximum heap " \
|
"Maximum fraction (1/n) of real memory used for maximum heap " \
|
||||||
"size") \
|
"size. " \
|
||||||
|
"Deprecated, use MaxRAMPercentage instead") \
|
||||||
range(1, max_uintx) \
|
range(1, max_uintx) \
|
||||||
\
|
\
|
||||||
product(uintx, MinRAMFraction, 2, \
|
product(uintx, MinRAMFraction, 2, \
|
||||||
"Minimum fraction (1/n) of real memory used for maximum heap " \
|
"Minimum fraction (1/n) of real memory used for maximum heap " \
|
||||||
"size on systems with small physical memory size") \
|
"size on systems with small physical memory size. " \
|
||||||
|
"Deprecated, use MinRAMPercentage instead") \
|
||||||
range(1, max_uintx) \
|
range(1, max_uintx) \
|
||||||
\
|
\
|
||||||
product(uintx, InitialRAMFraction, 64, \
|
product(uintx, InitialRAMFraction, 64, \
|
||||||
"Fraction (1/n) of real memory used for initial heap size") \
|
"Fraction (1/n) of real memory used for initial heap size. " \
|
||||||
|
"Deprecated, use InitialRAMPercentage instead") \
|
||||||
range(1, max_uintx) \
|
range(1, max_uintx) \
|
||||||
\
|
\
|
||||||
|
product(double, MaxRAMPercentage, 25.0, \
|
||||||
|
"Maximum percentage of real memory used for maximum heap size") \
|
||||||
|
range(0.0, 100.0) \
|
||||||
|
\
|
||||||
|
product(double, MinRAMPercentage, 50.0, \
|
||||||
|
"Minimum percentage of real memory used for maximum heap" \
|
||||||
|
"size on systems with small physical memory size") \
|
||||||
|
range(0.0, 100.0) \
|
||||||
|
\
|
||||||
|
product(double, InitialRAMPercentage, 1.5625, \
|
||||||
|
"Percentage of real memory used for initial heap size") \
|
||||||
|
range(0.0, 100.0) \
|
||||||
|
\
|
||||||
develop(uintx, MaxVirtMemFraction, 2, \
|
develop(uintx, MaxVirtMemFraction, 2, \
|
||||||
"Maximum fraction (1/n) of virtual memory used for ergonomically "\
|
"Maximum fraction (1/n) of virtual memory used for ergonomically "\
|
||||||
"determining maximum heap size") \
|
"determining maximum heap size") \
|
||||||
|
|
|
@ -70,8 +70,8 @@ else ifeq ($(shell expr $(CONCURRENCY) \> 12), 1)
|
||||||
CONCURRENCY := 12
|
CONCURRENCY := 12
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Make sure MaxRAMFraction is high enough to not cause OOM or swapping since we may end up with a lot of JVM's
|
# Make sure MaxRAMPercentage is high enough to not cause OOM or swapping since we may end up with a lot of JVM's
|
||||||
JTREG_BASIC_OPTIONS += -vmoption:-XX:MaxRAMFraction=$(shell expr $(CONCURRENCY) \* 4)
|
JTREG_BASIC_OPTIONS += -vmoption:-XX:MaxRAMPercentage=$(shell expr 25 / $(CONCURRENCY))
|
||||||
|
|
||||||
# Include the common base file with most of the logic
|
# Include the common base file with most of the logic
|
||||||
include ../../test/TestCommon.gmk
|
include ../../test/TestCommon.gmk
|
||||||
|
|
|
@ -36,10 +36,10 @@ import jdk.test.lib.process.OutputAnalyzer;
|
||||||
public class FlagWithInvalidValue {
|
public class FlagWithInvalidValue {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
||||||
"-XX:MaxRAMFraction=v", "-version");
|
"-XX:MaxRAMPercentage=v", "-version");
|
||||||
|
|
||||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||||
output.shouldContain("Improperly specified VM option 'MaxRAMFraction=v'");
|
output.shouldContain("Improperly specified VM option 'MaxRAMPercentage=v'");
|
||||||
output.shouldHaveExitValue(1);
|
output.shouldHaveExitValue(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,17 +36,17 @@ import jdk.test.lib.process.OutputAnalyzer;
|
||||||
public class NonBooleanFlagWithInvalidBooleanPrefix {
|
public class NonBooleanFlagWithInvalidBooleanPrefix {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
||||||
"-XX:-MaxRAMFraction=16", "-version");
|
"-XX:-MaxRAMPercentage=1", "-version");
|
||||||
|
|
||||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||||
output.shouldContain("Unexpected +/- setting in VM option 'MaxRAMFraction=16'");
|
output.shouldContain("Unexpected +/- setting in VM option 'MaxRAMPercentage=1'");
|
||||||
output.shouldHaveExitValue(1);
|
output.shouldHaveExitValue(1);
|
||||||
|
|
||||||
pb = ProcessTools.createJavaProcessBuilder(
|
pb = ProcessTools.createJavaProcessBuilder(
|
||||||
"-XX:+MaxRAMFraction=16", "-version");
|
"-XX:+MaxRAMPercentage=1", "-version");
|
||||||
|
|
||||||
output = new OutputAnalyzer(pb.start());
|
output = new OutputAnalyzer(pb.start());
|
||||||
output.shouldContain("Unexpected +/- setting in VM option 'MaxRAMFraction=16'");
|
output.shouldContain("Unexpected +/- setting in VM option 'MaxRAMPercentage=1'");
|
||||||
output.shouldHaveExitValue(1);
|
output.shouldHaveExitValue(1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,9 @@ public class VMDeprecatedOptions {
|
||||||
{"MaxGCMinorPauseMillis", "1032"},
|
{"MaxGCMinorPauseMillis", "1032"},
|
||||||
{"MustCallLoadClassInternal", "false"},
|
{"MustCallLoadClassInternal", "false"},
|
||||||
{"UnsyncloadClass", "false"},
|
{"UnsyncloadClass", "false"},
|
||||||
|
{"MaxRAMFraction", "8"},
|
||||||
|
{"MinRAMFraction", "2"},
|
||||||
|
{"InitialRAMFraction", "64"},
|
||||||
|
|
||||||
// deprecated alias flags (see also aliased_jvm_flags):
|
// deprecated alias flags (see also aliased_jvm_flags):
|
||||||
{"DefaultMaxRAMFraction", "4"},
|
{"DefaultMaxRAMFraction", "4"},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue