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

8343541: C1: Plain memory accesses are emitted with membars with +AlwaysAtomicAccesses #22191

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

pengxiaolong
Copy link

@pengxiaolong pengxiaolong commented Nov 18, 2024

C1 and C2 has different implementations for +AlwaysAtomicAccesses, C2 impl only guarantees atomicity hence no membars are emitted for plain memory access, but C1 treats it same as volatile access hence it emits membars. The change removes the unnecessary membars in C1 for +AlwaysAtomicAccesses.

The test have been verified by very simple JMH benchmarks to measure the latency of reading/writing long/volatile long variable 10000 times, and run with VM option -XX:TieredStopAtLevel=3 -XX:+UnlockExperimentalVMOptions -XX:+AlwaysAtomicAccesses:

Before the fix:

Benchmark                                   Mode  Cnt       Score      Error  Units
AlwaysAtomicAccesses.testReadLong           avgt    5   58711.131 ±  716.940  ns/op
AlwaysAtomicAccesses.testReadVolatileLong   avgt    5   59014.735 ±  675.354  ns/op
AlwaysAtomicAccesses.testWriteLong          avgt    5  115817.978 ±  302.089  ns/op
AlwaysAtomicAccesses.testWriteVolatileLong  avgt    5  116317.835 ± 1451.365  ns/op

After the fix:

Benchmark                                   Mode  Cnt       Score      Error  Units
AlwaysAtomicAccesses.testReadLong           avgt    5   49651.527 ±  159.948  ns/op
AlwaysAtomicAccesses.testReadVolatileLong   avgt    5   58668.844 ±  316.029  ns/op
AlwaysAtomicAccesses.testWriteLong          avgt    5   23008.361 ±   10.947  ns/op
AlwaysAtomicAccesses.testWriteVolatileLong  avgt    5  116440.017 ± 1240.832  ns/op

Progress

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

Issue

  • JDK-8343541: C1: Plain memory accesses are emitted with membars with +AlwaysAtomicAccesses (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 22191

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 18, 2024

👋 Welcome back xpeng! 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 Nov 18, 2024

@pengxiaolong This change is no longer ready for integration - check the PR body for details.

@openjdk
Copy link

openjdk bot commented Nov 18, 2024

@pengxiaolong 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.

@pengxiaolong pengxiaolong marked this pull request as ready for review November 18, 2024 08:50
@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 18, 2024
@mlbridge
Copy link

mlbridge bot commented Nov 18, 2024

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.

It is a bit sad that we call volatile_field_* when we really mean atomic. But renaming that would lead to much deeper changes. So I am okay with doing just this, thanks.

src/hotspot/share/gc/shared/c1/barrierSetC1.cpp Outdated Show resolved Hide resolved
@pengxiaolong
Copy link
Author

It is a bit sad that we call volatile_field_* when we really mean atomic. But renaming that would lead to much deeper changes. So I am okay with doing just this, thanks.

I'll fix it, it is not too deep, and they are only used by barrierSetC1.cpp

@shipilev
Copy link
Member

It is a bit sad that we call volatile_field_* when we really mean atomic. But renaming that would lead to much deeper changes. So I am okay with doing just this, thanks.

I'll fix it, it is not too deep, and they are only used by barrierSetC1.cpp

No need. If we go down that road, we also want to rename lir_move_volatile and all that jazz, which would probably entail a few rounds of careful looking. Submit a follow-up issue for it instead.

@pengxiaolong
Copy link
Author

pengxiaolong commented Nov 18, 2024

It is a bit sad that we call volatile_field_* when we really mean atomic. But renaming that would lead to much deeper changes. So I am okay with doing just this, thanks.

I'll fix it, it is not too deep, and they are only used by barrierSetC1.cpp

You are right, checked the related code, need to update the chain deep to LIR_Assembler, I'll leave them unchanged except if it is really necessary.

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.

/reviewers 2

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 18, 2024
@openjdk
Copy link

openjdk bot commented Nov 18, 2024

@shipilev
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot [email protected] rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

2 participants