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

8290688: Optimize x86_64 nmethod entry barriers #9569

Closed
wants to merge 4 commits into from

Conversation

fisk
Copy link
Contributor

@fisk fisk commented Jul 20, 2022

The current x86_64 nmethod entry barrier is good, but it could be a bit better. In particular, this enhancement targets the following ideas.

  1. The alignment of the cmp instruction is 8 bytes. However, we only patch 4 bytes and the instruction length is always 8 bytes. So if we align the start of the instruction to 4 bytes only, that is enough to ensure that the immediate part of the instruction is 4 byte aligned, which is all we need (cf. http://cr.openjdk.java.net/~jrose/jvm/hotspot-cmc.html).

  2. Today the fast path (conditionally) jumps over a call to a stub. It is not uncommon for the branch not taken path being better optimized, making it favourable to move the call to a stub out-of-line. This has the additional benefit of not polluting the instruction caches at the nmethod entry with instructions not used in the fast path. A bit messy but we can do it for at least C2 code.

  3. For C1 and native wrappers, I don't think they are hot enough to warrant the stub machinery. But at least the jump that jumps over the cold stuff, can be shortened. I can get behind that.

Before addressing this, turning nmethod entry barriers on with G1 (e.g. by enabling loom) leads to a regression in DaCapo tradesoap-large. With this enhancement, the regression goes away, so that the cost of nmethod entry barriers is not visible.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 9569

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/9569.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 20, 2022

👋 Welcome back eosterlund! 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
Copy link

openjdk bot commented Jul 20, 2022

@fisk The following label will be automatically applied to this pull request:

  • hotspot

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the hotspot hotspot-dev@openjdk.org label Jul 20, 2022
@fisk
Copy link
Contributor Author

fisk commented Jul 20, 2022

/issue JDK-8290688

@openjdk openjdk bot changed the title Optimize x86 nmethod entry barriers 8290688: Optimize x86_64 nmethod entry barriers Jul 20, 2022
@openjdk
Copy link

openjdk bot commented Jul 20, 2022

@fisk The primary solved issue for a PR is set through the PR title. Since the current title does not contain an issue reference, it will now be updated.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 20, 2022
@mlbridge
Copy link

mlbridge bot commented Jul 20, 2022

Webrevs

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

Looks good.

@openjdk
Copy link

openjdk bot commented Jul 20, 2022

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

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

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

8290688: Optimize x86_64 nmethod entry barriers

Reviewed-by: kvn, rrich

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 43 new commits pushed to the master branch:

  • 54854d9: 8256811: Delayed/missed jdwp class unloading events
  • 75c1e99: 8289572: InputStream wrapping with BufferedInputStream is redundant in HttpTimestamper
  • 7841e5c: 8290464: Optimize ResourceArea zapping on ResourceMark release
  • e9f97b2: 8290489: Initial nroff manpage generation for JDK 20
  • 59d85ba: 8290687: serviceability/sa/TestClassDump.java could leave files owned by root on macOS
  • 66f59c2: 8290731: Clean up CDS handling of LambdaForm Species classes
  • 0dda3c1: 8289275: Remove incorrect __declspec(dllimport) attributes from pointers in jdk.crypto.cryptoki
  • 620c8a0: 8289643: File descriptor leak with ProcessBuilder.startPipeline
  • 7ec0132: 8286844: com/sun/jdi/RedefineCrossEvent.java failed with 1 threads completed while VM suspended
  • 80bd8c3: 8290504: Close streams returned by ModuleReader::list
  • ... and 33 more: https://git.openjdk.org/jdk/compare/43c47b1ad7453b4be5ad949d49866de1d911973e...master

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.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 20, 2022
@fisk
Copy link
Contributor Author

fisk commented Jul 20, 2022

Looks good.

Thanks for the review, @vnkozlov!

Copy link
Member

@reinrich reinrich left a comment

Choose a reason for hiding this comment

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

Hi Erik,

Looks good to me!

I can imagine that hot taken branches, especially many of them, can become a
performance issue when the hardware fails to predict the target address.

Richard.

@fisk
Copy link
Contributor Author

fisk commented Jul 22, 2022

Thanks for the review @reinrich!

@fisk
Copy link
Contributor Author

fisk commented Jul 22, 2022

/integrate

@openjdk
Copy link

openjdk bot commented Jul 22, 2022

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

  • 54854d9: 8256811: Delayed/missed jdwp class unloading events
  • 75c1e99: 8289572: InputStream wrapping with BufferedInputStream is redundant in HttpTimestamper
  • 7841e5c: 8290464: Optimize ResourceArea zapping on ResourceMark release
  • e9f97b2: 8290489: Initial nroff manpage generation for JDK 20
  • 59d85ba: 8290687: serviceability/sa/TestClassDump.java could leave files owned by root on macOS
  • 66f59c2: 8290731: Clean up CDS handling of LambdaForm Species classes
  • 0dda3c1: 8289275: Remove incorrect __declspec(dllimport) attributes from pointers in jdk.crypto.cryptoki
  • 620c8a0: 8289643: File descriptor leak with ProcessBuilder.startPipeline
  • 7ec0132: 8286844: com/sun/jdi/RedefineCrossEvent.java failed with 1 threads completed while VM suspended
  • 80bd8c3: 8290504: Close streams returned by ModuleReader::list
  • ... and 33 more: https://git.openjdk.org/jdk/compare/43c47b1ad7453b4be5ad949d49866de1d911973e...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jul 22, 2022
@openjdk openjdk bot closed this Jul 22, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jul 22, 2022
@openjdk
Copy link

openjdk bot commented Jul 22, 2022

@fisk Pushed as commit b28f9da.

💡 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
hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated
3 participants