Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[GR-60176] JFR Old Object Sampler fixes #10190

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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