From fec12e8a4a6eaef8b16bf886e30865b9db85dcec Mon Sep 17 00:00:00 2001 From: Robert Toyonaga Date: Thu, 28 Nov 2024 14:49:48 -0500 Subject: [PATCH 1/2] Assertion fix. test fix --- .../svm/core/jfr/oldobject/JfrOldObjectSampler.java | 7 +++++-- .../svm/test/jfr/oldobject/TestOldObjectProfiler.java | 10 ++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/oldobject/JfrOldObjectSampler.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/oldobject/JfrOldObjectSampler.java index 36a7b0254645..19258c9da4a3 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/oldobject/JfrOldObjectSampler.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/oldobject/JfrOldObjectSampler.java @@ -120,9 +120,12 @@ private void remove(JfrOldObject sample) { next.increaseSpan(sample.getSpan()); queue.add(next); } else { - /* No remaining elements, we can't redistribute the weight. */ + /* + * No younger element, we can't redistribute the weight. The next sample should absorb + * the extra span. + */ totalInQueue = totalInQueue.subtract(sample.getSpan()); - assert totalInQueue.equal(0); + assert totalInQueue.aboveOrEqual(0); } queue.remove(sample); release(sample); diff --git a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/oldobject/TestOldObjectProfiler.java b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/oldobject/TestOldObjectProfiler.java index 5a1096bebd53..9beed3cf0850 100644 --- a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/oldobject/TestOldObjectProfiler.java +++ b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/oldobject/TestOldObjectProfiler.java @@ -33,8 +33,10 @@ import java.util.Collections; import java.util.List; +import jdk.jfr.Recording; import org.graalvm.word.WordFactory; import org.junit.Assert; +import org.junit.BeforeClass; import org.junit.Test; import com.oracle.svm.core.jfr.HasJfrSupport; @@ -45,6 +47,14 @@ import jdk.graal.compiler.api.directives.GraalDirectives; public class TestOldObjectProfiler extends AbstractJfrTest { + + /* Old object samples will not have allocation ticks set correctly if JfrTicks is not first initialized. + * We need to create the first JFR recording to lazily initialize JfrTicks.*/ + @BeforeClass + public static void initializeJfrTicks() { + GraalDirectives.blackhole(new Recording()); + } + @Test public void testScavenge() { int count = 10; From 841fd9da442784e81f7af84b8e7e070203c6e8ce Mon Sep 17 00:00:00 2001 From: Robert Toyonaga Date: Thu, 28 Nov 2024 15:34:37 -0500 Subject: [PATCH 2/2] style --- .../svm/test/jfr/oldobject/TestOldObjectProfiler.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/oldobject/TestOldObjectProfiler.java b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/oldobject/TestOldObjectProfiler.java index 9beed3cf0850..9886db719b49 100644 --- a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/oldobject/TestOldObjectProfiler.java +++ b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/oldobject/TestOldObjectProfiler.java @@ -48,8 +48,10 @@ public class TestOldObjectProfiler extends AbstractJfrTest { - /* Old object samples will not have allocation ticks set correctly if JfrTicks is not first initialized. - * We need to create the first JFR recording to lazily initialize JfrTicks.*/ + /* + * Old object samples will not have allocation ticks set correctly if JfrTicks is not first + * initialized. We need to create the first JFR recording to lazily initialize JfrTicks. + */ @BeforeClass public static void initializeJfrTicks() { GraalDirectives.blackhole(new Recording());