Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7903448: JMH: Override the use of compiler hints using a system property #96

Closed

Conversation

gilles-duboscq
Copy link
Member

@gilles-duboscq gilles-duboscq commented Mar 7, 2023

Using -Djmh.compilerhints.mode=true will force the use of compiler hints. -Djmh.compilerhints.mode=false will prevent the use of compiler hints. When the system property is not set, the current beahviour based on vm name and version will be used by default.

This is especially useful when working with uncommon / rare JVMs or when adding compiler hints support to a new JVM.

I considered auto-detecting support for compiler hints but that didn't fit very well in the current code and required much more intrusive changes.


Progress

  • Change must not contain extraneous whitespace
  • Change must be properly reviewed (1 review required, with at least 1 Committer)

Issue

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jmh.git pull/96/head:pull/96
$ git checkout pull/96

Update a local copy of the PR:
$ git checkout pull/96
$ git pull https://git.openjdk.org/jmh.git pull/96/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 96

View PR using the GUI difftool:
$ git pr show -t 96

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jmh/pull/96.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 7, 2023

👋 Welcome back gdub! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 7, 2023
@mlbridge
Copy link

mlbridge bot commented Mar 7, 2023

Webrevs

@shipilev shipilev changed the title Allow forcing the use of compiler hints using a system property 7903448: JMH: Override the use compiler hints using a system property Mar 23, 2023
@shipilev shipilev changed the title 7903448: JMH: Override the use compiler hints using a system property 7903448: JMH: Override the use of compiler hints using a system property Mar 23, 2023
Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

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

Okay, I understand the use case. But I also think that accepting a boolean as jmh.compilerhints.mode is ambiguous, especially if we ask questions about defaults :) It would be cleaner to do it like we do it for Blackholes:

public enum CompilerHintsMode {
   FORCE_ON("Forced on"),
   FORCE_OFF("Forced off"),
   AUTO("Automatically selected"),
}

Then parse that enum off the jmh.compilerhints.mode, default to AUTO.

@gilles-duboscq
Copy link
Member Author

Good idea. I'll do

@shipilev
Copy link
Member

Also, go to https://github.com/gilles-duboscq/jmh/actions and press a large green button to enable PR testing.

Using `-Djmh.compilerhints.mode=FORCE_ON` will force the use of compiler
hints. `-Djmh.compilerhints.mode=FORCE_OFF` will prevent the use of compiler
hints. When the system property is not set, or when it is set to `AUTO`,
the current beahviour based on vm name and version will be used.
@openjdk
Copy link

openjdk bot commented Mar 23, 2023

@gilles-duboscq Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information.

@gilles-duboscq
Copy link
Member Author

gilles-duboscq commented Mar 23, 2023

I have changed the jmh.compilerhints.mode system property to accept the 3 suggested values and implemented it following the implementation of the blackhole modes.

Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

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

I have more comments, apologies :)

/**
* FIXME (low priority): check if supplied JVM is hint compatible. This test is applied to the Runner VM,
* not the Forked and may therefore be wrong if the forked VM is not the same JVM
*/
private static boolean isHintCompatibleVM() {
private static boolean compilerHintsEnabled() {
if (compilerHintsEnabled != null) {
Copy link
Member

Choose a reason for hiding this comment

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

Where do we set compilerHintsEnabled? I think it needs to be set before every return from this method.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Comment on lines 436 to 437
out.print("# Compiler hints: " + (compilerHintsEnabled() ? "enabled" : "disabled") + " (" + compilerHintsSelect().desc() + ")");
out.println();
Copy link
Member

Choose a reason for hiding this comment

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

Let's print this only if !compilerHintsSelect().isAuto(). The normal use case is having compiler hints transparently enabled. This is quite a bit different from Blackhole that does have a normal variance in settings...

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@shipilev
Copy link
Member

Ping @gilles-duboscq -- do you want to complete this, or want me to take over?

@gilles-duboscq
Copy link
Member Author

Other things have taken over but i was still planning to get back to this within the next 1-2 weeks. If somebody else needs that faster, feel free to take over.
Thanks for the review feedback.

@shipilev
Copy link
Member

Other things have taken over but i was still planning to get back to this within the next 1-2 weeks. If somebody else needs that faster, feel free to take over. Thanks for the review feedback.

That's fine, there is no time pressure to complete this work. Looking forward to new version in a few weeks. I plan to have the next JMH release some time in May.

Only print compiler hints status when it is forced
Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

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

This version looks good!

There are some flukes in GHA testing, but they all seem to be environmental.

@openjdk
Copy link

openjdk bot commented Apr 24, 2023

@gilles-duboscq This change now passes all automated pre-integration checks.

After integration, the commit message for the final commit will be:

7903448: JMH: Override the use of compiler hints using a system property

Reviewed-by: shade

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 4 new commits pushed to the master branch:

  • c6178ca: 7903461: JMH: perfasm profiler misses some jump edges
  • 8716778: 7903455: JMH: Add "mempool" profiler
  • e88ed82: 7903451: JMH: Refactor internal Optional usages
  • 2f21ef2: 7903439: JMH: Print help to stdout instead of stderr

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@shipilev) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 24, 2023
@gilles-duboscq
Copy link
Member Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Apr 24, 2023
@openjdk
Copy link

openjdk bot commented Apr 24, 2023

@gilles-duboscq
Your change (at version 9c1617a) is now ready to be sponsored by a Committer.

@shipilev
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Apr 24, 2023

Going to push as commit c5c93a2.
Since your change was applied there have been 4 commits pushed to the master branch:

  • c6178ca: 7903461: JMH: perfasm profiler misses some jump edges
  • 8716778: 7903455: JMH: Add "mempool" profiler
  • e88ed82: 7903451: JMH: Refactor internal Optional usages
  • 2f21ef2: 7903439: JMH: Print help to stdout instead of stderr

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Apr 24, 2023
@openjdk openjdk bot closed this Apr 24, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Apr 24, 2023
@openjdk
Copy link

openjdk bot commented Apr 24, 2023

@shipilev @gilles-duboscq Pushed as commit c5c93a2.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated
2 participants