Skip to content

Conversation

jiekang
Copy link
Collaborator

@jiekang jiekang commented Aug 26, 2021

Closes #3538

@jiekang
Copy link
Collaborator Author

jiekang commented Aug 26, 2021

@christianhaeubl Hi Christian! I started this PR with the intent to let the changes be reviewed sooner rather than later. There is still some work to do for closing chunks properly in 17, but otherwise it compiles and runs without error.

@jiekang jiekang changed the title Update JFR Native Image Support for compatibility with JDK 17 [WIP] Update JFR Native Image Support for compatibility with JDK 17 Aug 26, 2021
@graalvmbot
Copy link
Collaborator

Hello Zhengyu Gu, thanks for contributing a PR to our project!

We use the Oracle Contributor Agreement to make the copyright of contributions clear. We don't have a record of you having signed this yet, based on your email address zgu -(at)- redhat -(dot)- com. You can sign it at that link.

If you think you've already signed it, please comment below and we'll check.

@graalvmbot
Copy link
Collaborator

Zhengyu Gu has signed the Oracle Contributor Agreement (based on email address zgu -(at)- redhat -(dot)- com) so can contribute to this repository.

@jiekang
Copy link
Collaborator Author

jiekang commented Aug 26, 2021

Just noting in a comment here: the current issue is that the jdk.jfr.internal.ShutdownHook to support dumponexit is not running in the image for 17, but is for 11. It's not touched directly by us though, so continuing to investigate.

@jiekang
Copy link
Collaborator Author

jiekang commented Aug 26, 2021

Just noting in a comment here: the current issue is that the jdk.jfr.internal.ShutdownHook to support dumponexit is not running in the image for 17, but is for 11. It's not touched directly by us though, so continuing to investigate.

Issue described here is resolved now.

@jiekang
Copy link
Collaborator Author

jiekang commented Aug 27, 2021

Note this still needs H:+PlatformInterfaceCompatibilityMode to compile. Not yet sure how to resolve that.

@jiekang jiekang requested a review from teshull September 1, 2021 14:17
@jiekang jiekang changed the title [WIP] Update JFR Native Image Support for compatibility with JDK 17 Update JFR Native Image Support for compatibility with JDK 17 Sep 1, 2021
Copy link
Member

@christianhaeubl christianhaeubl left a comment

Choose a reason for hiding this comment

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

Thanks for working on the JFR support for JDK17. I added a few comments, suggestions, and questions.

