Skip to content

Commit b1f3a7a

Browse files
committed
[GR-35746] Decrease aligned chunk size to 512 KB.
PullRequest: graal/10541
2 parents 4874d7e + 81235de commit b1f3a7a

File tree

5 files changed

+21
-15
lines changed

5 files changed

+21
-15
lines changed

substratevm/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
This changelog summarizes major changes to GraalVM Native Image.
44

5+
## Version 23.1.0
6+
* (GR-35746) Lower the default aligned chunk size from 1 MB to 512 KB for the serial and epsilon GCs, reducing memory usage and image size in many cases.
7+
58
## Version 23.0.0
69
* (GR-40187) Report invalid use of SVM specific classes on image class- or module-path as error. As a temporary workaround, `-H:+AllowDeprecatedBuilderClassesOnImageClasspath` allows turning the error into a warning.
710
* (GR-41196) Provide `.debug.svm.imagebuild.*` sections that contain build options and properties used in the build of the image.

substratevm/mx.substratevm/suite.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@
621621
],
622622
"requiresConcealed" : {
623623
"java.base" : [
624+
"jdk.internal",
624625
"jdk.internal.event",
625626
"jdk.internal.misc",
626627
"jdk.internal.vm.annotation",

substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/SerialAndEpsilonGCOptions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public final class SerialAndEpsilonGCOptions {
4545
public static final RuntimeOptionKey<Integer> MaximumYoungGenerationSizePercent = new NotifyGCRuntimeOptionKey<>(10, SerialAndEpsilonGCOptions::serialOrEpsilonGCOnly);
4646

4747
@Option(help = "The size of an aligned chunk. Serial and epsilon GC only.", type = OptionType.Expert) //
48-
public static final HostedOptionKey<Long> AlignedHeapChunkSize = new HostedOptionKey<>(1L * 1024L * 1024L, SerialAndEpsilonGCOptions::serialOrEpsilonGCOnly) {
48+
public static final HostedOptionKey<Long> AlignedHeapChunkSize = new HostedOptionKey<>(512 * 1024L, SerialAndEpsilonGCOptions::serialOrEpsilonGCOnly) {
4949
@Override
5050
protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Long oldValue, Long newValue) {
5151
int multiple = 4096;
@@ -57,7 +57,7 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Long oldV
5757
* This should be a fraction of the size of an aligned chunk, else large small arrays will not
5858
* fit in an aligned chunk.
5959
*/
60-
@Option(help = "The size at or above which an array will be allocated in its own unaligned chunk. 0 implies (AlignedHeapChunkSize / 8). Serial and epsilon GC only.", type = OptionType.Expert) //
60+
@Option(help = "The size at or above which an array will be allocated in its own unaligned chunk. Serial and epsilon GC only.", type = OptionType.Expert) //
6161
public static final HostedOptionKey<Long> LargeArrayThreshold = new HostedOptionKey<>(0L, SerialAndEpsilonGCOptions::serialOrEpsilonGCOnly);
6262

6363
@Option(help = "Fill unused memory chunks with a sentinel value. Serial and epsilon GC only.", type = OptionType.Debug) //

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/HostedConfiguration.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
*/
2525
package com.oracle.svm.hosted;
2626

27-
import java.lang.annotation.Annotation;
2827
import java.nio.file.Path;
2928
import java.util.ArrayList;
3029
import java.util.HashSet;
@@ -75,15 +74,13 @@
7574
import com.oracle.svm.hosted.meta.HostedMetaAccess;
7675
import com.oracle.svm.hosted.meta.HostedUniverse;
7776
import com.oracle.svm.hosted.substitute.UnsafeAutomaticSubstitutionProcessor;
78-
import com.oracle.svm.util.ReflectionUtil;
7977

78+
import jdk.internal.ValueBased;
8079
import jdk.vm.ci.meta.JavaKind;
8180
import jdk.vm.ci.meta.MetaAccessProvider;
8281
import jdk.vm.ci.meta.ResolvedJavaField;
8382

8483
public class HostedConfiguration {
85-
@SuppressWarnings("unchecked") private static final Class<? extends Annotation> VALUE_BASED_ANNOTATION = //
86-
(Class<? extends Annotation>) ReflectionUtil.lookupClass(false, "jdk.internal.ValueBased");
8784

8885
public HostedConfiguration() {
8986
}
@@ -269,7 +266,7 @@ protected void processedSynchronizedTypes(BigBang bb, HostedUniverse hUniverse,
269266
* Types that must be immutable cannot have a monitor field.
270267
*/
271268
protected static void maybeSetMonitorField(HostedUniverse hUniverse, Set<AnalysisType> immutableTypes, AnalysisType type) {
272-
if (!type.isArray() && !immutableTypes.contains(type) && !type.isAnnotationPresent(VALUE_BASED_ANNOTATION)) {
269+
if (!type.isArray() && !immutableTypes.contains(type) && !type.isAnnotationPresent(ValueBased.class)) {
273270
setMonitorField(hUniverse, type);
274271
}
275272
}

substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestObjectAllocationInNewTLABEvent.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,16 @@
3333
import org.junit.Test;
3434

3535
import com.oracle.svm.core.NeverInline;
36+
import com.oracle.svm.core.genscavenge.HeapParameters;
3637
import com.oracle.svm.core.jfr.JfrEvent;
38+
import com.oracle.svm.core.util.UnsignedUtils;
3739

3840
import jdk.jfr.consumer.RecordedClass;
3941
import jdk.jfr.consumer.RecordedEvent;
4042
import jdk.jfr.consumer.RecordedThread;
4143

4244
public class TestObjectAllocationInNewTLABEvent extends JfrRecordingTest {
4345
private static final int K = 1024;
44-
private static final int DEFAULT_ALIGNED_HEAP_CHUNK_SIZE = 1024 * K;
4546

4647
@Override
4748
public String[] getTestedEvents() {
@@ -50,6 +51,8 @@ public String[] getTestedEvents() {
5051

5152
@Override
5253
protected void validateEvents(List<RecordedEvent> events) throws Throwable {
54+
final int alignedHeapChunkSize = UnsignedUtils.safeToInt(HeapParameters.getAlignedHeapChunkSize());
55+
5356
boolean foundBigByteArray = false;
5457
boolean foundSmallByteArray = false;
5558
boolean foundBigCharArray = false;
@@ -66,16 +69,16 @@ protected void validateEvents(List<RecordedEvent> events) throws Throwable {
6669
String className = event.<RecordedClass> getValue("objectClass").getName();
6770

6871
// >= To account for size of reference
69-
if (allocationSize >= 2 * DEFAULT_ALIGNED_HEAP_CHUNK_SIZE && tlabSize >= 2 * DEFAULT_ALIGNED_HEAP_CHUNK_SIZE) {
72+
if (allocationSize >= 2 * alignedHeapChunkSize && tlabSize >= 2 * alignedHeapChunkSize) {
7073
// verify previous owner
7174
if (className.equals(char[].class.getName())) {
7275
foundBigCharArray = true;
7376
} else if (className.equals(byte[].class.getName())) {
7477
foundBigByteArray = true;
7578
}
76-
} else if (allocationSize >= K && tlabSize == DEFAULT_ALIGNED_HEAP_CHUNK_SIZE && className.equals(byte[].class.getName())) {
79+
} else if (allocationSize >= K && tlabSize == alignedHeapChunkSize && className.equals(byte[].class.getName())) {
7780
foundSmallByteArray = true;
78-
} else if (tlabSize == DEFAULT_ALIGNED_HEAP_CHUNK_SIZE && className.equals(Helper.class.getName())) {
81+
} else if (tlabSize == alignedHeapChunkSize && className.equals(Helper.class.getName())) {
7982
foundInstance = true;
8083
}
8184
}
@@ -88,17 +91,19 @@ protected void validateEvents(List<RecordedEvent> events) throws Throwable {
8891

8992
@Test
9093
public void test() throws Exception {
94+
final int alignedHeapChunkSize = UnsignedUtils.safeToInt(HeapParameters.getAlignedHeapChunkSize());
95+
9196
// Allocate large arrays (always need a new TLAB).
92-
allocateByteArray(2 * DEFAULT_ALIGNED_HEAP_CHUNK_SIZE);
93-
allocateCharArray(DEFAULT_ALIGNED_HEAP_CHUNK_SIZE);
97+
allocateByteArray(2 * alignedHeapChunkSize);
98+
allocateCharArray(alignedHeapChunkSize);
9499

95100
// Exhaust TLAB with small arrays.
96-
for (int i = 0; i < DEFAULT_ALIGNED_HEAP_CHUNK_SIZE / K; i++) {
101+
for (int i = 0; i < alignedHeapChunkSize / K; i++) {
97102
allocateByteArray(K);
98103
}
99104

100105
// Exhaust TLAB with instances.
101-
for (int i = 0; i < DEFAULT_ALIGNED_HEAP_CHUNK_SIZE; i++) {
106+
for (int i = 0; i < alignedHeapChunkSize; i++) {
102107
allocateInstance();
103108
}
104109
}

0 commit comments

Comments
 (0)