mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-13 15:09:39 +00:00
8378319: Obsolete the MaxRAM flag
Reviewed-by: ayang, tschatzl
This commit is contained in:
parent
bc9c6c6af9
commit
bd99c627b1
@ -262,18 +262,13 @@
|
||||
product(bool, AlwaysActAsServerClassMachine, false, \
|
||||
"(Deprecated) Always act like a server-class machine") \
|
||||
\
|
||||
product(uint64_t, MaxRAM, 0, \
|
||||
"(Deprecated) Real memory size (in bytes) used to set maximum " \
|
||||
"heap size") \
|
||||
range(0, 0XFFFFFFFFFFFFFFFF) \
|
||||
\
|
||||
product(bool, AggressiveHeap, false, \
|
||||
"(Deprecated) Optimize heap options for long-running memory " \
|
||||
"intensive apps") \
|
||||
\
|
||||
product(size_t, ErgoHeapSizeLimit, 0, \
|
||||
"Maximum ergonomically set heap size (in bytes); zero means use " \
|
||||
"MaxRAM * MaxRAMPercentage / 100") \
|
||||
"(System RAM) * MaxRAMPercentage / 100") \
|
||||
range(0, max_uintx) \
|
||||
\
|
||||
product(double, MaxRAMPercentage, 25.0, \
|
||||
|
||||
@ -536,7 +536,6 @@ static SpecialFlag const special_jvm_flags[] = {
|
||||
#ifdef _LP64
|
||||
{ "UseCompressedClassPointers", JDK_Version::jdk(25), JDK_Version::jdk(27), JDK_Version::undefined() },
|
||||
#endif
|
||||
{ "MaxRAM", JDK_Version::jdk(26), JDK_Version::jdk(27), JDK_Version::jdk(28) },
|
||||
{ "AggressiveHeap", JDK_Version::jdk(26), JDK_Version::jdk(27), JDK_Version::jdk(28) },
|
||||
{ "NeverActAsServerClassMachine", JDK_Version::jdk(26), JDK_Version::jdk(27), JDK_Version::jdk(28) },
|
||||
{ "AlwaysActAsServerClassMachine", JDK_Version::jdk(26), JDK_Version::jdk(27), JDK_Version::jdk(28) },
|
||||
@ -553,6 +552,7 @@ static SpecialFlag const special_jvm_flags[] = {
|
||||
{ "PSChunkLargeArrays", JDK_Version::jdk(26), JDK_Version::jdk(27), JDK_Version::jdk(28) },
|
||||
{ "ParallelRefProcEnabled", JDK_Version::jdk(26), JDK_Version::jdk(27), JDK_Version::jdk(28) },
|
||||
{ "ParallelRefProcBalancingEnabled", JDK_Version::jdk(26), JDK_Version::jdk(27), JDK_Version::jdk(28) },
|
||||
{ "MaxRAM", JDK_Version::jdk(26), JDK_Version::jdk(27), JDK_Version::jdk(28) },
|
||||
|
||||
#ifdef ASSERT
|
||||
{ "DummyObsoleteTestFlag", JDK_Version::undefined(), JDK_Version::jdk(18), JDK_Version::undefined() },
|
||||
@ -1510,25 +1510,19 @@ void Arguments::set_heap_size() {
|
||||
// Check if the user has configured any limit on the amount of RAM we may use.
|
||||
bool has_ram_limit = !FLAG_IS_DEFAULT(MaxRAMPercentage) ||
|
||||
!FLAG_IS_DEFAULT(MinRAMPercentage) ||
|
||||
!FLAG_IS_DEFAULT(InitialRAMPercentage) ||
|
||||
!FLAG_IS_DEFAULT(MaxRAM);
|
||||
!FLAG_IS_DEFAULT(InitialRAMPercentage);
|
||||
|
||||
if (FLAG_IS_DEFAULT(MaxRAM)) {
|
||||
if (CompilerConfig::should_set_client_emulation_mode_flags()) {
|
||||
// Limit the available memory if client emulation mode is enabled.
|
||||
FLAG_SET_ERGO(MaxRAM, 1ULL*G);
|
||||
} else {
|
||||
// Use the available physical memory on the system.
|
||||
FLAG_SET_ERGO(MaxRAM, os::physical_memory());
|
||||
}
|
||||
}
|
||||
// Limit the available memory if client emulation mode is enabled.
|
||||
const size_t avail_mem = CompilerConfig::should_set_client_emulation_mode_flags()
|
||||
? 1ULL*G
|
||||
: os::physical_memory();
|
||||
|
||||
// If the maximum heap size has not been set with -Xmx, then set it as
|
||||
// fraction of the size of physical memory, respecting the maximum and
|
||||
// minimum sizes of the heap.
|
||||
if (FLAG_IS_DEFAULT(MaxHeapSize)) {
|
||||
uint64_t min_memory = (uint64_t)(((double)MaxRAM * MinRAMPercentage) / 100);
|
||||
uint64_t max_memory = (uint64_t)(((double)MaxRAM * MaxRAMPercentage) / 100);
|
||||
uint64_t min_memory = (uint64_t)(((double)avail_mem * MinRAMPercentage) / 100);
|
||||
uint64_t max_memory = (uint64_t)(((double)avail_mem * MaxRAMPercentage) / 100);
|
||||
|
||||
const size_t reasonable_min = clamp_by_size_t_max(min_memory);
|
||||
size_t reasonable_max = clamp_by_size_t_max(max_memory);
|
||||
@ -1615,7 +1609,7 @@ void Arguments::set_heap_size() {
|
||||
reasonable_minimum = limit_heap_by_allocatable_memory(reasonable_minimum);
|
||||
|
||||
if (InitialHeapSize == 0) {
|
||||
uint64_t initial_memory = (uint64_t)(((double)MaxRAM * InitialRAMPercentage) / 100);
|
||||
uint64_t initial_memory = (uint64_t)(((double)avail_mem * InitialRAMPercentage) / 100);
|
||||
size_t reasonable_initial = clamp_by_size_t_max(initial_memory);
|
||||
reasonable_initial = limit_heap_by_allocatable_memory(reasonable_initial);
|
||||
|
||||
|
||||
@ -2454,8 +2454,8 @@ Java HotSpot VM.
|
||||
|
||||
[`-XX:InitialRAMPercentage=`]{#-XX_InitialRAMPercentage}*percent*
|
||||
: Sets the initial amount of memory that the JVM will use for the Java heap
|
||||
before applying ergonomics heuristics as a percentage of the maximum amount
|
||||
determined as described in the `-XX:MaxRAM` option.
|
||||
before applying ergonomics heuristics as a percentage of the available memory
|
||||
to the JVM process.
|
||||
|
||||
The following example shows how to set the percentage of the initial
|
||||
amount of memory used for the Java heap:
|
||||
@ -2575,9 +2575,8 @@ Java HotSpot VM.
|
||||
|
||||
[`-XX:MaxRAMPercentage=`]{#-XX_MaxRAMPercentage}*percent*
|
||||
: Sets the maximum amount of memory that the JVM may use for the Java heap
|
||||
before applying ergonomics heuristics as a percentage of the maximum amount
|
||||
determined as described in the `-XX:MaxRAM` option. The default value is 25
|
||||
percent.
|
||||
before applying ergonomics heuristics as a percentage of the available memory
|
||||
to the JVM process. The default value is 25 percent.
|
||||
|
||||
Specifying this option disables automatic use of compressed oops if
|
||||
the combined result of this and other options influencing the maximum amount
|
||||
@ -2591,9 +2590,9 @@ Java HotSpot VM.
|
||||
|
||||
[`-XX:MinRAMPercentage=`]{#-XX_MinRAMPercentage}*percent*
|
||||
: Sets the maximum amount of memory that the JVM may use for the Java heap
|
||||
before applying ergonomics heuristics as a percentage of the maximum amount
|
||||
determined as described in the `-XX:MaxRAM` option for small heaps. A small
|
||||
heap is a heap of approximately 125 MB. The default value is 50 percent.
|
||||
before applying ergonomics heuristics as a percentage of the available memory
|
||||
to the JVM process for small heaps. A small heap is a heap of approximately
|
||||
125 MB. The default value is 50 percent.
|
||||
|
||||
The following example shows how to set the percentage of the maximum amount
|
||||
of memory used for the Java heap for small heaps:
|
||||
@ -2939,25 +2938,6 @@ they're used.
|
||||
(`-XX:+UseParallelGC` or `-XX:+UseG1GC`). Other collectors employing multiple
|
||||
threads always perform reference processing in parallel.
|
||||
|
||||
[`-XX:MaxRAM=`]{#-XX_MaxRAM}*size*
|
||||
: Sets the maximum amount of memory that the JVM may use for the Java heap
|
||||
before applying ergonomics heuristics. The default value is the amount of
|
||||
available memory to the JVM process.
|
||||
|
||||
The maximum amount of available memory to the JVM process is the minimum
|
||||
of the machine's physical memory and any constraints set by the environment
|
||||
(e.g. container).
|
||||
|
||||
Specifying this option disables automatic use of compressed oops if
|
||||
the combined result of this and other options influencing the maximum amount
|
||||
of memory is larger than the range of memory addressable by compressed oops.
|
||||
See `-XX:UseCompressedOops` for further information about compressed oops.
|
||||
|
||||
The following example shows how to set the maximum amount of available
|
||||
memory for sizing the Java heap to 2 GB:
|
||||
|
||||
> `-XX:MaxRAM=2G`
|
||||
|
||||
[`-XX:+AggressiveHeap`]{#-XX__AggressiveHeap}
|
||||
: Enables Java heap optimization. This sets various parameters to be
|
||||
optimal for long-running jobs with intensive memory allocation, based on
|
||||
@ -2967,8 +2947,8 @@ they're used.
|
||||
[`-XX:+NeverActAsServerClassMachine`]{#-XX__NeverActAsServerClassMachine}
|
||||
: Enable the "Client VM emulation" mode which only uses the C1 JIT compiler,
|
||||
a 32Mb CodeCache and the Serial GC. The maximum amount of memory that the
|
||||
JVM may use (controlled by the `-XX:MaxRAM=n` flag) is set to 1GB by default.
|
||||
The string "emulated-client" is added to the JVM version string.
|
||||
JVM may use is set to 1GB by default. The string "emulated-client" is added
|
||||
to the JVM version string.
|
||||
|
||||
By default the flag is set to `true` only on Windows in 32-bit mode and
|
||||
`false` in all other cases.
|
||||
|
||||
@ -58,7 +58,7 @@ TEST_VM(FlagGuard, size_t_flag) {
|
||||
}
|
||||
|
||||
TEST_VM(FlagGuard, uint64_t_flag) {
|
||||
TEST_FLAG(MaxRAM, uint64_t, 1337);
|
||||
TEST_FLAG(ErrorLogTimeout, uint64_t, 1337);
|
||||
}
|
||||
|
||||
TEST_VM(FlagGuard, double_flag) {
|
||||
|
||||
@ -24,10 +24,9 @@
|
||||
package gc.arguments;
|
||||
|
||||
/*
|
||||
* @test TestMaxRAMFlags
|
||||
* @test TestMaxRAMPercentage
|
||||
* @bug 8222252
|
||||
* @summary Verify correct MaxHeapSize and UseCompressedOops when MaxRAM and MaxRAMPercentage
|
||||
* are specified.
|
||||
* @summary Verify correct MaxHeapSize and UseCompressedOops when MaxRAMPercentage is specified
|
||||
* @library /test/lib
|
||||
* @library /
|
||||
* @requires vm.bits == "64"
|
||||
@ -35,8 +34,11 @@ package gc.arguments;
|
||||
* java.management
|
||||
* @build jdk.test.whitebox.WhiteBox
|
||||
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
|
||||
* @run driver gc.arguments.TestMaxRAMFlags
|
||||
* @author bob.vandette@oracle.com
|
||||
* @run main/othervm
|
||||
* -Xbootclasspath/a:.
|
||||
* -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI
|
||||
* gc.arguments.TestMaxRAMPercentage
|
||||
*/
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
@ -45,14 +47,17 @@ import java.util.regex.Pattern;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import jdk.test.whitebox.WhiteBox;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jtreg.SkippedException;
|
||||
|
||||
public class TestMaxRAMFlags {
|
||||
public class TestMaxRAMPercentage {
|
||||
|
||||
private static void checkMaxRAMSize(long maxram, int maxrampercent, boolean forcecoop, long expectheap, boolean expectcoop) throws Exception {
|
||||
private static final WhiteBox wb = WhiteBox.getWhiteBox();
|
||||
|
||||
private static void checkMaxRAMSize(double maxrampercent, boolean forcecoop, long expectheap, boolean expectcoop) throws Exception {
|
||||
|
||||
ArrayList<String> args = new ArrayList<String>();
|
||||
args.add("-XX:MaxRAM=" + maxram);
|
||||
args.add("-XX:MaxRAMPercentage=" + maxrampercent);
|
||||
if (forcecoop) {
|
||||
args.add("-XX:+UseCompressedOops");
|
||||
@ -107,21 +112,32 @@ public class TestMaxRAMFlags {
|
||||
}
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
// Tests
|
||||
// 1. Verify that MaxRAMPercentage overrides UseCompressedOops Ergo
|
||||
// 2. Verify that UseCompressedOops forces compressed oops limit even
|
||||
// when other flags are specified.
|
||||
|
||||
long oneG = 1L * 1024L * 1024L * 1024L;
|
||||
|
||||
// Hotspot startup logic reduces MaxHeapForCompressedOops by HeapBaseMinAddress
|
||||
// in order to get zero based compressed oops offsets.
|
||||
long heapbaseminaddr = getHeapBaseMinAddress();
|
||||
long maxcoopheap = TestUseCompressedOopsErgoTools.getMaxHeapForCompressedOops(new String [0]) - heapbaseminaddr;
|
||||
|
||||
// Args: MaxRAM , MaxRAMPercentage, forcecoop, expect heap, expect coop
|
||||
checkMaxRAMSize(maxcoopheap - oneG, 100, false, maxcoopheap - oneG, true);
|
||||
checkMaxRAMSize(maxcoopheap + oneG, 100, false, maxcoopheap + oneG, false);
|
||||
checkMaxRAMSize(maxcoopheap + oneG, 100, true, maxcoopheap, true);
|
||||
// The headroom is used to get/not get compressed oops from the maxcoopheap size
|
||||
long M = 1L * 1024L * 1024L;
|
||||
long headroom = 64 * M;
|
||||
|
||||
long requiredHostMemory = maxcoopheap + headroom;
|
||||
|
||||
// Get host memory
|
||||
long hostMemory = wb.hostPhysicalMemory();
|
||||
|
||||
System.out.println("hostMemory: " + hostMemory + ", requiredHostMemory: " + requiredHostMemory);
|
||||
|
||||
if (hostMemory < requiredHostMemory) {
|
||||
throw new SkippedException("Not enough RAM on machine to run. Test skipped!");
|
||||
}
|
||||
|
||||
double MaxRAMPercentage = ((double)maxcoopheap / hostMemory) * 100.0;
|
||||
double headroomPercentage = ((double)headroom / hostMemory) * 100.0;
|
||||
|
||||
// Args: MaxRAMPercentage, forcecoop, expectheap, expectcoop
|
||||
checkMaxRAMSize(MaxRAMPercentage - headroomPercentage, false, maxcoopheap - (long)headroom, true);
|
||||
checkMaxRAMSize(MaxRAMPercentage + headroomPercentage, false, maxcoopheap + (long)headroom, false);
|
||||
checkMaxRAMSize(MaxRAMPercentage, true, maxcoopheap, true);
|
||||
}
|
||||
}
|
||||
@ -26,8 +26,7 @@ package gc.arguments;
|
||||
/*
|
||||
* @test TestUseCompressedOopsFlagsWithUlimit
|
||||
* @bug 8280761
|
||||
* @summary Verify correct UseCompressedOops when MaxRAM and MaxRAMPercentage
|
||||
* are specified with ulimit -v.
|
||||
* @summary Verify that ergonomic setting of UseCompressedOops adheres to ulimit -v
|
||||
* @library /test/lib
|
||||
* @library /
|
||||
* @requires vm.bits == "64"
|
||||
@ -50,10 +49,9 @@ import jdk.test.lib.process.ProcessTools;
|
||||
|
||||
public class TestUseCompressedOopsFlagsWithUlimit {
|
||||
|
||||
private static void checkFlag(long ulimit, long maxram, int maxrampercent, boolean expectcoop) throws Exception {
|
||||
private static void checkFlag(long ulimit, int maxrampercent, boolean expectcoop) throws Exception {
|
||||
|
||||
ArrayList<String> args = new ArrayList<String>();
|
||||
args.add("-XX:MaxRAM=" + maxram);
|
||||
args.add("-XX:MaxRAMPercentage=" + maxrampercent);
|
||||
args.add("-XX:+PrintFlagsFinal");
|
||||
|
||||
@ -74,7 +72,7 @@ public class TestUseCompressedOopsFlagsWithUlimit {
|
||||
boolean actualcoop = getFlagBoolValue("UseCompressedOops", stdout);
|
||||
if (actualcoop != expectcoop) {
|
||||
throw new RuntimeException("UseCompressedOops set to " + actualcoop +
|
||||
", expected " + expectcoop + " when running with the following flags: " + Arrays.asList(args).toString());
|
||||
", expected " + expectcoop + " when running with the following flags: " + Arrays.asList(args).toString() + ", and ulimit: " + ulimit);
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,10 +89,13 @@ public class TestUseCompressedOopsFlagsWithUlimit {
|
||||
// Verify that UseCompressedOops Ergo follows ulimit -v setting.
|
||||
|
||||
long oneG = 1L * 1024L * 1024L * 1024L;
|
||||
long ulimit = 10 * oneG;
|
||||
|
||||
// Args: ulimit, max_ram, max_ram_percent, expected_coop
|
||||
// Setting MaxRAMPercentage explicitly to make the test more resilient.
|
||||
checkFlag(10 * oneG, 32 * oneG, 100, true);
|
||||
checkFlag(10 * oneG, 128 * oneG, 100, true);
|
||||
// Regardless of how much memory that is available on the machine, we should
|
||||
// always get compressed oops if we have set a ulimit below the COOPS limit.
|
||||
// We set MaxRAMPercentage explicitly to make the test more resilient.
|
||||
|
||||
// Args: ulimit, maxrampercent, expectedcoop
|
||||
checkFlag(ulimit, 100, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,12 +28,12 @@ package gc.g1;
|
||||
* @bug 8013791
|
||||
* @requires vm.gc.G1
|
||||
* @summary Make sure that G1 ergonomics pick a heap size that is aligned with the region size
|
||||
* @run main/othervm -XX:+UseG1GC -XX:G1HeapRegionSize=32m -XX:MaxRAM=555m gc.g1.TestRegionAlignment
|
||||
*
|
||||
* When G1 ergonomically picks a maximum heap size it must be aligned to the region size.
|
||||
* This test tries to get the VM to pick a small and unaligned heap size (by using MaxRAM=555) and a
|
||||
* large region size (by using -XX:G1HeapRegionSize=32m). This will fail without the fix for 8013791.
|
||||
* @comment When G1 ergonomically picks a maximum heap size it must be aligned to the region size.
|
||||
* This test tries to get the VM to pick a small and unaligned heap size (by using MaxRAM=555) and a
|
||||
* large region size (by using -XX:G1HeapRegionSize=32m). This will fail without the fix for 8013791.
|
||||
* @run main/othervm -XX:+UseG1GC -XX:G1HeapRegionSize=32m -Xmx140m gc.g1.TestRegionAlignment
|
||||
*/
|
||||
|
||||
public class TestRegionAlignment {
|
||||
public static void main(String[] args) { }
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
*
|
||||
* @test PrintAsFlag
|
||||
* @summary verify that Flag::print_as_flag() works correctly. This is used by "jinfo -flag" and -XX:+PrintCommandLineFlags.
|
||||
* @run main/othervm -XX:+PrintCommandLineFlags -XX:-ShowMessageBoxOnError -XX:ParallelGCThreads=4 -XX:MaxRAM=1G -XX:ErrorFile="file" PrintAsFlag
|
||||
* @run main/othervm -XX:+PrintCommandLineFlags -XX:-ShowMessageBoxOnError -XX:ParallelGCThreads=4 -XX:ErrorLogTimeout=12345 -XX:ErrorFile="file" PrintAsFlag
|
||||
*/
|
||||
|
||||
public class PrintAsFlag {
|
||||
|
||||
@ -237,7 +237,6 @@ public class TestOptionsWithRanges {
|
||||
excludeTestMaxRange("G1ConcRefinementThreads");
|
||||
excludeTestMaxRange("InitialHeapSize");
|
||||
excludeTestMaxRange("MaxHeapSize");
|
||||
excludeTestMaxRange("MaxRAM");
|
||||
excludeTestMaxRange("NewSize");
|
||||
excludeTestMaxRange("ParallelGCThreads");
|
||||
excludeTestMaxRange("TLABSize");
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
*/
|
||||
|
||||
public class Uint64Test {
|
||||
private static final String FLAG_NAME = "MaxRAM";
|
||||
private static final String FLAG_NAME = "StringDeduplicationHashSeed";
|
||||
private static final Long[] TESTS = {0L, 100L, (long) Integer.MAX_VALUE,
|
||||
-1L, Long.MAX_VALUE, Long.MIN_VALUE};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user