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

JDK-8305711: Arm: C2 always enters slowpath for monitorexit #13376

Conversation

tstuefe
Copy link
Member

@tstuefe tstuefe commented Apr 6, 2023

A small bug in the C2 implementation of monitorexit for thin locks causes us to always enter the slow path.

This seems to be a day zero bug of the arm port, since JEP 297: "Unified arm32/arm64 Port". It has a significant effect on locking performance, but its effect had been hidden until JDK 15 by biased locking. Biased locking removal made the bug appearant.

With this patch, @rkennke's artificial microbenchmark that does nothing but uncontended locking improves greatly (see https://github.com/rkennke/fastlockbench):

Benchmark                      (backoff)  Mode  Cnt      Score   Error  Units
FastLockingBenchmark.testSync          0  avgt    2    110.600          ns/op
FastLockingBenchmark.testSync          1  avgt    2    105.725          ns/op
FastLockingBenchmark.testSync          2  avgt    2    122.780          ns/op
FastLockingBenchmark.testSync          4  avgt    2    125.133          ns/op
FastLockingBenchmark.testSync          8  avgt    2    151.915          ns/op
FastLockingBenchmark.testSync         16  avgt    2    206.458          ns/op
FastLockingBenchmark.testSync         32  avgt    2    313.980          ns/op
FastLockingBenchmark.testSync         64  avgt    2    522.206          ns/op

New:

Benchmark                      (backoff)  Mode  Cnt      Score   Error  Units
FastLockingBenchmark.testSync          0  avgt    2     60.102          ns/op
FastLockingBenchmark.testSync          1  avgt    2     61.667          ns/op
FastLockingBenchmark.testSync          2  avgt    2     74.950          ns/op
FastLockingBenchmark.testSync          4  avgt    2     85.480          ns/op
FastLockingBenchmark.testSync          8  avgt    2    115.019          ns/op
FastLockingBenchmark.testSync         16  avgt    2    178.046          ns/op
FastLockingBenchmark.testSync         32  avgt    2    273.376          ns/op
FastLockingBenchmark.testSync         64  avgt    2    500.287          ns/op

Please note that Arm remains broken since JDK-8301995; I based and tested this patch on the parent of that change.


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-8305711: Arm: C2 always enters slowpath for monitorexit

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 13376

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 6, 2023

👋 Welcome back stuefe! 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 Apr 6, 2023
@openjdk
Copy link

openjdk bot commented Apr 6, 2023

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

  • hotspot-compiler

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-compiler hotspot-compiler-dev@openjdk.org label Apr 6, 2023
@mlbridge
Copy link

mlbridge bot commented Apr 6, 2023

Webrevs

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.

Ouch! Good thing this does not blow up correctness-wise? The object header would almost never (famous last words) look like a displaced header when locked. InterpreterMacroAssembler::unlock_object does it correctly, and this code now matches the interpreter.

@openjdk
Copy link

openjdk bot commented Apr 6, 2023

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

8305711: Arm: C2 always enters slowpath for monitorexit

Reviewed-by: shade, kvn

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 no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential 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 Apr 6, 2023
@shipilev
Copy link
Member

shipilev commented Apr 6, 2023

Usual synopsis for ARM32 bugs is "ARM32: C2 always...", I think :)

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.

@tstuefe
Copy link
Member Author

tstuefe commented Apr 7, 2023

Thanks @shipilev and @vnkozlov!

/integrate

@openjdk
Copy link

openjdk bot commented Apr 7, 2023

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

  • ce6e746: 8305118: Add RISC-V related content to building.md
  • 314e9b3: 8300829: Make CtwRunner available as an independent tool
  • 0a34018: 8305680: Remove Permissions from jcmd help output
  • 8db1dd0: 8305622: Remove Permission details from jcmd man page
  • 1d517af: 8305209: JDWP exit error AGENT_ERROR_INVALID_THREAD(203): missing entry in running thread table

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Apr 7, 2023

@tstuefe Pushed as commit c67bbce.

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

@tstuefe tstuefe deleted the JDK-8305711-Arm-C2-always-enters-slowpath-for-monitorexit branch July 25, 2023 13:28
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
3 participants