From f0a6a9c57a81292bc66f5998d8249c90a55727da Mon Sep 17 00:00:00 2001 From: Robert Toyonaga Date: Mon, 25 Mar 2024 16:43:34 -0400 Subject: [PATCH] Add correct values to GCHeapSummary --- .../svm/core/genscavenge/JfrGCHeapSummaryEvent.java | 9 +++++---- .../oracle/svm/test/jfr/TestGCHeapSummaryEvent.java | 12 ++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/JfrGCHeapSummaryEvent.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/JfrGCHeapSummaryEvent.java index 232456a9fc29..76194023be8d 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/JfrGCHeapSummaryEvent.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/JfrGCHeapSummaryEvent.java @@ -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); diff --git a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestGCHeapSummaryEvent.java b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestGCHeapSummaryEvent.java index b0f457a73446..95ba749f82e2 100644 --- a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestGCHeapSummaryEvent.java +++ b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestGCHeapSummaryEvent.java @@ -29,6 +29,7 @@ import java.util.List; +import jdk.jfr.consumer.RecordedObject; import org.junit.Test; import com.oracle.svm.core.jfr.JfrEvent; @@ -49,5 +50,16 @@ public void test() throws Throwable { private static void validateEvents(List events) { assertTrue(events.size() > 0); + for (RecordedEvent event : events) { + RecordedObject heapSpace = event.getValue("heapSpace"); + assertTrue(heapSpace.getLong("start") == -1); + assertTrue(heapSpace.getLong("committedEnd") == -1); + assertTrue(heapSpace.getLong("reservedEnd") == -1); + assertTrue(heapSpace.getLong("committedSize") > 0); + assertTrue(heapSpace.getLong("reservedSize") >= heapSpace.getLong("committedSize")); + assertTrue(event.getLong("gcId") >= 0); + assertTrue(event.getString("when").equals("Before GC") || event.getString("when").equals("After GC")); + assertTrue(event.getLong("heapUsed") > 0); + } } }