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

8292713: Unsafe.allocateInstance should be intrinsified without UseUnalignedAccesses #9970

Closed

Conversation

shipilev
Copy link
Member

@shipilev shipilev commented Aug 22, 2022

See the rationale and references in the bug. I spotted that RISC-V tests are remarkably slow, and profiler shows that Unsafe.allocateInstance is very hot and native. RISC-V and ARM32 systems are UseUnalignedAccess = false, and I believe the _allocateInstance intrinsic is disabled on these paths by mistake. This PR improves the selected tests very considerably, and I think it actually fixes the real performance bug in java.lang.invoke-rich code paths.

Raspberry Pi 4, ARM32 fastdebug build:

$ time make test TEST=java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java

# Baseline

real	4m37.970s
user	6m5.490s
sys	0m21.731s

real	4m52.363s
user	6m24.100s
sys	0m21.363s

# Patched

real	2m32.678s ; <--- 1.8x faster
user	4m33.749s
sys	0m22.127s

real	2m38.451s ; <--- 1.8x faster, reproducible
user	4m44.788s
sys	0m22.160s

HiFive Unmatched, RISC-V fastdebug build:

$ time make test TEST=java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java

# Baseline

real	19m3.479s
user	27m2.932s
sys	0m27.766s

real	18m52.351s
user	27m23.917s
sys	0m27.682s

# Patched

real	10m5.971s  ; <--- 1.9x faster
user	18m11.538s
sys	0m28.204s

real	10m18.973s ; <--- 1.9x faster, reproducible
user	18m31.067s
sys	0m28.053s

Additional testing:

  • Linux RISC-V build, timing tests
  • Linux ARM32 build, timing tests
  • Linux ARM32 fastdebug tier1

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

  • JDK-8292713: Unsafe.allocateInstance should be intrinsified without UseUnalignedAccesses

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 9970

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 22, 2022

👋 Welcome back shade! 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 Aug 22, 2022
@openjdk
Copy link

openjdk bot commented Aug 22, 2022

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

  • hotspot-runtime

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-runtime hotspot-runtime-dev@openjdk.org label Aug 22, 2022
@shipilev
Copy link
Member Author

@RealFYang, you might want to give it a spin on your RISC-V machines ;)

@shipilev
Copy link
Member Author

/label remove hotspot-runtime
/label add hotspot-compiler

@openjdk openjdk bot removed the hotspot-runtime hotspot-runtime-dev@openjdk.org label Aug 22, 2022
@openjdk
Copy link

openjdk bot commented Aug 22, 2022

@shipilev
The hotspot-runtime label was successfully removed.

@openjdk openjdk bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Aug 22, 2022
@openjdk
Copy link

openjdk bot commented Aug 22, 2022

@shipilev
The hotspot-compiler label was successfully added.

@mlbridge
Copy link

mlbridge bot commented Aug 22, 2022

Webrevs

@VladimirKempik
Copy link

1-2 minutes (per test) on thead now, ( was 1-4 before the patch)

@PaulSandoz
Copy link
Member

I agree that this looks like mistake. Confirmation by another HotSpot member would be useful.

@openjdk
Copy link

openjdk bot commented Aug 23, 2022

@shipilev 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:

8292713: Unsafe.allocateInstance should be intrinsified without UseUnalignedAccesses

Reviewed-by: psandoz, kvn, fyang

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

  • b653b9c: 8291969: Convert LoaderConstraintsTable to ResourceHashtable
  • 0813a47: 8282729: Serial: Move BOT implementation to collector specific directory
  • fa5cc4c: 8291878: NMT: Malloc limits
  • ad2e0c4: 8292778: EncodingSupport_md.c convertUtf8ToPlatformString wrong placing of free
  • 13c0369: 8242181: [Linux] Show source information when printing native stack traces in hs_err files
  • fe0544f: 8292790: Remove hashtable.hpp from other files
  • 926380d: 8292640: C2: Remove unused scratch register usages on x86
  • f3be673: 8292638: x86: Improve scratch register handling in VM stubs
  • d24b7b7: 8276651: java/lang/ProcessHandle tests fail with "RuntimeException: Input/output error" in java.lang.ProcessHandleImpl$Info.info0
  • 8a45abd: 8292654: G1 remembered set memory footprint regression after JDK-8286115
  • ... and 28 more: https://git.openjdk.org/jdk/compare/79597f1ea6844f374beeeba219719cd9d5fe7d03...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 Aug 23, 2022
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.

Good.

Originally only 8 get/put*Unaligned intrinsics were guarded by UseUnalignedAccesses.
JDK-8130832 put accidentally additional 3 intrinsics: diff
get/putAddress_raw intrinsics were removed later by JDK-8150921.

@RealFYang
Copy link
Member

@RealFYang, you might want to give it a spin on your RISC-V machines ;)

Thanks for finding this. And I have launched a Tier1 test with release build on my unmatched board. It should take hours to finish.

Copy link
Member

@RealFYang RealFYang left a comment

Choose a reason for hiding this comment

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

Passed tier1 hotspot & jdk test on riscv64-linux unmatched board. Looks good to me.

@shipilev
Copy link
Member Author

Passed tier1 hotspot & jdk test on riscv64-linux unmatched board. Looks good to me.

Thanks! Do you know if it passes significantly faster?

@RealFYang
Copy link
Member

Passed tier1 hotspot & jdk test on riscv64-linux unmatched board. Looks good to me.

Thanks! Do you know if it passes significantly faster?

Well, I was not timing the testing process since it was carried on unmatched board shared with other developers.
But I guess this change will also improve some benchmark numbers. Maybe I can arrange some further tests like specjbb2015 when I can monopolize the board :-)

@shipilev
Copy link
Member Author

Passed tier1 hotspot & jdk test on riscv64-linux unmatched board. Looks good to me.

Thanks! Do you know if it passes significantly faster?

Well, I was not timing the testing process since it was carried on unmatched board shared with other developers. But I guess this change will also improve some benchmark numbers. Maybe I can arrange some further tests like specjbb2015 when I can monopolize the board :-)

No need, I was just curious. I'll integrate this then.

/integrate

@openjdk
Copy link

openjdk bot commented Aug 24, 2022

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

  • a45a4b9: 8292194: G1 nmethod entry barrier disarm value wraps around too early
  • d3fed12: 8292864: Remove resourceHash.hpp from header files
  • b653b9c: 8291969: Convert LoaderConstraintsTable to ResourceHashtable
  • 0813a47: 8282729: Serial: Move BOT implementation to collector specific directory
  • fa5cc4c: 8291878: NMT: Malloc limits
  • ad2e0c4: 8292778: EncodingSupport_md.c convertUtf8ToPlatformString wrong placing of free
  • 13c0369: 8242181: [Linux] Show source information when printing native stack traces in hs_err files
  • fe0544f: 8292790: Remove hashtable.hpp from other files
  • 926380d: 8292640: C2: Remove unused scratch register usages on x86
  • f3be673: 8292638: x86: Improve scratch register handling in VM stubs
  • ... and 30 more: https://git.openjdk.org/jdk/compare/79597f1ea6844f374beeeba219719cd9d5fe7d03...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Aug 24, 2022

@shipilev Pushed as commit c062397.

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

@VladimirKempik
Copy link

DO we want to backport it to jdk17u as well ?

@shipilev
Copy link
Member Author

DO we want to backport it to jdk17u as well ?

Yes, once it gets soaked in mainline for a week or two.

@shipilev shipilev deleted the JDK-8292713-unsafe-allocinstance branch September 5, 2022 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

5 participants