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

8186670: Implement _onSpinWait() intrinsic for AArch64 #181

Closed
wants to merge 1 commit into from

Conversation

eastig
Copy link
Contributor

@eastig eastig commented Feb 23, 2022

A backport of a configurable implementation of _onSpinWait() intrinsic to achieve parity with x86 which has it implemented.
The risk of changes is low. By default it is off.
Tested for fastdebug and release builds:

  • gtest: Passed
  • tier1...tier3: Passed except JDK-8261534 and JDK-8277488
  • hotspot/jtreg/compiler/onSpinWait: Passed

Applying the patch had issues to find proper positions. No code changes are needed after repositioning.
Changes to globals_aarch64.hpp needed the new added options definitions to be converted from the new format to the old one. vm.flagless was removed from the new tests.
Changes to vm_version_aarch64.cpp, instantiation of SpinWait, use C++11 syntax. They needed to be changed to C++03 syntax.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issues

  • JDK-8186670: Implement _onSpinWait() intrinsic for AArch64
  • JDK-8274564: Add diagnostic VM options to control Thread.onSpinWait intrinsic code for AArch64 (CSR)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk15u-dev pull/181/head:pull/181
$ git checkout pull/181

Update a local copy of the PR:
$ git checkout pull/181
$ git pull https://git.openjdk.java.net/jdk15u-dev pull/181/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 181

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk15u-dev/pull/181.diff

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Feb 23, 2022

👋 Welcome back eastig! 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 changed the title Backport 6954b98f8faf29b6c2d13687a7a94e83302bdd85 8186670: Implement _onSpinWait() intrinsic for AArch64 Feb 23, 2022
@openjdk
Copy link

@openjdk openjdk bot commented Feb 23, 2022

This backport pull request has now been updated with issue from the original commit.

@openjdk openjdk bot added backport rfr labels Feb 23, 2022
@mlbridge
Copy link

@mlbridge mlbridge bot commented Feb 23, 2022

Webrevs

Copy link
Member

@phohensee phohensee left a comment

Lgtm, except:

I don't see any C++03 vs C++11 differences in vm_version_aarch64.cpp. What am I missing?

Do JDK-8261534 and JDK-8277488 also fail without this patch?

@eastig
Copy link
Contributor Author

@eastig eastig commented Feb 24, 2022

Lgtm, except:

I don't see any C++03 vs C++11 differences in vm_version_aarch64.cpp. What am I missing?

C++11 return SpinWait{} vs C++03 return SpinWait();

Do JDK-8261534 and JDK-8277488 also fail without this patch?

Yes, they do.

Copy link
Member

@phohensee phohensee left a comment

I skipped right over the {} vs ()!

Lgtm.

@openjdk
Copy link

@openjdk openjdk bot commented Feb 24, 2022

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

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

8186670: Implement _onSpinWait() intrinsic for AArch64

Reviewed-by: phh

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

  • b98036f: 8276141: XPathFactory set/getProperty method
  • be6915a: 8261107: ArrayIndexOutOfBoundsException in the ICC_Profile.getInstance(InputStream)
  • 1a1dec4: 8261534: Test sun/security/pkcs11/KeyAgreement/IllegalPackageAccess.java fails on platforms where no nsslib artifacts are defined

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 (@phohensee) 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 label Feb 24, 2022
@theRealAph
Copy link
Contributor

@theRealAph theRealAph commented Feb 25, 2022

I'm not sure about this one. With OnSpinWaitInst=isb, ThreadOnSpinWaitProducerConsumer gets better but ThreadOnSpinWaitSharedCounter gets worse. So there are cases where it's worth using, but does this patch meet the "enhancement that provides substantial benefit to OpenJDK 11u users and it is of low risk" requirement? I guess as long as the default for all platforms stays at "off" it won't cause any regressions.
Do you know of any applications that substantially benefit?

@eastig
Copy link
Contributor Author

@eastig eastig commented Feb 25, 2022

