Skip to content

Commit 9a86031

Browse files
committed
[GR-64575] [GR-64819] Documentation updates.
1 parent e6238d1 commit 9a86031

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed

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

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import com.oracle.svm.core.os.CommittedMemoryProvider;
3737
import com.oracle.svm.core.thread.JavaSpinLockUtils;
3838
import com.oracle.svm.core.thread.VMOperation;
39+
import com.oracle.svm.core.util.BasedOnJDKFile;
3940
import com.oracle.svm.core.util.UnsignedUtils;
4041
import com.oracle.svm.core.util.VMError;
4142

@@ -49,7 +50,9 @@
4950
*/
5051
abstract class AbstractCollectionPolicy implements CollectionPolicy {
5152

52-
protected static final int MIN_SPACE_SIZE_IN_ALIGNED_CHUNKS = 8;
53+
protected static final int MIN_SPACE_SIZE_AS_NUMBER_OF_ALIGNED_CHUNKS = 8;
54+
55+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+20/src/hotspot/share/gc/shared/gc_globals.hpp#L572-L575") //
5356
protected static final int MAX_TENURING_THRESHOLD = 15;
5457

5558
@Platforms(Platform.HOSTED_ONLY.class)
@@ -68,15 +71,19 @@ static int getMaxSurvivorSpaces(Integer userValue) {
6871
* Don't change these values individually without carefully going over their occurrences in
6972
* HotSpot source code, there are dependencies between them that are not handled in our code.
7073
*/
74+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+20/src/hotspot/share/gc/shared/gc_globals.hpp#L413-L415") //
7175
protected static final int INITIAL_SURVIVOR_RATIO = 8;
76+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+20/src/hotspot/share/gc/shared/gc_globals.hpp#L409-L411") //
7277
protected static final int MIN_SURVIVOR_RATIO = 3;
73-
protected static final int DEFAULT_TIME_WEIGHT = 25; // -XX:AdaptiveTimeWeight
78+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+20/src/hotspot/share/gc/shared/gc_globals.hpp#L340-L342") //
79+
protected static final int ADAPTIVE_TIME_WEIGHT = 25;
7480

7581
/* Constants to compute defaults for values which can be set through existing options. */
7682
protected static final UnsignedWord INITIAL_HEAP_SIZE = Word.unsigned(128 * 1024 * 1024);
77-
protected static final int NEW_RATIO = 2; // HotSpot: -XX:NewRatio
83+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+20/src/hotspot/share/gc/shared/gc_globals.hpp#L554-L556") //
84+
protected static final int NEW_RATIO = 2;
7885

79-
protected final AdaptiveWeightedAverage avgYoungGenAlignedChunkFraction = new AdaptiveWeightedAverage(DEFAULT_TIME_WEIGHT);
86+
protected final AdaptiveWeightedAverage avgYoungGenAlignedChunkFraction = new AdaptiveWeightedAverage(ADAPTIVE_TIME_WEIGHT);
8087

8188
private final int initialNewRatio;
8289
protected UnsignedWord survivorSize;
@@ -130,7 +137,7 @@ static boolean isAligned(UnsignedWord size) {
130137

131138
@Fold
132139
static UnsignedWord minSpaceSize() {
133-
return getAlignment().multiply(MIN_SPACE_SIZE_IN_ALIGNED_CHUNKS);
140+
return HeapParameters.getAlignedHeapChunkSize().multiply(MIN_SPACE_SIZE_AS_NUMBER_OF_ALIGNED_CHUNKS);
134141
}
135142

136143
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
@@ -221,6 +228,7 @@ public final UnsignedWord getInitialEdenSize() {
221228

222229
@Override
223230
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
231+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+21/src/hotspot/share/gc/parallel/psYoungGen.cpp#L104-L116")
224232
public final UnsignedWord getMaximumEdenSize() {
225233
guaranteeSizeParametersInitialized();
226234
return alignDown(sizes.maxYoungSize.subtract(survivorSize.multiply(2)));
@@ -295,9 +303,8 @@ public UnsignedWord getMaximumFreeAlignedChunksSize() {
295303
assert VMOperation.isGCInProgress() : "use only during GC";
296304
guaranteeSizeParametersInitialized();
297305
/*
298-
* Keep chunks ready for allocations in eden and for the survivor to-spaces during young
299-
* collections (although we might keep too many aligned chunks when large objects in
300-
* unaligned chunks are also allocated). We could alternatively return
306+
* Keep chunks ready for allocations in eden as well as for copying the objects currently in
307+
* survivor spaces in a future collection. We could alternatively return
301308
* getCurrentHeapCapacity() to have chunks ready during full GCs as well.
302309
*/
303310
UnsignedWord total = edenSize.add(HeapImpl.getAccounting().getSurvivorUsedBytes());
@@ -331,6 +338,8 @@ public final UnsignedWord getMinimumHeapSize() {
331338
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
332339
protected abstract long gcCount();
333340

341+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+21/src/hotspot/share/gc/shared/genArguments.cpp#L195-L310")
342+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+21/src/hotspot/share/gc/parallel/psYoungGen.cpp#L146-L168")
334343
protected SizeParameters computeSizeParameters(SizeParameters existing) {
335344
UnsignedWord minYoungSpaces = minSpaceSize(); // eden
336345
if (HeapParameters.getMaxSurvivorSpaces() > 0) {
@@ -386,9 +395,10 @@ protected SizeParameters computeSizeParameters(SizeParameters existing) {
386395
/*
387396
* In HotSpot, this is the reserved capacity of each of the survivor From and To spaces,
388397
* i.e., together they occupy 2x this size. Our chunked heap doesn't reserve memory, so
389-
* we never occupy more than 1x this size for survivors except during collections.
390-
* However, this is inconsistent with how we interpret the maximum size of the old
391-
* generation, which we can exceed while copying during collections.
398+
* we never occupy more than 1x this size for survivors except during collections. We
399+
* reserve 2x regardless (see below). However, this is inconsistent with how we
400+
* interpret the maximum size of the old generation, which we can exceed the same way
401+
* while copying during collections, but reserve only 1x its size.
392402
*/
393403
initialSurvivor = initialYoung.unsignedDivide(AbstractCollectionPolicy.INITIAL_SURVIVOR_RATIO);
394404
initialSurvivor = minSpaceSize(alignDown(initialSurvivor));
@@ -448,6 +458,7 @@ private SizeParameters(UnsignedWord maxHeapSize, UnsignedWord maxYoungSize, Unsi
448458
}
449459

450460
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
461+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+21/src/hotspot/share/gc/parallel/psYoungGen.cpp#L104-L116")
451462
UnsignedWord maxSurvivorSize() {
452463
if (HeapParameters.getMaxSurvivorSpaces() == 0) {
453464
return Word.zero();

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+20/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.cpp")
5252
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+12/src/hotspot/share/gc/parallel/psParallelCompact.cpp#L963-L1180")
5353
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/share/gc/parallel/psScavenge.cpp#L321-L637")
54-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+20/src/hotspot/share/gc/shared/gc_globals.hpp#L303-L415")
54+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+20/src/hotspot/share/gc/shared/gc_globals.hpp#L303-L407")
5555
class AdaptiveCollectionPolicy extends AbstractCollectionPolicy {
5656

5757
/*
@@ -61,7 +61,6 @@ class AdaptiveCollectionPolicy extends AbstractCollectionPolicy {
6161
* Don't change these values individually without carefully going over their occurrences in
6262
* HotSpot source code, there are dependencies between them that are not handled in our code.
6363
*/
64-
private static final int ADAPTIVE_TIME_WEIGHT = DEFAULT_TIME_WEIGHT;
6564
private static final int ADAPTIVE_SIZE_POLICY_READY_THRESHOLD = 5;
6665
private static final int ADAPTIVE_SIZE_DECREMENT_SCALE_FACTOR = 4;
6766
private static final int ADAPTIVE_SIZE_POLICY_WEIGHT = 10;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ static boolean shouldCollectYoungGenSeparately(boolean defaultValue) {
192192
UnsignedWord getMaximumOldSize();
193193

194194
/**
195-
* The maximum number of bytes that should be kept readily available for allocation or copying
196-
* during collections.
195+
* The maximum number of bytes that should be kept readily available for allocations after a
196+
* collection. This may consider memory needed during a future collection as well.
197197
*/
198198
UnsignedWord getMaximumFreeAlignedChunksSize();
199199

0 commit comments

Comments
 (0)