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

Reviewed-by: mgronlun, stuefe
  • Loading branch information
schmelter-sap committed Jul 12, 2022
1 parent 728157f commit 7f0e9bd
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

5 comments on commit 7f0e9bd

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@schmelter-sap
Copy link
Contributor Author

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 7f0e9bd Jul 4, 2023

Choose a reason for hiding this comment

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

@schmelter-sap the backport was successfully created on the branch schmelter-sap-backport-7f0e9bd6 in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 7f0e9bd6 from the openjdk/jdk repository.

The commit being backported was authored by Ralf Schmelter on 12 Jul 2022 and was reviewed by Markus Grönlund and Thomas Stuefe.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev.git schmelter-sap-backport-7f0e9bd6:schmelter-sap-backport-7f0e9bd6
$ git checkout schmelter-sap-backport-7f0e9bd6
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev.git schmelter-sap-backport-7f0e9bd6

@schmelter-sap
Copy link
Contributor Author

Choose a reason for hiding this comment

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

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 7f0e9bd Oct 20, 2023

Choose a reason for hiding this comment

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

@schmelter-sap Could not automatically backport 7f0e9bd6 to openjdk/jdk11u-dev due to conflicts in the following files:

  • src/hotspot/share/gc/g1/g1Trace.cpp
  • test/jdk/jdk/jfr/event/gc/detailed/TestEvacuationFailedEvent.java

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk11u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk11u-dev.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b schmelter-sap-backport-7f0e9bd6

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git 7f0e9bd632198c7fd34d27b85ca51ea0e2442e4d

# Backport the commit
$ git cherry-pick --no-commit 7f0e9bd632198c7fd34d27b85ca51ea0e2442e4d
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 7f0e9bd632198c7fd34d27b85ca51ea0e2442e4d'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk11u-dev with the title Backport 7f0e9bd632198c7fd34d27b85ca51ea0e2442e4d.

Please sign in to comment.