So there are cases where it's worth using, but does this patch meet the "enhancement that provides substantial benefit to OpenJDK 11u users and it is of low risk" requirement?

This is for 15u not for 11u.

Do you know of any applications that substantially benefit?

Yes, we have services which got improvements. Also 15u version of java.util.concurrent.SynchronousQueue uses Thread.onSpinWait. A SynchronousQueue microbenchmark (see it in https://bugs.openjdk.java.net/browse/JDK-8267502) got the following geomean ops/s when ran on 2 CPUs 60 times:

  • No intrinsic implementation: 226,732.8 ops/s
  • One ISB implementation: 1,996,916.3 ops/s

The difference is 8.8x.

@mlbridge
Copy link

@mlbridge mlbridge bot commented Feb 25, 2022

Mailing list message from Andrew Haley on jdk-updates-dev:

On 2/25/22 12:14, Evgeny Astigeevich wrote:

On Fri, 25 Feb 2022 10:24:08 GMT, Andrew Haley <aph at openjdk.org> wrote:

So there are cases where it's worth using, but does this patch meet the "enhancement that provides substantial benefit to OpenJDK 11u users and it is of low risk" requirement?

This is for 15u not for 11u.

Sure, OK. I'm thinking ahead.

Do you know of any applications that substantially benefit?

Yes, we have services which got improvements. Also 15u version of `java.util.concurrent.SynchronousQueue` uses `Thread.onSpinWait`. A SynchronousQueue microbenchmark (see it in https://bugs.openjdk.java.net/browse/JDK-8267502) got the following geomean ops/s when ran on 2 CPUs 60 times:
- No intrinsic implementation: 226,732.8 ops/s
- One ISB implementation: 1,996,916.3 ops/s

The difference is 8.8x.

Interesting, so I guess that's much more dramatic than anything we have in
the OpenJDK benchmarks. Maybe we want a JMH version of that.

Do you think that onSpinWait() = ISB would help with 8267502?

@eastig
Copy link
Contributor Author

@eastig eastig commented Mar 8, 2022

Interesting, so I guess that's much more dramatic than anything we have in
the OpenJDK benchmarks. Maybe we want a JMH version of that.

I've converted it to the JMH version. Results:

No intrinsic:
Benchmark                                 Mode  Cnt     Score     Error  Units
ThreadOnSpinWaitProducerConsumer01.trial  avgt   10  2078.777 ± 743.187  ms/op

1-ISB
Benchmark                                 Mode  Cnt    Score   Error  Units
ThreadOnSpinWaitProducerConsumer01.trial  avgt   10  239.728 ± 3.207  ms/op

Do you think that onSpinWait() = ISB would help with 8267502?

Maybe, if I knew more details of https://bugs.openjdk.java.net/browse/JDK-8246677.

@eastig
Copy link
Contributor Author

@eastig eastig commented Mar 10, 2022

/integrate

@openjdk openjdk bot added the sponsor label Mar 10, 2022
@openjdk
Copy link

@openjdk openjdk bot commented Mar 10, 2022

@eastig
Your change (at version 359f97d) is now ready to be sponsored by a Committer.

@phohensee
Copy link
Member

@phohensee phohensee commented Mar 10, 2022

/sponsor

@openjdk
Copy link

@openjdk openjdk bot commented Mar 10, 2022

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

  • b98036f: 8276141: XPathFactory set/getProperty method
  • be6915a: 8261107: ArrayIndexOutOfBoundsException in the ICC_Profile.getInstance(InputStream)
  • 1a1dec4: 8261534: Test sun/security/pkcs11/KeyAgreement/IllegalPackageAccess.java fails on platforms where no nsslib artifacts are defined

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated label Mar 10, 2022
@openjdk openjdk bot closed this Mar 10, 2022
@openjdk openjdk bot removed ready rfr sponsor labels Mar 10, 2022
@openjdk
Copy link

@openjdk openjdk bot commented Mar 10, 2022

@phohensee @eastig Pushed as commit e972e77.

💡 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
backport integrated
3 participants