Skip to content

Commit

Permalink
8290839: jdk/jfr/event/compiler/TestJitRestart.java failed with "Runt…
Browse files Browse the repository at this point in the history
…imeException: No JIT restart event found: expected true, was false"

Reviewed-by: egahlin, lucy
  • Loading branch information
MBaesken committed Jul 28, 2022
1 parent 97fc8de commit 5d1ad39
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions test/jdk/jdk/jfr/event/compiler/TestJitRestart.java
Expand Up @@ -24,6 +24,7 @@
package jdk.jfr.event.compiler;

import java.util.List;
import java.util.Comparator;

import jdk.jfr.Recording;
import jdk.jfr.consumer.RecordedEvent;
Expand All @@ -50,22 +51,23 @@
public class TestJitRestart {

public static void main(String[] args) throws Exception {
boolean foundJitRestart = false;
boolean checkJitRestartCompilation = false;
for (BlobType btype : BlobType.getAvailable()) {
boolean jr = testWithBlobType(btype, calculateAvailableSize(btype));
if (jr) {
System.out.println("JIT restart event found for BlobType " + btype);
foundJitRestart = true;
System.out.println("JIT restart event / Compilation event check for BlobType " + btype + " was successful");
checkJitRestartCompilation = true;
}
}
Asserts.assertTrue(foundJitRestart, "No JIT restart event found");
Asserts.assertTrue(checkJitRestartCompilation, "No JIT restart event found and unexpected compilation seen");
}

private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();

private static boolean testWithBlobType(BlobType btype, long availableSize) throws Exception {
Recording r = new Recording();
r.enable(EventNames.CodeCacheFull);
r.enable(EventNames.Compilation);
r.enable(EventNames.JitRestart);
r.start();
long addr = WHITE_BOX.allocateCodeBlob(availableSize, btype.id);
Expand All @@ -74,18 +76,34 @@ private static boolean testWithBlobType(BlobType btype, long availableSize) thro
r.stop();

List<RecordedEvent> events = Events.fromRecording(r);
System.out.println("---------------------------------------------");
System.out.println("# events:" + events.size());
Events.hasEvents(events);
events.sort(Comparator.comparing(RecordedEvent::getStartTime));

boolean compilationCanHappen = true;
for (RecordedEvent evt: events) {
System.out.println(evt);
if (evt.getEventType().getName().equals("jdk.CodeCacheFull")) {
System.out.println("--> jdk.CodeCacheFull found");
compilationCanHappen = false;
}
if (evt.getEventType().getName().equals("jdk.Compilation") && !compilationCanHappen) {
return false;
}
if (evt.getEventType().getName().equals("jdk.JitRestart")) {
System.out.println("--> jdk.JitRestart found");
Events.assertField(evt, "codeCacheMaxCapacity").notEqual(0L);
Events.assertField(evt, "freedMemory").notEqual(0L);
System.out.println("JIT restart event found for BlobType " + btype);
return true;
}
}
return false;
System.out.println("---------------------------------------------");

// in some seldom cases we do not see the JitRestart event; but then
// do not fail (as long as no compilation happened before)
return true;
}

// Compute the available size for this BlobType by taking into account
Expand Down

5 comments on commit 5d1ad39

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@MBaesken
Copy link
Member 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 5d1ad39 Nov 16, 2022

Choose a reason for hiding this comment

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

@MBaesken the backport was successfully created on the branch MBaesken-backport-5d1ad396 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 5d1ad396 from the openjdk/jdk repository.

The commit being backported was authored by Matthias Baesken on 28 Jul 2022 and was reviewed by Erik Gahlin and Lutz Schmidt.

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 MBaesken-backport-5d1ad396:MBaesken-backport-5d1ad396
$ git checkout MBaesken-backport-5d1ad396
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev MBaesken-backport-5d1ad396

@MBaesken
Copy link
Member 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 5d1ad39 Nov 18, 2022

Choose a reason for hiding this comment

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

@MBaesken the backport was successfully created on the branch MBaesken-backport-5d1ad396 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 5d1ad396 from the openjdk/jdk repository.

The commit being backported was authored by Matthias Baesken on 28 Jul 2022 and was reviewed by Erik Gahlin and Lutz Schmidt.

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 MBaesken-backport-5d1ad396:MBaesken-backport-5d1ad396
$ git checkout MBaesken-backport-5d1ad396
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev MBaesken-backport-5d1ad396

Please sign in to comment.