-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8297379: Enable the ByteBuffer path of Poly1305 optimizations #11338
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
Conversation
👋 Welcome back vpaprotsk! A progress list of the required criteria for merging this PR into |
@vpaprotsk The following label will be automatically applied to this pull request:
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. |
Webrevs
|
Please add a JMH micro showcasing gains, with heap allocated and native byte buffer (once you support it). |
processMultipleBlocks(input, offset, blockMultipleLength, aLimbs, rLimbs); | ||
} else { | ||
while (blockMultipleLength > 0) { | ||
processBlock(buf, BLOCK_LENGTH); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For native byte buffers, you can pass the buffer address and base.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spent some time thinking about this one.. Originally, (from the sample you shared) I thought I had to use Unsafe
, which I don't think is 'safe' to do in a crypto library. After some searching, I found a 'safe' alternative, sun.nio.ch.DirectBuffer
interface, which would give me the long address()
.
The problem is that the current java signature for the intrinsic expects a []byte
not a long. I could certainly change the existing intrinsic (or more likely add a new instrinsic calling existing stub assembly).
I would lean towards not supporting Direct Byte buffers right now. (Also, it doesn't seem like other crypto intrinsics do either. At least GCM does not..)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JMH also added (and main PR comment modified to match)
private void processMultipleBlocks(ByteBuffer buf, int blockMultipleLength) { | ||
if (buf.hasArray()) { | ||
byte[] input = buf.array(); | ||
int offset = buf.arrayOffset(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arrayOffset returns the offset of the first element of the backing buffer. Need to also take into account the position() of the buffer here. We should also add test case for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this!! Fixed the mainline to handle position(). I have now reworked the test case quite a bit.
The PR looks good to me. |
@vpaprotsk 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:
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 18 new commits pushed to the
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 (@sviswa7, @ascarpino, @jnimeh) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
@valeriepeng Could you please take a look at this PR? |
@sviswa7 I will be looking at this today |
The changes look ok to me |
(The build failures do not look related to this PR, trying to see if fixed in main branch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look fine. tier1-5 + hs-precheckin-comp test jobs came back clean with the exception of two jaxp failures only on linux-x64 but they don't appear to be related to your changes.
/integrate |
@vpaprotsk |
/sponsor |
Going to push as commit 203251f.
Your commit was automatically rebased without conflicts. |
@sviswa7 @vpaprotsk Pushed as commit 203251f. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
There is now an intrinsic for Poly1305, which is only enabled on the
engineUpdate([]byte)
path. This PR adds intrinsic supportengineUpdate(ByteBuffer)
(when the bytebufferhasArray
).Fuzzing test expanded to also include ByteBuffer payloads.
Performance is now matched:
Relates to:
[]byte
andByteBuffer
. When that one is fixed,Poly1305IntrinsicFuzzTest.java
should not be setting the endianness on theByteBuffer
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/11338/head:pull/11338
$ git checkout pull/11338
Update a local copy of the PR:
$ git checkout pull/11338
$ git pull https://git.openjdk.org/jdk pull/11338/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 11338
View PR using the GUI difftool:
$ git pr show -t 11338
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/11338.diff