Skip to content

Commit 83e6cf0

Browse files
[GR-60176] JFR Old Object Sampler fixes.
PullRequest: graal/19488
2 parents 3f6c059 + 841fd9d commit 83e6cf0

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

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

+5-2
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

+12
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,16 @@
4547
import jdk.graal.compiler.api.directives.GraalDirectives;
4648

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

0 commit comments

Comments
 (0)