@@ -107,15 +121,175 @@ private static void initRecording() {
Boolean dumpOnExit = parseBoolean(args, JfrStartArgument.DumpOnExit);
Boolean pathToGcRoots = parseBoolean(args, JfrStartArgument.PathToGCRoots);

Target_jdk_jfr_internal_dcmd_DCmdStart dcmdStart = new Target_jdk_jfr_internal_dcmd_DCmdStart();
Copy link
Member

Choose a reason for hiding this comment

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

What is the reason for copying the DCmdStart implementation here? Copying code like that typically creates major issues in the long run.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

DCmdStart and surrounding functionality was heavily modified in OpenJDK here: openjdk/jdk@f716711#diff-437f27c74f0b6eb69196ae8b8a27d398a188da4809c6c755ec8eae771e3f4b94R64

I don't know how to support both method signatures of DcmdStart.execute from 11 and 17 so I decided to follow the execution manually instead.

Specifically

public String[] execute(String name, String[] settings, Long delay, Long duration, Boolean disk, String path, Long maxAge, Long maxSize, Long flush, Boolean dumpOnExit, Boolean pathToGcRoots) throws DCmdException {

to

@Override
public void execute(ArgumentParser parser) throws DCmdException {

I can revisit this.

Copy link
Member

Choose a reason for hiding this comment

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

If you see any chance of simplifying that, please open a new PR. This PR was merged to master in the meanwhile.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@christianhaeubl Okay. I will create a new issue specifically for DcmdStart support and look at that. Thanks for reviewing and merging this.

I have an attempt similar to HiddenClassSupport but the changes are quite substantial to support the two quite different APIs :|

@christianhaeubl
Copy link
Member

@jiekang: what is the error message that you get without -H:+PlatformInterfaceCompatibilityMode?

@jiekang
Copy link
Collaborator Author

jiekang commented Sep 6, 2021

@jiekang: what is the error message that you get without -H:+PlatformInterfaceCompatibilityMode?

@christianhaeubl

[com.redhat.jfr.tests.event.testconcurrenteventsclean:83210]    classlist:   3,804.60 ms,  0.96 GB
[com.redhat.jfr.tests.event.testconcurrenteventsclean:83210]        (cap):     742.61 ms,  0.96 GB
[com.redhat.jfr.tests.event.testconcurrenteventsclean:83210]        setup:   3,868.15 ms,  0.96 GB
[com.redhat.jfr.tests.event.testconcurrenteventsclean:83210]     (clinit):     462.59 ms,  2.38 GB
[com.redhat.jfr.tests.event.testconcurrenteventsclean:83210]   (typeflow):   5,848.35 ms,  2.38 GB
[com.redhat.jfr.tests.event.testconcurrenteventsclean:83210]    (objects):  40,922.54 ms,  2.38 GB
[com.redhat.jfr.tests.event.testconcurrenteventsclean:83210]   (features):   1,174.98 ms,  2.38 GB
[com.redhat.jfr.tests.event.testconcurrenteventsclean:83210]     analysis:  49,469.98 ms,  2.38 GB
Error: The interface org.graalvm.nativeimage.hosted.Feature is not available in the current platform, but used by com.oracle.svm.jfr.JfrFeature. GraalVM before version 21.2 ignored such interfaces, but this was an oversight. The old behavior can be temporarily restored using the option -H:+PlatformInterfaceCompatibilityMode. This option will be removed in a future GraalVM version.
Detailed message:
Trace: Object was reached by 
	reading field java.lang.Class.nestHost of
		constant java.lang.Class@f973499 reached by 
	Hub

com.oracle.svm.core.util.UserError$UserException: The interface org.graalvm.nativeimage.hosted.Feature is not available in the current platform, but used by com.oracle.svm.jfr.JfrFeature. GraalVM before version 21.2 ignored such interfaces, but this was an oversight. The old behavior can be temporarily restored using the option -H:+PlatformInterfaceCompatibilityMode. This option will be removed in a future GraalVM version.
Detailed message:
Trace: Object was reached by 
	reading field java.lang.Class.nestHost of
		constant java.lang.Class@f973499 reached by 
	Hub

	at com.oracle.svm.core.util.UserError.abort(UserError.java:87)
	at com.oracle.svm.hosted.FallbackFeature.reportAsFallback(FallbackFeature.java:233)
	at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:764)
	at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:534)
	at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:493)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:400)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:566)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:122)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:596)
Caused by: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: The interface org.graalvm.nativeimage.hosted.Feature is not available in the current platform, but used by com.oracle.svm.jfr.JfrFeature. GraalVM before version 21.2 ignored such interfaces, but this was an oversight. The old behavior can be temporarily restored using the option -H:+PlatformInterfaceCompatibilityMode. This option will be removed in a future GraalVM version.
Detailed message:
Trace: Object was reached by 
	reading field java.lang.Class.nestHost of
		constant java.lang.Class@f973499 reached by 
	Hub

	at com.oracle.graal.pointsto.constraints.UnsupportedFeatures.report(UnsupportedFeatures.java:126)
	at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:761)
	... 6 more
[com.redhat.jfr.tests.event.testconcurrenteventsclean:83210]      [total]:  57,542.99 ms,  2.38 GB

@christianhaeubl
Copy link
Member

@jiekan: thanks for the error message, I will try to debug that tomorrow.

@christianhaeubl
Copy link
Member

@jiekang: regarding the issue that -H:+PlatformInterfaceCompatibilityMode is needed: the JFRFeature is reachable at runtime because of lambdas that are used in JFRFeature (this happens because of existing code and is not caused by any code that you introduced in your PR). I implemented a fix.

Let me know if I should push the fix to your branch.

@jiekang
Copy link
Collaborator Author

jiekang commented Sep 7, 2021

@jiekang: regarding the issue that -H:+PlatformInterfaceCompatibilityMode is needed: the JFRFeature is reachable at runtime because of lambdas that are used in JFRFeature (this happens because of existing code and is not caused by any code that you introduced in your PR). I implemented a fix.

Let me know if I should push the fix to your branch.

@christianhaeubl Please feel free to push the fix to this branch. I also do not mind having it merged in a separate PR and I can rebase this one easily enough. Whichever is ideal for you works for me. Thank you for investigating and fixing this.

@christianhaeubl
Copy link
Member

@jiekang : I pushed my fix to your branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update JFR Native Image Support for compatibility with JDK 17
4 participants