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

8269404: Base64 Encoding optimization enhancements for x86 using AVX-512 #4601

Closed
wants to merge 12 commits into from

Conversation

asgibbons
Copy link
Contributor

@asgibbons asgibbons commented Jun 26, 2021

Enhance the Base64 Encode intrinsic for x86 using AVX-512 to get better performance. Also allow for performance improvement on non-AVX-512 enabled platforms.

Added AVX-512 code for encoding Base64 blocks, including slight improvements for non-AVX-512 x86 platforms.

Running the Base64Decode benchmark, this change increases decode performance by an average of 2.6x with a maximum 9.7x for buffers > ~20k. The numbers are given in the table below.

Base Score is without intrinsic support, Optimized Score is using this intrinsic, and Gain is Base / Optimized.

Benchmark Name Base Score Optimized Score Gain
testBase64Encode size 1 8.10 8.04 1.01
testBase64Encode size 2 8.51 8.43 1.01
testBase64Encode size 3 11.08 10.72 1.03
testBase64Encode size 6 13.98 13.12 1.07
testBase64Encode size 7 14.44 13.38 1.08
testBase64Encode size 9 15.44 14.37 1.07
testBase64Encode size 10 16.13 14.97 1.08
testBase64Encode size 48 27.14 23.23 1.17
testBase64Encode size 512 123.86 30.75 4.03
testBase64Encode size 1000 224.42 37.71 5.95
testBase64Encode size 20000 4202.11 430.16 9.77

Progress

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

Issue

  • JDK-8269404: Base64 Encoding optimization enhancements for x86 using AVX-512

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 4601

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

Using diff file

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

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Jun 26, 2021

👋 Welcome back asgibbons! 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 label Jun 26, 2021
@asgibbons
Copy link
Contributor Author

@asgibbons asgibbons commented Jun 26, 2021

/label add hotspot-compiler

@openjdk
Copy link

@openjdk openjdk bot commented Jun 26, 2021

@asgibbons 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 label Jun 26, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Jun 26, 2021

@asgibbons The hotspot-compiler label was already applied.

@mlbridge
Copy link

@mlbridge mlbridge bot commented Jun 26, 2021

Webrevs

@vnkozlov
Copy link
Contributor

@vnkozlov vnkozlov commented Jun 26, 2021

@asgibbons if you are still working on this, please convert it to draft PR. There is Convert to draft link under Reviewers:

Reviewers
No reviews
Still in progress? Convert to draft

Otherwise it seems like it is ready for review and we got RFR emails.

@asgibbons
Copy link
Contributor Author

@asgibbons asgibbons commented Jun 26, 2021

Thanks, @vnkozlov. I have tested this on all the platforms I have available to me, and it has been internally reviewed. I'm a novice when it comes to this process and I have read the contributing guidelines, but I'm at a loss as to how draft PRs are used.

I believe this is the change that will ultimately be integrated, so in fact I am looking for reviews. Can you enlighten me please?

Copy link
Contributor

@vnkozlov vnkozlov left a comment

At first I thought you would add more changes in Java lib and Hotspot runtime.
But you simply optimized assembler code for existing Encode intrinsic.

This looks good to me but I need to test it.

@vnkozlov
Copy link
Contributor

@vnkozlov vnkozlov commented Jun 27, 2021

compiler/intrinsics/base64/TestBase64.java failed with wrong result on Windows (avx512):

----------System.out:(1/17)----------
5000 iterations
----------System.err:(17/1502)----------
java.lang.RuntimeException: Assertion failed! The result is not same as expected
 result: ICAgICAgICAxNiBRICAgICAgICAgICAgsTsA6igAoigAoigAoigAoj0QIHk= expected: ICAgICAgICAxNiBRICAgICAgICAgICAgMzMgaCAgICAgICAgICAgIDUwIHk=
	at compiler.intrinsics.base64.TestBase64.assertEqual(TestBase64.java:238)
	at compiler.intrinsics.base64.TestBase64.test0(TestBase64.java:151)
	at compiler.intrinsics.base64.TestBase64.main(TestBase64.java:72)

@asgibbons
Copy link
Contributor Author

@asgibbons asgibbons commented Jun 28, 2021

@vnkozlov Looks like I had a shift count wrong for URL encoding. Tested it and it should now work. Sorry for the churn.

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Testing passed.

You need second review.

@openjdk
Copy link

@openjdk openjdk bot commented Jun 29, 2021

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

8269404: Base64 Encoding optimization enhancements for x86 using AVX-512

Reviewed-by: kvn, sviswanathan

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 248 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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@vnkozlov, @sviswa7) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready label Jun 29, 2021
@asgibbons
Copy link
Contributor Author

@asgibbons asgibbons commented Jul 2, 2021

/integrate

@openjdk openjdk bot added the sponsor label Jul 2, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Jul 2, 2021

@asgibbons
Your change (at version c4cbe97) is now ready to be sponsored by a Committer.

src/hotspot/cpu/x86/assembler_x86.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/x86/assembler_x86.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/x86/assembler_x86.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/x86/stubGenerator_x86_64.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/x86/stubGenerator_x86_64.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/x86/stubGenerator_x86_64.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/x86/stubGenerator_x86_64.cpp Show resolved Hide resolved
@openjdk openjdk bot removed the sponsor label Jul 10, 2021
@asgibbons
Copy link
Contributor Author

@asgibbons asgibbons commented Jul 10, 2021

/integrate

@openjdk openjdk bot added the sponsor label Jul 10, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Jul 10, 2021

@asgibbons
Your change (at version e0db0ae) is now ready to be sponsored by a Committer.

@openjdk openjdk bot removed the sponsor label Jul 13, 2021
@asgibbons
Copy link
Contributor Author

@asgibbons asgibbons commented Jul 13, 2021

/integrate

@openjdk openjdk bot added the sponsor label Jul 13, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Jul 13, 2021

@asgibbons
Your change (at version 10ec992) is now ready to be sponsored by a Committer.

@sviswa7
Copy link

@sviswa7 sviswa7 commented Jul 13, 2021

The patch looks good to me.

@sviswa7
Copy link

@sviswa7 sviswa7 commented Jul 13, 2021

/sponsor

@openjdk
Copy link

@openjdk openjdk bot commented Jul 13, 2021

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

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Jul 13, 2021
@openjdk openjdk bot added integrated and removed ready rfr sponsor labels Jul 13, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Jul 13, 2021

@sviswa7 @asgibbons Pushed as commit 9cac94d.

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

@asgibbons asgibbons deleted the base64_encode_new branch Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-compiler integrated
4 participants