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

8281168: Micro-optimize VarForm.getMemberName for interpreter #7333

Closed
wants to merge 3 commits into from

Conversation

shipilev
Copy link
Member

@shipilev shipilev commented Feb 3, 2022

I was looking for easy things to do to improve java.lang.invoke cold performance. One of the things is inlining VarForm.getMemberName a bit, so that interpreter does not have to call through getMemberNameOrNull.

There is direct VarHandle benchmark in our corpus:

$ CONF=linux-x86_64-server-release make run-test TEST=micro:java.lang.invoke.VarHandleExact MICRO="TIME=200ms;WARMUP_TIME=200ms;VM_OPTIONS=-Xint"

Benchmark                                 Mode  Cnt     Score    Error  Units

# -Xint
# Baseline
VarHandleExact.exact_exactInvocation      avgt   30   714.041 ±  5.882  ns/op
VarHandleExact.generic_exactInvocation    avgt   30   641.570 ± 11.681  ns/op
VarHandleExact.generic_genericInvocation  avgt   30  1336.571 ± 11.873  ns/op

# -Xint
# Patched
VarHandleExact.exact_exactInvocation      avgt   30   678.495 ± 10.752  ns/op ; +5%
VarHandleExact.generic_exactInvocation    avgt   30   573.320 ±  5.100  ns/op ; +11%
VarHandleExact.generic_genericInvocation  avgt   30  1338.593 ± 14.275  ns/op 

# (server, default)
# Baseline
VarHandleExact.exact_exactInvocation      avgt   30   0.620 ± 0.079  ns/op
VarHandleExact.generic_exactInvocation    avgt   30   0.602 ± 0.063  ns/op
VarHandleExact.generic_genericInvocation  avgt   30  10.521 ± 0.065  ns/op

# (server, default)
# Patched
VarHandleExact.exact_exactInvocation      avgt   30   0.621 ± 0.070  ns/op
VarHandleExact.generic_exactInvocation    avgt   30   0.601 ± 0.061  ns/op
VarHandleExact.generic_genericInvocation  avgt   30  10.499 ± 0.070  ns/op

Additional testing:

  • Linux x86_64 fastdebug tier1
  • Linux x86_64 fastdebug tier2
  • Linux x86_64 fastdebug tier3

Progress

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

Issue

  • JDK-8281168: Micro-optimize VarForm.getMemberName for interpreter

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/7333/head:pull/7333
$ git checkout pull/7333

Update a local copy of the PR:
$ git checkout pull/7333
$ git pull https://git.openjdk.java.net/jdk pull/7333/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 7333

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/7333.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 3, 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 Feb 3, 2022
@openjdk
Copy link

openjdk bot commented Feb 3, 2022

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

  • core-libs

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 core-libs core-libs-dev@openjdk.org label Feb 3, 2022
@mlbridge
Copy link

mlbridge bot commented Feb 3, 2022

Webrevs

Copy link
Member

@cl4es cl4es left a comment

Choose a reason for hiding this comment

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

Looks reasonable.

@openjdk
Copy link

openjdk bot commented Feb 7, 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:

8281168: Micro-optimize VarForm.getMemberName for interpreter

Reviewed-by: redestad, vlivanov, mchung

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 44 new commits pushed to 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.

➡️ 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 Feb 7, 2022
@shipilev
Copy link
Member Author

shipilev commented Feb 8, 2022

Looks reasonable.

Thanks. Any more reviews needed, or I am pushing?

@cl4es
Copy link
Member

cl4es commented Feb 8, 2022

Thanks. Any more reviews needed, or I am pushing?

I think you're good to push. I suspect some might question making the code ever so little less obvious/maintainable on behalf of interpreter performance, but I think it's well-motivated since startup speed is where MHs/VHs continue to feel a bit lackluster.

Copy link

@iwanowww iwanowww left a comment

Choose a reason for hiding this comment

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

Thanks, looks good.

@mlchung
Copy link
Member

mlchung commented Feb 8, 2022

This change looks okay. One biggest cold startup overhead we measured for JEP 416 is due to the overhead of spinning and loading classes of MH/VH. This micro-optimization focuses on the performance of VH invocation. Do you see class spinning and loading from your benchmark? Maybe in the generic invocation case?

@shipilev
Copy link
Member Author

shipilev commented Feb 8, 2022

This change looks okay. One biggest cold startup overhead we measured for JEP 416 is due to the overhead of spinning and loading classes of MH/VH. This micro-optimization focuses on the performance of VH invocation. Do you see class spinning and loading from your benchmark? Maybe in the generic invocation case?

Not really, I am trying to see that -Xint does not have easy to fix impediments to cold performance. In this benchmark, bootstrapping stuff had already happened at warmup, it measures the overheads of doing all the MH/VH without the optimizing compiler assistance.

@shipilev
Copy link
Member Author

shipilev commented Feb 9, 2022

/integrate

@openjdk
Copy link

openjdk bot commented Feb 9, 2022

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

  • bce5dd1: 8280438: Improve BufferNode::Allocator::release to avoid walking pending list
  • 13f739d: 8280830: Change NonblockingQueue::try_pop variable named "result"
  • 2f46af0: 8280132: Incorrect comparator com.sun.beans.introspect.MethodInfo.MethodOrder
  • fb17a8e: 8278947: Support for array constants in constant table
  • d658d94: 8280828: Improve invariants in NonblockingQueue::append
  • 5fb56db: 8281476: ProblemList tools/jar/CreateMissingParentDirectories.java
  • 92f4f40: 8281104: jar --create should create missing parent directories
  • 7f19c70: 8281061: [s390] JFR runs into assertions while validating interpreter frames
  • 380378c: 8281400: Remove unused wcslen() function
  • 83d6745: 8281450: Remove unnecessary operator new and delete from ObjectMonitor
  • ... and 40 more: https://git.openjdk.java.net/jdk/compare/63a00a0df24b154ef459936dbd69bcd2f0626235...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Feb 9, 2022

@shipilev Pushed as commit fc77217.

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

@shipilev shipilev deleted the JDK-8281168-int-varform branch March 7, 2022 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated
4 participants