Skip to content

Commit fec12e8

Browse files
committedNov 28, 2024·
Assertion fix. test fix
1 parent 511d339 commit fec12e8

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed
 

‎substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/oldobject/JfrOldObjectSampler.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,12 @@ private void remove(JfrOldObject sample) {
120120
next.increaseSpan(sample.getSpan());
121121
queue.add(next);
122122
} else {
123-
/* No remaining elements, we can't redistribute the weight. */
123+
/*
124+
* No younger element, we can't redistribute the weight. The next sample should absorb
125+
* the extra span.
126+
*/
124127
totalInQueue = totalInQueue.subtract(sample.getSpan());
125-
assert totalInQueue.equal(0);
128+
assert totalInQueue.aboveOrEqual(0);
126129
}
127130
queue.remove(sample);
128131
release(sample);

‎substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/oldobject/TestOldObjectProfiler.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@
3333
import java.util.Collections;
3434
import java.util.List;
3535

36+
import jdk.jfr.Recording;
3637
import org.graalvm.word.WordFactory;
3738
import org.junit.Assert;
39+
import org.junit.BeforeClass;
3840
import org.junit.Test;
3941

4042
import com.oracle.svm.core.jfr.HasJfrSupport;
@@ -45,6 +47,14 @@
4547
import jdk.graal.compiler.api.directives.GraalDirectives;
4648

4749
public class TestOldObjectProfiler extends AbstractJfrTest {
50+
51+
/* Old object samples will not have allocation ticks set correctly if JfrTicks is not first initialized.
52+
* We need to create the first JFR recording to lazily initialize JfrTicks.*/
53+
@BeforeClass
54+
public static void initializeJfrTicks() {
55+
GraalDirectives.blackhole(new Recording());
56+
}
57+
4858
@Test
4959
public void testScavenge() {
5060
int count = 10;

0 commit comments

Comments
 (0)
Please sign in to comment.