From f6f7307fd30249317fa0161a4edec75ba74dbcbd Mon Sep 17 00:00:00 2001 From: Peter Hofer Date: Thu, 5 Dec 2024 17:02:56 +0100 Subject: [PATCH 1/2] Add change tracking for AdaptiveCollectionPolicy. --- .../svm/core/genscavenge/AdaptiveCollectionPolicy.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AdaptiveCollectionPolicy.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AdaptiveCollectionPolicy.java index ecefb5ddb7a8..d7120625a908 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AdaptiveCollectionPolicy.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AdaptiveCollectionPolicy.java @@ -31,6 +31,7 @@ import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.heap.GCCause; +import com.oracle.svm.core.util.BasedOnJDKFile; import com.oracle.svm.core.util.TimeUtils; import com.oracle.svm.core.util.UnsignedUtils; @@ -42,6 +43,13 @@ * its base class {@code AdaptiveSizePolicy}. Method and variable names have been kept mostly the * same for comparability. */ +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+1/src/hotspot/share/gc/shared/adaptiveSizePolicy.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+1/src/hotspot/share/gc/shared/adaptiveSizePolicy.cpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+1/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+1/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.cpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+1/src/hotspot/share/gc/parallel/psParallelCompact.cpp#L951-L1174") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+1/src/hotspot/share/gc/parallel/psScavenge.cpp#L321-L639") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+1/src/hotspot/share/gc/shared/gc_globals.hpp#L308-L420") class AdaptiveCollectionPolicy extends AbstractCollectionPolicy { /* @@ -152,7 +160,7 @@ public String getName() { } @Override - public boolean shouldCollectCompletely(boolean followingIncrementalCollection) { // should_{attempt_scavenge,full_GC} + public boolean shouldCollectCompletely(boolean followingIncrementalCollection) { // should_attempt_scavenge guaranteeSizeParametersInitialized(); if (!followingIncrementalCollection && shouldCollectYoungGenSeparately(!SerialGCOptions.useCompactingOldGen())) { From 305e44d885a7cc82ea8de291ab98de822976d8b2 Mon Sep 17 00:00:00 2001 From: Peter Hofer Date: Thu, 5 Dec 2024 18:17:34 +0100 Subject: [PATCH 2/2] Adopt JDK-8319713: avoid conservative full GC after successful young GC. --- .../core/genscavenge/AdaptiveCollectionPolicy.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AdaptiveCollectionPolicy.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AdaptiveCollectionPolicy.java index d7120625a908..a77ec5fb0ace 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AdaptiveCollectionPolicy.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AdaptiveCollectionPolicy.java @@ -190,17 +190,7 @@ public boolean shouldCollectCompletely(boolean followingIncrementalCollection) { return true; } - UnsignedWord youngUsed = HeapImpl.getHeapImpl().getYoungGeneration().getChunkBytes(); - UnsignedWord oldUsed = HeapImpl.getHeapImpl().getOldGeneration().getChunkBytes(); - - /* - * If the remaining free space in the old generation is less than what is expected to be - * needed by the next collection, do a full collection now. - */ - UnsignedWord averagePromoted = UnsignedUtils.fromDouble(avgPromoted.getPaddedAverage()); - UnsignedWord promotionEstimate = UnsignedUtils.min(averagePromoted, youngUsed); - UnsignedWord oldFree = oldSize.subtract(oldUsed); - return promotionEstimate.aboveThan(oldFree); + return false; } private void updateAverages(boolean isSurvivorOverflow, UnsignedWord survivedChunkBytes, UnsignedWord promotedChunkBytes) {