Skip to content

Commit

Permalink
8289745: JfrStructCopyFailed uses heap words instead of bytes for obj…
Browse files Browse the repository at this point in the history
…ect sizes

Backport-of: 7f0e9bd632198c7fd34d27b85ca51ea0e2442e4d
  • Loading branch information
schmelter-sap committed Sep 28, 2023
1 parent 4ecf818 commit 0ce7d86
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/hotspot/share/gc/g1/g1Trace.cpp
Expand Up @@ -163,9 +163,9 @@ void G1NewTracer::send_evacuation_failed_event(const EvacuationFailedInfo& ef_in
// Create JFR structured failure data
JfrStructCopyFailed evac_failed;
evac_failed.set_objectCount(ef_info.failed_count());
evac_failed.set_firstSize(ef_info.first_size());
evac_failed.set_smallestSize(ef_info.smallest_size());
evac_failed.set_totalSize(ef_info.total_size());
evac_failed.set_firstSize(ef_info.first_size() * HeapWordSize);
evac_failed.set_smallestSize(ef_info.smallest_size() * HeapWordSize);
evac_failed.set_totalSize(ef_info.total_size() * HeapWordSize);
// Add to the event
e.set_gcId(GCId::current());
e.set_evacuationFailed(evac_failed);
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/gc/shared/gcTraceSend.cpp
Expand Up @@ -157,9 +157,9 @@ void OldGCTracer::send_old_gc_event() const {
static JfrStructCopyFailed to_struct(const CopyFailedInfo& cf_info) {
JfrStructCopyFailed failed_info;
failed_info.set_objectCount(cf_info.failed_count());
failed_info.set_firstSize(cf_info.first_size());
failed_info.set_smallestSize(cf_info.smallest_size());
failed_info.set_totalSize(cf_info.total_size());
failed_info.set_firstSize(cf_info.first_size() * HeapWordSize);
failed_info.set_smallestSize(cf_info.smallest_size() * HeapWordSize);
failed_info.set_totalSize(cf_info.total_size() * HeapWordSize);
return failed_info;
}

Expand Down
4 changes: 4 additions & 0 deletions test/jdk/jdk/jfr/event/gc/detailed/PromotionFailedEvent.java
Expand Up @@ -49,12 +49,16 @@ public static void test(String testName, String[] vmFlags) throws Throwable {
// This test can not always trigger the expected event.
// Test is ok even if no events found.
List<RecordedEvent> events = RecordingFile.readAllEvents(Paths.get(jfr_file));
int minObjectAlignment = 8;
for (RecordedEvent event : events) {
System.out.println("Event: " + event);
long smallestSize = Events.assertField(event, "promotionFailed.smallestSize").atLeast(1L).getValue();
Asserts.assertTrue((smallestSize % minObjectAlignment) == 0, "smallestSize " + smallestSize + " is not a valid size.");
long firstSize = Events.assertField(event, "promotionFailed.firstSize").atLeast(smallestSize).getValue();
Asserts.assertTrue((firstSize % minObjectAlignment) == 0, "firstSize " + firstSize + " is not a valid size.");
long totalSize = Events.assertField(event, "promotionFailed.totalSize").atLeast(firstSize).getValue();
long objectCount = Events.assertField(event, "promotionFailed.objectCount").atLeast(1L).getValue();
Asserts.assertTrue((totalSize % minObjectAlignment) == 0, "totalSize " + totalSize + " is not a valid size.");
Asserts.assertLessThanOrEqual(smallestSize * objectCount, totalSize, "smallestSize * objectCount <= totalSize");
}
}
Expand Down
Expand Up @@ -76,13 +76,17 @@ public static void main(String[] args) throws Exception {

// Verify recording
List<RecordedEvent> events = Events.fromRecording(recording);
int minObjectAlignment = 8;

Events.hasEvents(events);
for (RecordedEvent event : events) {
long objectCount = Events.assertField(event, "evacuationFailed.objectCount").atLeast(1L).getValue();
long smallestSize = Events.assertField(event, "evacuationFailed.smallestSize").atLeast(1L).getValue();
Asserts.assertTrue((smallestSize % minObjectAlignment) == 0, "smallestSize " + smallestSize + " is not a valid size.");
long firstSize = Events.assertField(event, "evacuationFailed.firstSize").atLeast(smallestSize).getValue();
Asserts.assertTrue((firstSize % minObjectAlignment) == 0, "firstSize " + firstSize + " is not a valid size.");
long totalSize = Events.assertField(event, "evacuationFailed.totalSize").atLeast(firstSize).getValue();
Asserts.assertTrue((totalSize % minObjectAlignment) == 0, "totalSize " + totalSize + " is not a valid size.");
Asserts.assertLessThanOrEqual(smallestSize * objectCount, totalSize, "smallestSize * objectCount <= totalSize");
}
recording.close();
Expand Down

1 comment on commit 0ce7d86

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.