8333962: Obsolete OldSize

Reviewed-by: dholmes, zgu
This commit is contained in:
Albert Mingkun Yang 2024-06-17 15:50:55 +00:00
parent cdf22b1320
commit c94af6f943
15 changed files with 24 additions and 185 deletions

View File

@ -32,6 +32,7 @@
#include "gc/shared/gcLocker.hpp"
#include "gc/shared/gcTimer.hpp"
#include "gc/shared/gcTrace.hpp"
#include "gc/shared/genArguments.hpp"
#include "gc/shared/space.hpp"
#include "gc/shared/spaceDecorator.hpp"
#include "logging/log.hpp"

View File

@ -540,10 +540,6 @@
"Soft limit for maximum heap size (in bytes)") \
constraint(SoftMaxHeapSizeConstraintFunc,AfterMemoryInit) \
\
product(size_t, OldSize, ScaleForWordSize(4*M), \
"(Deprecated) Initial tenured generation size (in bytes)") \
range(0, max_uintx) \
\
product(size_t, NewSize, ScaleForWordSize(1*M), \
"Initial new generation size (in bytes)") \
constraint(NewSizeConstraintFunc,AfterErgo) \

View File

@ -37,6 +37,8 @@ size_t MinNewSize = 0;
size_t MinOldSize = 0;
size_t MaxOldSize = 0;
size_t OldSize = 0;
size_t GenAlignment = 0;
size_t GenArguments::conservative_max_heap_alignment() { return (size_t)Generation::GenGrain; }
@ -152,24 +154,7 @@ void GenArguments::initialize_heap_flags_and_sizes() {
vm_exit_during_initialization("Invalid young gen ratio specified");
}
if (OldSize < old_gen_size_lower_bound()) {
FLAG_SET_ERGO(OldSize, old_gen_size_lower_bound());
}
if (!is_aligned(OldSize, GenAlignment)) {
FLAG_SET_ERGO(OldSize, align_down(OldSize, GenAlignment));
}
if (FLAG_IS_CMDLINE(OldSize) && FLAG_IS_DEFAULT(MaxHeapSize)) {
// NewRatio will be used later to set the young generation size so we use
// it to calculate how big the heap should be based on the requested OldSize
// and NewRatio.
assert(NewRatio > 0, "NewRatio should have been set up earlier");
size_t calculated_heapsize = (OldSize / NewRatio) * (NewRatio + 1);
calculated_heapsize = align_up(calculated_heapsize, HeapAlignment);
FLAG_SET_ERGO(MaxHeapSize, calculated_heapsize);
FLAG_SET_ERGO(InitialHeapSize, calculated_heapsize);
}
OldSize = old_gen_size_lower_bound();
// Adjust NewSize and OldSize or MaxHeapSize to match each other
if (NewSize + OldSize > MaxHeapSize) {
@ -185,23 +170,12 @@ void GenArguments::initialize_heap_flags_and_sizes() {
// HeapAlignment, and we just made sure that NewSize is aligned to
// GenAlignment. In initialize_flags() we verified that HeapAlignment
// is a multiple of GenAlignment.
FLAG_SET_ERGO(OldSize, MaxHeapSize - NewSize);
OldSize = MaxHeapSize - NewSize;
} else {
FLAG_SET_ERGO(MaxHeapSize, align_up(NewSize + OldSize, HeapAlignment));
}
}
// Update NewSize, if possible, to avoid sizing the young gen too small when only
// OldSize is set on the command line.
if (FLAG_IS_CMDLINE(OldSize) && !FLAG_IS_CMDLINE(NewSize)) {
if (OldSize < InitialHeapSize) {
size_t new_size = InitialHeapSize - OldSize;
if (new_size >= MinNewSize && new_size <= MaxNewSize) {
FLAG_SET_ERGO(NewSize, new_size);
}
}
}
DEBUG_ONLY(assert_flags();)
}
@ -215,12 +189,6 @@ void GenArguments::initialize_heap_flags_and_sizes() {
// In the absence of explicitly set command line flags, policies
// such as the use of NewRatio are used to size the generation.
// Minimum sizes of the generations may be different than
// the initial sizes. An inconsistency is permitted here
// in the total size that can be specified explicitly by
// command line specification of OldSize and NewSize and
// also a command line specification of -Xms. Issue a warning
// but allow the values to pass.
void GenArguments::initialize_size_info() {
GCArguments::initialize_size_info();
@ -286,37 +254,7 @@ void GenArguments::initialize_size_info() {
InitialHeapSize - initial_young_size,
MinHeapSize - MinNewSize);
size_t initial_old_size = OldSize;
// If no explicit command line flag has been set for the
// old generation size, use what is left.
if (!FLAG_IS_CMDLINE(OldSize)) {
// The user has not specified any value but the ergonomics
// may have chosen a value (which may or may not be consistent
// with the overall heap size). In either case make
// the minimum, maximum and initial sizes consistent
// with the young sizes and the overall heap sizes.
initial_old_size = clamp(InitialHeapSize - initial_young_size, MinOldSize, MaxOldSize);
// MaxOldSize and MinOldSize have already been made consistent above.
} else {
// OldSize has been explicitly set on the command line. Use it
// for the initial size but make sure the minimum allow a young
// generation to fit as well.
// If the user has explicitly set an OldSize that is inconsistent
// with other command line flags, issue a warning.
// The generation minimums and the overall heap minimum should
// be within one generation alignment.
if (initial_old_size > MaxOldSize) {
log_warning(gc, ergo)("Inconsistency between maximum heap size and maximum "
"generation sizes: using maximum heap = " SIZE_FORMAT
", -XX:OldSize flag is being ignored",
MaxHeapSize);
initial_old_size = MaxOldSize;
} else if (initial_old_size < MinOldSize) {
log_warning(gc, ergo)("Inconsistency between initial old size and minimum old size");
MinOldSize = initial_old_size;
}
}
size_t initial_old_size = clamp(InitialHeapSize - initial_young_size, MinOldSize, MaxOldSize);;
// The initial generation sizes should match the initial heap size,
// if not issue a warning and resize the generations. This behavior
@ -359,7 +297,7 @@ void GenArguments::initialize_size_info() {
}
if (OldSize != initial_old_size) {
FLAG_SET_ERGO(OldSize, initial_old_size);
OldSize = initial_old_size;
}
log_trace(gc, heap)("Minimum old " SIZE_FORMAT " Initial old " SIZE_FORMAT " Maximum old " SIZE_FORMAT,

View File

@ -33,6 +33,8 @@ extern size_t MinNewSize;
extern size_t MinOldSize;
extern size_t MaxOldSize;
extern size_t OldSize;
extern size_t GenAlignment;
class GenArguments : public GCArguments {

View File

@ -34,6 +34,7 @@
#include "compiler/compilerDefinitions.hpp"
#include "gc/shared/gcArguments.hpp"
#include "gc/shared/gcConfig.hpp"
#include "gc/shared/genArguments.hpp"
#include "gc/shared/stringdedup/stringDedup.hpp"
#include "gc/shared/tlab_globals.hpp"
#include "jvm.h"
@ -502,7 +503,6 @@ static SpecialFlag const special_jvm_flags[] = {
{ "RequireSharedSpaces", JDK_Version::jdk(18), JDK_Version::jdk(19), JDK_Version::undefined() },
{ "UseSharedSpaces", JDK_Version::jdk(18), JDK_Version::jdk(19), JDK_Version::undefined() },
{ "DontYieldALot", JDK_Version::jdk(23), JDK_Version::jdk(24), JDK_Version::jdk(25) },
{ "OldSize", JDK_Version::jdk(23), JDK_Version::jdk(24), JDK_Version::jdk(25) },
{ "PreserveAllAnnotations", JDK_Version::jdk(23), JDK_Version::jdk(24), JDK_Version::jdk(25) },
{ "UseNotificationThread", JDK_Version::jdk(23), JDK_Version::jdk(24), JDK_Version::jdk(25) },
{ "UseEmptySlotsInSupers", JDK_Version::jdk(23), JDK_Version::jdk(24), JDK_Version::jdk(25) },
@ -513,6 +513,7 @@ static SpecialFlag const special_jvm_flags[] = {
{ "MetaspaceReclaimPolicy", JDK_Version::undefined(), JDK_Version::jdk(21), JDK_Version::undefined() },
{ "OldSize", JDK_Version::jdk(23), JDK_Version::jdk(24), JDK_Version::jdk(25) },
#if defined(X86)
{ "UseRTMLocking", JDK_Version::jdk(23), JDK_Version::jdk(24), JDK_Version::jdk(25) },
{ "UseRTMDeopt", JDK_Version::jdk(23), JDK_Version::jdk(24), JDK_Version::jdk(25) },

View File

@ -80,7 +80,6 @@ public class HeapSummary extends Tool {
printValMB("MaxHeapSize = ", getFlagValue("MaxHeapSize", flagMap));
printValMB("NewSize = ", getFlagValue("NewSize", flagMap));
printValMB("MaxNewSize = ", getFlagValue("MaxNewSize", flagMap));
printValMB("OldSize = ", getFlagValue("OldSize", flagMap));
printValue("NewRatio = ", getFlagValue("NewRatio", flagMap));
printValue("SurvivorRatio = ", getFlagValue("SurvivorRatio", flagMap));
printValMB("MetaspaceSize = ", getFlagValue("MetaspaceSize", flagMap));

View File

@ -63,11 +63,9 @@ class TestGenCollectorPolicy {
AutoSaveRestore<size_t> FLAG_GUARD(MaxNewSize);
AutoSaveRestore<size_t> FLAG_GUARD(MinHeapDeltaBytes);
AutoSaveRestore<size_t> FLAG_GUARD(NewSize);
AutoSaveRestore<size_t> FLAG_GUARD(OldSize);
MinHeapSize = 40 * M;
FLAG_SET_ERGO(InitialHeapSize, 100 * M);
FLAG_SET_ERGO(OldSize, 4 * M);
FLAG_SET_ERGO(NewSize, 1 * M);
FLAG_SET_ERGO(MaxNewSize, 80 * M);
@ -144,14 +142,6 @@ class TestGenCollectorPolicy {
}
};
class SetOldSizeCmd : public UnaryExecutor {
public:
SetOldSizeCmd(size_t param) : UnaryExecutor(param) { }
void execute() {
FLAG_SET_CMDLINE(OldSize, param);
}
};
class SetMaxNewSizeCmd : public BinaryExecutor {
public:
SetMaxNewSizeCmd(size_t param1, size_t param2) : BinaryExecutor(param1, param2) { }
@ -162,49 +152,6 @@ class TestGenCollectorPolicy {
FLAG_SET_CMDLINE(MaxNewSize, new_size_value);
}
};
class CheckOldMin : public UnaryExecutor {
public:
CheckOldMin(size_t param) : UnaryExecutor(param) { }
void execute() {
SerialArguments sa;
sa.initialize_heap_sizes();
ASSERT_LE(MinOldSize, param);
}
};
class CheckOldInitial : public Executor {
public:
void execute() {
size_t heap_alignment = GCArguments::compute_heap_alignment();
SerialArguments sa;
sa.initialize_heap_sizes();
size_t expected_old_initial = align_up(InitialHeapSize, heap_alignment)
- MaxNewSize;
ASSERT_EQ(expected_old_initial, OldSize);
}
};
class CheckOldInitialMaxNewSize : public BinaryExecutor {
public:
CheckOldInitialMaxNewSize(size_t param1, size_t param2) : BinaryExecutor(param1, param2) { }
void execute() {
size_t heap_alignment = GCArguments::compute_heap_alignment();
size_t new_size_value = align_up(MaxHeapSize, heap_alignment)
- param1 + param2;
SerialArguments sa;
sa.initialize_heap_sizes();
size_t expected_old_initial = align_up(MaxHeapSize, heap_alignment)
- new_size_value;
ASSERT_EQ(expected_old_initial, OldSize);
}
};
};
@ -244,29 +191,3 @@ TEST_OTHER_VM(CollectorPolicy, young_cmd) {
TestGenCollectorPolicy::CheckYoungInitial checker_large(80 * M);
TestGenCollectorPolicy::TestWrapper::test(&setter_large, &checker_large);
}
// Since a flag has been set with FLAG_SET_CMDLINE it
// will be treated as it have been set on the command line for
// the rest of the VM lifetime. This is an irreversible change and
// could impact other tests so we use TEST_OTHER_VM
TEST_OTHER_VM(CollectorPolicy, old_cmd) {
// If OldSize is set on the command line, it should be used
// for both min and initial old size if less than min heap.
TestGenCollectorPolicy::SetOldSizeCmd setter(20 * M);
TestGenCollectorPolicy::CheckOldMin checker_min(20 * M);
TestGenCollectorPolicy::TestWrapper::test(&setter, &checker_min);
TestGenCollectorPolicy::CheckOldInitial checker_initial;
TestGenCollectorPolicy::TestWrapper::test(&setter, &checker_initial);
// If MaxNewSize is large, the maximum OldSize will be less than
// what's requested on the command line and it should be reset
// ergonomically.
// We intentionally set MaxNewSize + OldSize > MaxHeapSize
TestGenCollectorPolicy::SetOldSizeCmd setter_old_size(30 * M);
TestGenCollectorPolicy::SetMaxNewSizeCmd setter_max_new_size(30 * M, 20 * M);
TestGenCollectorPolicy::CheckOldInitialMaxNewSize checker_large(30 * M, 20 * M);
TestGenCollectorPolicy::TestWrapper::test(&setter_old_size, &setter_max_new_size, &checker_large);
}

View File

@ -59,15 +59,10 @@ class TestMaxHeapSizeTools {
}
public static void checkMinInitialErgonomics(String gcflag) throws Exception {
// heap sizing ergonomics use the value NewSize + OldSize as default values
// for ergonomics calculation. Retrieve these values.
long[] values = new long[2];
getNewOldSize(gcflag, values);
// we check cases with values smaller and larger than this default value.
long newPlusOldSize = values[0] + values[1];
long smallValue = newPlusOldSize / 2;
long largeValue = newPlusOldSize * 2;
long initialHeapSize = getInitialHeapSize(gcflag);
long smallValue = initialHeapSize / 2;
long largeValue = initialHeapSize * 2;
long maxHeapSize = largeValue + (2 * 1024 * 1024);
// -Xms is not set
@ -114,14 +109,13 @@ class TestMaxHeapSizeTools {
return (value + alignmentMinusOne) & ~alignmentMinusOne;
}
private static void getNewOldSize(String gcflag, long[] values) throws Exception {
private static long getInitialHeapSize(String gcflag) throws Exception {
OutputAnalyzer output = GCArguments.executeTestJava(gcflag,
"-XX:+PrintFlagsFinal", "-version");
output.shouldHaveExitValue(0);
String stdout = output.getStdout();
values[0] = getFlagValue(" NewSize", stdout);
values[1] = getFlagValue(" OldSize", stdout);
return getFlagValue(" InitialHeapSize", stdout);
}
public static void checkGenMaxHeapErgo(String gcflag) throws Exception {

View File

@ -29,7 +29,7 @@ package gc.arguments;
* @summary Make sure that MaxNewSize always has a useful value after argument
* processing.
* @key flag-sensitive
* @requires vm.gc.Serial & vm.opt.MaxNewSize == null & vm.opt.NewRatio == null & vm.opt.NewSize == null & vm.opt.OldSize == null
* @requires vm.gc.Serial & vm.opt.MaxNewSize == null & vm.opt.NewRatio == null & vm.opt.NewSize == null
* @library /test/lib
* @library /
* @modules java.base/jdk.internal.misc
@ -44,7 +44,7 @@ package gc.arguments;
* @summary Make sure that MaxNewSize always has a useful value after argument
* processing.
* @key flag-sensitive
* @requires vm.gc.Parallel & vm.opt.MaxNewSize == null & vm.opt.NewRatio == null & vm.opt.NewSize == null & vm.opt.OldSize == null
* @requires vm.gc.Parallel & vm.opt.MaxNewSize == null & vm.opt.NewRatio == null & vm.opt.NewSize == null
* @library /test/lib
* @library /
* @modules java.base/jdk.internal.misc
@ -59,7 +59,7 @@ package gc.arguments;
* @summary Make sure that MaxNewSize always has a useful value after argument
* processing.
* @key flag-sensitive
* @requires vm.gc.G1 & vm.opt.MaxNewSize == null & vm.opt.NewRatio == null & vm.opt.NewSize == null & vm.opt.OldSize == null
* @requires vm.gc.G1 & vm.opt.MaxNewSize == null & vm.opt.NewRatio == null & vm.opt.NewSize == null
* @library /test/lib
* @library /
* @modules java.base/jdk.internal.misc
@ -116,7 +116,6 @@ public class TestMaxNewSize {
checkMaxNewSize(new String[] { gcName, "-Xmx128M" }, 128 * M);
checkMaxNewSize(new String[] { gcName, "-Xmx128M", "-XX:NewRatio=5" }, 128 * M);
checkMaxNewSize(new String[] { gcName, "-Xmx128M", "-XX:NewSize=32M" }, 128 * M);
checkMaxNewSize(new String[] { gcName, "-Xmx128M", "-XX:OldSize=96M" }, 128 * M);
checkMaxNewSize(new String[] { gcName, "-Xmx128M", "-XX:MaxNewSize=32M" }, 32 * M);
checkMaxNewSize(new String[] { gcName, "-Xmx128M", "-XX:NewSize=32M", "-XX:MaxNewSize=32M" }, 32 * M);
checkMaxNewSize(new String[] { gcName, "-Xmx128M", "-XX:NewRatio=6", "-XX:MaxNewSize=32M" }, 32 * M);

View File

@ -29,7 +29,7 @@ package gc.g1;
* @summary Check that benign (0-sized) out of heap bounds card table invalidations do not assert.
* @requires vm.gc.G1
* @requires vm.debug
* @run main/othervm -XX:NewSize=1M -Xlog:gc -XX:MaxNewSize=1m -XX:-UseTLAB -XX:OldSize=63M -XX:MaxHeapSize=64M gc.g1.TestInvalidateArrayCopy
* @run main/othervm -XX:NewSize=1M -Xlog:gc -XX:MaxNewSize=1m -XX:-UseTLAB -XX:MaxHeapSize=64M gc.g1.TestInvalidateArrayCopy
*/
// The test allocates zero-sized arrays of j.l.O and tries to arraycopy random data into it so

View File

@ -40,7 +40,6 @@ public class PLABUtils {
private final static String[] GC_TUNE_OPTIONS = {
"-XX:+UseG1GC",
"-XX:G1HeapRegionSize=1m",
"-XX:OldSize=64m",
"-XX:-UseAdaptiveSizePolicy",
"-XX:MaxTenuringThreshold=1",
"-XX:-UseTLAB",

View File

@ -240,7 +240,6 @@ public class TestOptionsWithRanges {
excludeTestMaxRange("MaxHeapSize");
excludeTestMaxRange("MaxRAM");
excludeTestMaxRange("NewSize");
excludeTestMaxRange("OldSize");
excludeTestMaxRange("ParallelGCThreads");
excludeTestMaxRange("TLABSize");

View File

@ -79,10 +79,6 @@ public class MemOptionsTest {
// positive("Initial young generation size at 32-bit range", "-Xmx5G", "-XX:NewSize=4G");
// positive("Initial young generation size outside 32-bit range", "-Xmx5G", "-XX:NewSize=4G");
// positive("Initial old generation size within 32-bit range", "-Xmx3G", "-XX:OldSize=2G");
// positive("Initial old generation size at 32-bit range", "-Xmx5G", "-XX:OldSize=4G");
// positive("Initial old generation size outside 32-bit range", "-Xmx5G", "-XX:OldSize=4G");
if (!failed.isEmpty()) {
throw new AssertionError(String.format("%d cases failed : %s", failed.size(), failed));
}

View File

@ -40,13 +40,12 @@ import jdk.test.lib.jfr.Events;
* @key jfr
* @summary Test checks that flags of type size_t are being sent to the jfr
* @library /test/lib
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseG1GC -XX:+UseTLAB -XX:MinTLABSize=3k -XX:OldSize=30m -XX:YoungPLABSize=3k -XX:MaxDirectMemorySize=5M jdk.jfr.event.runtime.TestSizeTFlags
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseG1GC -XX:+UseTLAB -XX:MinTLABSize=3k -XX:YoungPLABSize=3k -XX:MaxDirectMemorySize=5M jdk.jfr.event.runtime.TestSizeTFlags
*/
public class TestSizeTFlags {
private static final String EVENT_NAME = EventNames.UnsignedLongFlag;
private static final int NUMBER_OF_FLAGS_TO_CHECK = 4;
private static final int NUMBER_OF_FLAGS_TO_CHECK = 3;
private static final long MIN_TLAB_SIZE_FLAG_VALUE = 3*1024L;
private static final long OLD_SIZE_FLAG_VALUE = 30*1024*1024L;
private static final long YOUNG_PLAB_SIZE_FLAG_VALUE = 3*1024L;
private static final long MAX_DIRECT_MEMORY_SIZE_FLAG_VALUE = 5*1024*1024L;
@ -71,16 +70,12 @@ public class TestSizeTFlags {
flagsFoundWithExpectedValue[0] = MIN_TLAB_SIZE_FLAG_VALUE == value;
continue;
}
case "OldSize": {
flagsFoundWithExpectedValue[1] = OLD_SIZE_FLAG_VALUE == value;
continue;
}
case "YoungPLABSize": {
flagsFoundWithExpectedValue[2] = YOUNG_PLAB_SIZE_FLAG_VALUE == value;
flagsFoundWithExpectedValue[1] = YOUNG_PLAB_SIZE_FLAG_VALUE == value;
continue;
}
case "MaxDirectMemorySize": {
flagsFoundWithExpectedValue[3] = MAX_DIRECT_MEMORY_SIZE_FLAG_VALUE == value;
flagsFoundWithExpectedValue[2] = MAX_DIRECT_MEMORY_SIZE_FLAG_VALUE == value;
continue;
}
default: {

View File

@ -54,7 +54,6 @@ public class JMapHeapConfigTest {
"MaxHeapSize",
"NewSize",
"MaxNewSize",
"OldSize",
"NewRatio",
"SurvivorRatio",
"MetaspaceSize",