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

8145948: C2: Initializing volatile fields to default values should be optimized #19721

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shipilev
Copy link
Member

@shipilev shipilev commented Jun 14, 2024

WIP.

New benchmark shows expected improvements. Actually, I suppose we can eliminate the barriers for all volatile writes in initializers, and instead rely on final-field-like semantics, but that requires a more comprehensive arguments, so I'll leave that for future work.

Benchmark                                        Mode  Cnt   Score   Error  Units

# Baseline
ConstructorDefaultInitBarriers.plain_init_0      avgt    3   5.820 ± 0.161  ns/op
ConstructorDefaultInitBarriers.plain_init_42     avgt    3   5.504 ± 0.108  ns/op
ConstructorDefaultInitBarriers.volatile_init_0   avgt    3  11.969 ± 0.223  ns/op
ConstructorDefaultInitBarriers.volatile_init_42  avgt    3  12.028 ± 1.671  ns/op

# Patched
ConstructorDefaultInitBarriers.plain_init_0      avgt    3   5.815 ± 0.187  ns/op
ConstructorDefaultInitBarriers.plain_init_42     avgt    3   5.511 ± 0.053  ns/op
ConstructorDefaultInitBarriers.volatile_init_0   avgt    3   5.737 ± 0.079  ns/op   ; <----
ConstructorDefaultInitBarriers.volatile_init_42  avgt    3  11.885 ± 0.950  ns/op

Additional testing:

  • New IR tests pass
  • New benchmark shows expected improvement
  • Linux x86_64 server fastdebug, all
  • Linux AArch64 server fastdebug, all

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-8145948: C2: Initializing volatile fields to default values should be optimized (Enhancement - P4)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 19721

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 14, 2024

👋 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
Copy link

openjdk bot commented Jun 14, 2024

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk
Copy link

openjdk bot commented Jun 14, 2024

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

if (is_vol && !(method()->is_initializer() && _gvn.type(val)->is_zero_type())) {
// Volatile fields initialized to default values in constructor are
// indistinguishable from the default field initializations. They do
// do not require full barriers.
Copy link

Choose a reason for hiding this comment

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

only if it's the very first put, right?

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 9, 2024

@shipilev This pull request has been inactive for more than 8 weeks and will be automatically closed if another 8 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@shipilev
Copy link
Member Author

Not now, bot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants