-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8320448: Accelerate IndexOf using AVX2 #16753
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 sgibbons! A progress list of the required criteria for merging this PR into |
|
@asgibbons this pull request can not be integrated into git checkout indexof
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push |
|
@asgibbons The following labels 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 lists. If you would like to change these labels, use the /label pull request command. |
|
Opening up for review. Fixed last whitespace error. I will post final performance numbers soon. |
|
@eme64 I'm glad to have received your feedback. I see I have erroneously assumed that by making the exact code change you requested still requires your acceptance - I won't make that mistake again. I had also erroneously assumed that your review was complete and you had no further changes for me to make. I'd also not like to make that mistake again, but I'm unsure how to conclude that a review is complete - it seems like 7 hours of elapsed time isn't sufficient to indicate completion, so can you please help me figure this out? Perhaps it's just my distaste for "trickle-in" comments, which I should get over, or is there another way you can suggest? As for the fuzzer I would be very interested in learning more about this. We have a significant number of compute resources, so it may be valuable for us to set up a copy of the fuzzer on-site to improve the quality of our submissions. Can you help in pointing me to someone that can advise me on how to do this? As for holding off the integration, I'll leave the decision to a sponsor for this PR. I don't believe increasing the reviewer count just to "force" reevaluation should be an acceptable practice, although I'm not an insider in this community. |
|
@eme64 I guess to add some confidence.. we did also 'test it independently' to catch blind spots. i.e. |
|
@asgibbons I was done with my review, or at least so I thought 😉 Often I only see the glaring issues. Then you fix them, and then I see something else around it. Then I may give more comments. That is what happened. If I think that I have small suggestions and then I'm done, then I might even approve even though there are suggestions still to be added. I just put up the limit really quick so that nobody else would by accident sponsor it before we have finished the conversation, and I will definitely give you my approval once the little issues are resolved ;) |
|
About the fuzzer: we have it in our closed tests. But I think it comes from this: https://github.com/shipilev/JavaFuzzer |
| */ | ||
|
|
||
| /* @test | ||
| * @bug 4162796 4162796 8320448 |
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.
| * @bug 4162796 4162796 8320448 | |
| * @bug 8320448 |
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.
As I said above: I never add old bug numbers to new tests. But here it is even duplicated ;)
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.
The file I used as baseline for this test/jdk/java/lang/StringBuffer/IndexOf.java has the bug number listed twice (copy/paste). I'll remove it from here, but leave it in the original unless requested to change it.
| */ | ||
|
|
||
| /* @test | ||
| * @bug 4162796 4162796 8320448 |
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.
| * @bug 4162796 4162796 8320448 | |
| * @bug 8320448 |
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.
Fixed.
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.
Ok, now it is good for me. But I would definately wait with integration for after the fork next week.
| @@ -0,0 +1,1837 @@ | |||
| /* | |||
| * Copyright (c) 2023, 2024 Intel Corporation. All rights reserved. | |||
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.
Is the 2023 year intentional? I don't know your policy, so you can just ignore 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.
I started this in November :-)
| // and <= 32 bytes for small. The switches implement optimized code for handling 1 to | ||
| // NUMBER_OF_CASES (currently 10) needle sizes for both big and small. There are special | ||
| // routines for handling needle sizes > NUMBER_OF_CASES (L_{big,small}CaseDefault). These | ||
| // cases use C@'s arrays_equals() to compare the needle to the haystack. The small cases |
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.
| // cases use C@'s arrays_equals() to compare the needle to the haystack. The small cases | |
| // cases use C2's arrays_equals() to compare the needle to the haystack. The small cases |
Randomly spotted 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.
Fixed.
| // cmp nndx, ndlLen | ||
| // jae done | ||
| // | ||
| // Final index of start of needle @((16 - (ndlLen %16)) & 0xf) << 1 |
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.
What is the meaning of the @? Maybe at. I'd use the same consistently
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.
Changed to "at".
|
I agree with @eme64 to postpone the integration after JDK 23 is forked in one week. It is not about how you confident with code. It is size of code. I did only limited (tier1-4) testing in our infra which did not cover all our testing configuration. |
|
@vnkozlov OK. I'll defer to you all. I've contacted the author of the fuzzer to see what I can do to set up a local instance. Would this be sufficient to increase confidence for future submissions? We can run it perpetually on fixes (provided I can set it up). Had I done that, we could have had 6 months of fuzzing on top of our tests. Would that have alleviated this concern? |
|
@asgibbons I generally just stop pushing ANY RFE's a week or two before the fork. Even if you did run the fuzzer with it - there are often last-minute changes. And your code here is rather large, so even if you are confident, there must be at least one bug hiding. Running the fuzzer is nice as pre-integration, but it mostly only catches things post-integration. |
|
Hi, everyone. I see that JDK 23 has now been forked, and new commits go into the JDK 24 branch. I would like to get this in as soon as possible to have as much time with fuzzers, etc. for everyone to be confident in the code. I have 3 positive reviews on this PR and would like to integrate. Please reply as soon as you reasonably can with objections or approval and I will integrate. Thanks. |
|
Let me do quick testing with latest mainline (JDK 24 now). |
|
@asgibbons, my testing almost finished. No new failures. I think this can be pushed now. Thank you for waiting! |
|
@eme64 Are you OK with me integrating? |
|
@asgibbons yes, ship it! 🚢 |
|
/integrate |
|
@asgibbons |
|
/sponsor |
|
Going to push as commit 8e72d7c.
Your commit was automatically rebased without conflicts. |
|
@jatin-bhateja @asgibbons Pushed as commit 8e72d7c. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |

Re-write the IndexOf code without the use of the pcmpestri instruction, only using AVX2 instructions. This change accelerates String.IndexOf on average 1.3x for AVX2. The benchmark numbers:
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/16753/head:pull/16753$ git checkout pull/16753Update a local copy of the PR:
$ git checkout pull/16753$ git pull https://git.openjdk.org/jdk.git pull/16753/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 16753View PR using the GUI difftool:
$ git pr show -t 16753Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/16753.diff
Webrev
Link to Webrev Comment