Skip to content

Commit

Permalink
[GR-52940] Fix values reported in JFR event GCHeapSummary.
Browse files Browse the repository at this point in the history
PullRequest: graal/17375
  • Loading branch information
christianhaeubl committed Mar 27, 2024
2 parents f6c7945 + 83b936a commit 5e43646
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ private static void emit0(UnsignedWord gcEpoch, long start, UnsignedWord committ
JfrNativeEventWriter.putLong(data, gcWhen.getId());

// VirtualSpace
JfrNativeEventWriter.putLong(data, 0L); // start
JfrNativeEventWriter.putLong(data, 0L); // committedEnd
JfrNativeEventWriter.putLong(data, -1); // start
JfrNativeEventWriter.putLong(data, -1); // committedEnd
JfrNativeEventWriter.putLong(data, committedSize.rawValue());
JfrNativeEventWriter.putLong(data, 0L); // reservedEnd
JfrNativeEventWriter.putLong(data, 0L); // reservedSize
JfrNativeEventWriter.putLong(data, -1); // reservedEnd
// Reserved heap size matches committed size
JfrNativeEventWriter.putLong(data, committedSize.rawValue()); // reservedSize

JfrNativeEventWriter.putLong(data, heapUsed.rawValue());
JfrNativeEventWriter.endSmallEvent(data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

package com.oracle.svm.test.jfr;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.util.List;
Expand All @@ -35,6 +36,7 @@

import jdk.jfr.Recording;
import jdk.jfr.consumer.RecordedEvent;
import jdk.jfr.consumer.RecordedObject;

public class TestGCHeapSummaryEvent extends JfrRecordingTest {
@Test
Expand All @@ -49,5 +51,18 @@ public void test() throws Throwable {

private static void validateEvents(List<RecordedEvent> events) {
assertTrue(events.size() > 0);
for (RecordedEvent event : events) {
RecordedObject heapSpace = event.getValue("heapSpace");
assertEquals(-1, heapSpace.getLong("start"));
assertEquals(-1, heapSpace.getLong("committedEnd"));
assertEquals(-1, heapSpace.getLong("reservedEnd"));

long committedSize = heapSpace.getLong("committedSize");
assertTrue(committedSize > 0);
assertTrue(heapSpace.getLong("reservedSize") >= committedSize);
assertTrue(event.getLong("gcId") >= 0);
assertTrue(event.getString("when").equals("Before GC") || event.getString("when").equals("After GC"));
assertTrue(event.getLong("heapUsed") > 0);
}
}
}

0 comments on commit 5e43646

Please sign in to comment.