-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8302163: Speed up various String comparison methods with ArraysSupport.mismatch #12528
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
…ome minor improvements to String::regionMatches
|
👋 Welcome back redestad! A progress list of the required criteria for merging this PR into |
|
Microbenchmarking shows decent improvements on small data, scaling up to some impressive gains on large inputs when vectorization kicks in (~41x on regionMatches for size = 1024 on my x64 sandybridge setup, ~34x on m1 in the same config) macosx-aarch64, m1, 21-b9: macosx-aarch64. m1, patched: linux-x64 sandybridge, 21-b9: linux-x64 sandybridge, patched: |
Webrevs
|
|
Amazing gains! |
|
|
stsypanov
left a comment
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.
Looks simple and harmless.
RogerRiggs
left a comment
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.
Look good.
|
@cl4es 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 92 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. ➡️ To integrate this PR with the above commit message to the |
| } | ||
| toffset <<= coder; | ||
| return ArraysSupport.mismatch(ta, toffset, | ||
| pa, 0, pc) < 0; |
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.
offset <<= coder is only obvious if the reader knows the value of LATIN1, maybe it would be simpler to read if you kept "int to"?
|
Case-insensitive regionMatches could be improved by using ArraysSupport.mismatch to skip over long common substrings: PR: Arrays.mismatch: Patch on top of your PR: |
I considered this but saw regressions similar to what you're getting for size = 6 and backed off. I think this might be a good future enhancement, with some care, but didn't want to encumber this RFE with a case that regresses small inputs (which tend to be more common in actual applications). In similar constructs we have avoided doing the vectorized call in a loop since this could regress worst case inputs severely (an adversary example might be something like |
|
Thanks for reviewing! /integrate |
|
Going to push as commit 861e302.
Your commit was automatically rebased without conflicts. |
We can improve various String methods such as
startsWith,endsWithandregionMatchesby leveraging the intrinsified mismatch methods inArraysSupport.Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/12528/head:pull/12528$ git checkout pull/12528Update a local copy of the PR:
$ git checkout pull/12528$ git pull https://git.openjdk.org/jdk pull/12528/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 12528View PR using the GUI difftool:
$ git pr show -t 12528Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/12528.diff