Skip to content

Commit

Permalink
[GR-60176] JFR Old Object Sampler fixes.
Browse files Browse the repository at this point in the history
PullRequest: graal/19488
  • Loading branch information
christianhaeubl committed Dec 2, 2024
2 parents 3f6c059 + 841fd9d commit 83e6cf0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -45,6 +47,16 @@
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;
Expand Down

0 comments on commit 83e6cf0

Please sign in to comment.