diff --git a/src/hotspot/share/gc/shared/gc_globals.hpp b/src/hotspot/share/gc/shared/gc_globals.hpp index c910294419744..1ff6fd493a76e 100644 --- a/src/hotspot/share/gc/shared/gc_globals.hpp +++ b/src/hotspot/share/gc/shared/gc_globals.hpp @@ -262,10 +262,6 @@ "and ObjArrayMarkingStride.") \ constraint(ArrayMarkingMinStrideConstraintFunc,AfterErgo) \ \ - 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 " \ "(System RAM) * MaxRAMPercentage / 100") \ diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index 72e3c4fc4b468..d1304133d6314 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -533,7 +533,6 @@ static SpecialFlag const special_jvm_flags[] = { { "DynamicDumpSharedSpaces", JDK_Version::jdk(18), JDK_Version::jdk(19), JDK_Version::undefined() }, { "RequireSharedSpaces", JDK_Version::jdk(18), JDK_Version::jdk(19), JDK_Version::undefined() }, { "UseSharedSpaces", JDK_Version::jdk(18), JDK_Version::jdk(19), JDK_Version::undefined() }, - { "AggressiveHeap", JDK_Version::jdk(26), JDK_Version::jdk(27), JDK_Version::jdk(28) }, // --- Deprecated alias flags (see also aliased_jvm_flags) - sorted by obsolete_in then expired_in: { "CreateMinidumpOnCrash", JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() }, @@ -556,6 +555,7 @@ static SpecialFlag const special_jvm_flags[] = { { "AlwaysActAsServerClassMachine", JDK_Version::jdk(26), JDK_Version::jdk(27), JDK_Version::jdk(28) }, { "UseXMMForArrayCopy", JDK_Version::undefined(), JDK_Version::jdk(27), JDK_Version::jdk(28) }, { "UseNewLongLShift", JDK_Version::undefined(), JDK_Version::jdk(27), JDK_Version::jdk(28) }, + { "AggressiveHeap", 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() }, @@ -1490,13 +1490,7 @@ jint Arguments::set_ergonomics_flags() { } size_t Arguments::limit_heap_by_allocatable_memory(size_t limit) { - // The AggressiveHeap check is a temporary workaround to avoid calling - // GCarguments::heap_virtual_to_physical_ratio() before a GC has been - // selected. This works because AggressiveHeap implies UseParallelGC - // where we know the ratio will be 1. Once the AggressiveHeap option is - // removed, this can be cleaned up. - size_t heap_virtual_to_physical_ratio = (AggressiveHeap ? 1 : GCConfig::arguments()->heap_virtual_to_physical_ratio()); - size_t fraction = MaxVirtMemFraction * heap_virtual_to_physical_ratio; + size_t fraction = MaxVirtMemFraction * GCConfig::arguments()->heap_virtual_to_physical_ratio(); size_t max_allocatable = os::commit_memory_limit(); return MIN2(limit, max_allocatable / fraction); @@ -1627,107 +1621,6 @@ void Arguments::set_heap_size() { } } -// This option inspects the machine and attempts to set various -// parameters to be optimal for long-running, memory allocation -// intensive jobs. It is intended for machines with large -// amounts of cpu and memory. -jint Arguments::set_aggressive_heap_flags() { - // initHeapSize is needed since _initial_heap_size is 4 bytes on a 32 bit - // VM, but we may not be able to represent the total physical memory - // available (like having 8gb of memory on a box but using a 32bit VM). - // Thus, we need to make sure we're using a julong for intermediate - // calculations. - julong initHeapSize; - physical_memory_size_type phys_mem = os::physical_memory(); - julong total_memory = static_cast(phys_mem); - - if (total_memory < (julong) 256 * M) { - jio_fprintf(defaultStream::error_stream(), - "You need at least 256mb of memory to use -XX:+AggressiveHeap\n"); - vm_exit(1); - } - - // The heap size is half of available memory, or (at most) - // all of possible memory less 160mb (leaving room for the OS - // when using ISM). This is the maximum; because adaptive sizing - // is turned on below, the actual space used may be smaller. - - initHeapSize = MIN2(total_memory / (julong) 2, - total_memory - (julong) 160 * M); - - initHeapSize = limit_heap_by_allocatable_memory(initHeapSize); - - if (FLAG_IS_DEFAULT(MaxHeapSize)) { - if (FLAG_SET_CMDLINE(MaxHeapSize, initHeapSize) != JVMFlag::SUCCESS) { - return JNI_EINVAL; - } - if (FLAG_SET_CMDLINE(InitialHeapSize, initHeapSize) != JVMFlag::SUCCESS) { - return JNI_EINVAL; - } - if (FLAG_SET_CMDLINE(MinHeapSize, initHeapSize) != JVMFlag::SUCCESS) { - return JNI_EINVAL; - } - } - if (FLAG_IS_DEFAULT(NewSize)) { - // Make the young generation 3/8ths of the total heap. - if (FLAG_SET_CMDLINE(NewSize, - ((julong) MaxHeapSize / (julong) 8) * (julong) 3) != JVMFlag::SUCCESS) { - return JNI_EINVAL; - } - if (FLAG_SET_CMDLINE(MaxNewSize, NewSize) != JVMFlag::SUCCESS) { - return JNI_EINVAL; - } - } - -#if !defined(_ALLBSD_SOURCE) && !defined(AIX) // UseLargePages is not yet supported on BSD and AIX. - FLAG_SET_DEFAULT(UseLargePages, true); -#endif - - // Increase some data structure sizes for efficiency - if (FLAG_SET_CMDLINE(ResizeTLAB, false) != JVMFlag::SUCCESS) { - return JNI_EINVAL; - } - if (FLAG_SET_CMDLINE(TLABSize, 256 * K) != JVMFlag::SUCCESS) { - return JNI_EINVAL; - } - - // See the OldPLABSize comment below, but replace 'after promotion' - // with 'after copying'. YoungPLABSize is the size of the survivor - // space per-gc-thread buffers. The default is 4kw. - if (FLAG_SET_CMDLINE(YoungPLABSize, 256 * K) != JVMFlag::SUCCESS) { // Note: this is in words - return JNI_EINVAL; - } - - // OldPLABSize is the size of the buffers in the old gen that - // UseParallelGC uses to promote live data that doesn't fit in the - // survivor spaces. At any given time, there's one for each gc thread. - // The default size is 1kw. These buffers are rarely used, since the - // survivor spaces are usually big enough. For specjbb, however, there - // are occasions when there's lots of live data in the young gen - // and we end up promoting some of it. We don't have a definite - // explanation for why bumping OldPLABSize helps, but the theory - // is that a bigger PLAB results in retaining something like the - // original allocation order after promotion, which improves mutator - // locality. A minor effect may be that larger PLABs reduce the - // number of PLAB allocation events during gc. The value of 8kw - // was arrived at by experimenting with specjbb. - if (FLAG_SET_CMDLINE(OldPLABSize, 8 * K) != JVMFlag::SUCCESS) { // Note: this is in words - return JNI_EINVAL; - } - - // Enable parallel GC and adaptive generation sizing - if (FLAG_SET_CMDLINE(UseParallelGC, true) != JVMFlag::SUCCESS) { - return JNI_EINVAL; - } - - // Encourage steady state memory management - if (FLAG_SET_CMDLINE(ThresholdTolerance, 100) != JVMFlag::SUCCESS) { - return JNI_EINVAL; - } - - return JNI_OK; -} - // This must be called after ergonomics. void Arguments::set_bytecode_flags() { if (!RewriteBytecodes) { @@ -2938,16 +2831,6 @@ jint Arguments::finalize_vm_init_args() { return JNI_ERR; } - // This must be done after all arguments have been processed - // and the container support has been initialized since AggressiveHeap - // relies on the amount of total memory available. - if (AggressiveHeap) { - jint result = set_aggressive_heap_flags(); - if (result != JNI_OK) { - return result; - } - } - // CompileThresholdScaling == 0.0 is same as -Xint: Disable compilation (enable interpreter-only mode), // but like -Xint, leave compilation thresholds unaffected. // With tiered compilation disabled, setting CompileThreshold to 0 disables compilation as well. diff --git a/src/hotspot/share/runtime/arguments.hpp b/src/hotspot/share/runtime/arguments.hpp index f2bcc21e1236c..2c31383f7a45f 100644 --- a/src/hotspot/share/runtime/arguments.hpp +++ b/src/hotspot/share/runtime/arguments.hpp @@ -303,8 +303,6 @@ class Arguments : AllStatic { // Aggressive optimization flags. static jint set_aggressive_opts_flags(); - static jint set_aggressive_heap_flags(); - // Argument parsing static bool parse_argument(const char* arg, JVMFlagOrigin origin); static bool process_argument(const char* arg, jboolean ignore_unrecognized, JVMFlagOrigin origin); diff --git a/src/java.base/share/man/java.md b/src/java.base/share/man/java.md index 18d64b3a4c2b2..6c079c268b168 100644 --- a/src/java.base/share/man/java.md +++ b/src/java.base/share/man/java.md @@ -2938,12 +2938,6 @@ they're used. (`-XX:+UseParallelGC` or `-XX:+UseG1GC`). Other collectors employing multiple threads always perform reference processing in parallel. -[`-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 - the configuration of the computer (RAM and CPU). By default, the option - is disabled and the heap sizes are configured less aggressively. - ## Obsolete Java Options These `java` options are still accepted but ignored, and a warning is issued @@ -2976,6 +2970,12 @@ when they're used. -XX:{+|-}UseJVMCICompiler ``` +[`-XX:+AggressiveHeap`]{#-XX__AggressiveHeap} +: Enabled Java heap optimization. This set various parameters to be + optimal for long-running jobs with intensive memory allocation, based on + the configuration of the computer (RAM and CPU). By default, the option + was disabled and the heap sizes configured less aggressively. + ## Removed Java Options No documented java options have been removed in JDK @@VERSION_SPECIFICATION@@. diff --git a/test/hotspot/jtreg/gc/arguments/TestAggressiveHeap.java b/test/hotspot/jtreg/gc/arguments/TestAggressiveHeap.java deleted file mode 100644 index 758747d451a1b..0000000000000 --- a/test/hotspot/jtreg/gc/arguments/TestAggressiveHeap.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package gc.arguments; - -/* - * @test TestAggressiveHeap - * @bug 8179084 - * @requires vm.gc.Parallel - * @summary Test argument processing for -XX:+AggressiveHeap. - * @library /test/lib - * @library / - * @modules java.management - * @run driver gc.arguments.TestAggressiveHeap - */ - -import java.lang.management.ManagementFactory; -import javax.management.MBeanServer; -import javax.management.ObjectName; - -import jdk.test.lib.process.OutputAnalyzer; -import jtreg.SkippedException; - -public class TestAggressiveHeap { - - public static void main(String args[]) throws Exception { - if (canUseAggressiveHeapOption()) { - testFlag(); - } - } - - // Note: Not a normal boolean flag; -XX:-AggressiveHeap is invalid. - private static final String option = "-XX:+AggressiveHeap"; - - // Option requires at least 256M, else error during option processing. - private static final long minMemory = 256 * 1024 * 1024; - - // Setting the heap to half of the physical memory is not suitable for - // a test environment with many tests running concurrently, setting to - // half of the required size instead. - private static final String heapSizeOption = "-Xmx128M"; - - // bool UseParallelGC = true {product} {command line} - private static final String parallelGCPattern = - " *bool +UseParallelGC *= *true +\\{product\\} *\\{command line\\}"; - - private static void testFlag() throws Exception { - OutputAnalyzer output = GCArguments.executeTestJava( - option, heapSizeOption, "-XX:+PrintFlagsFinal", "-version"); - - output.shouldHaveExitValue(0); - - String value = output.firstMatch(parallelGCPattern); - if (value == null) { - throw new RuntimeException( - option + " didn't set UseParallelGC as if from command line"); - } - } - - private static boolean haveRequiredMemory() throws Exception { - MBeanServer server = ManagementFactory.getPlatformMBeanServer(); - ObjectName os = new ObjectName("java.lang", "type", "OperatingSystem"); - Object attr = server.getAttribute(os, "TotalPhysicalMemorySize"); - String value = attr.toString(); - long memory = Long.parseLong(value); - return memory >= minMemory; - } - - private static boolean canUseAggressiveHeapOption() throws Exception { - if (!haveRequiredMemory()) { - throw new SkippedException("Skipping test of " + option + " : insufficient memory"); - } - return true; - } -}