Skip to content

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

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

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

Sorry, something went wrong.

@bridgekeeper
Copy link

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 Pull request is ready for review label Jun 26, 2021
@asgibbons
Copy link
Contributor Author

/label add hotspot-compiler

@openjdk
Copy link

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 hotspot-compiler-dev@openjdk.org label Jun 26, 2021
@openjdk
Copy link

openjdk bot commented Jun 26, 2021

@asgibbons The hotspot-compiler label was already applied.

@mlbridge
Copy link

mlbridge bot commented Jun 26, 2021

Webrevs

@vnkozlov
Copy link
Contributor

@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

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

Choose a reason for hiding this comment

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

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

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

@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

Choose a reason for hiding this comment

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

Testing passed.

You need second review.

@openjdk
Copy link

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 Pull request is ready to be integrated label Jun 29, 2021
@asgibbons
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Jul 2, 2021
@openjdk
Copy link

openjdk bot commented Jul 2, 2021

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

@openjdk openjdk bot removed the sponsor Pull request is ready to be sponsored label Jul 10, 2021
@asgibbons
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Jul 10, 2021
@openjdk
Copy link

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 Pull request is ready to be sponsored label Jul 13, 2021
@asgibbons
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Jul 13, 2021
@openjdk
Copy link

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 commented Jul 13, 2021

The patch looks good to me.

@sviswa7
Copy link

sviswa7 commented Jul 13, 2021

/sponsor

@openjdk
Copy link

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 Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Jul 13, 2021
@openjdk
Copy link

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 July 13, 2021 23:56
@asgibbons
Copy link
Contributor Author

/backport jdk17u-dev

@openjdk
Copy link

openjdk bot commented Nov 10, 2022

@asgibbons Only OpenJDK contributors can use the /backport command

@sviswa7
Copy link

sviswa7 commented Nov 10, 2022

/backport jdk17u-dev

@openjdk
Copy link

openjdk bot commented Nov 10, 2022

@sviswa7 the backport was successfully created on the branch sviswa7-backport-9cac94d5 in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 9cac94d5 from the openjdk/jdk repository.

The commit being backported was authored by Scott Gibbons on 13 Jul 2021 and was reviewed by Vladimir Kozlov and Sandhya Viswanathan.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev sviswa7-backport-9cac94d5:sviswa7-backport-9cac94d5
$ git checkout sviswa7-backport-9cac94d5
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev sviswa7-backport-9cac94d5

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
Development

Successfully merging this pull request may close these issues.

None yet

4 participants