-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8345120: A likely bug in StringSupport::chunkedStrlenShort #22451
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 pminborg! A progress list of the required criteria for merging this PR into |
@minborg 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 4 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
Webrevs
|
src/java.base/share/classes/jdk/internal/foreign/SegmentBulkOperations.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/jdk/internal/foreign/SegmentBulkOperations.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/jdk/internal/foreign/StringSupport.java
Outdated
Show resolved
Hide resolved
if (curr == 0) { | ||
return offset; | ||
@ForceInline | ||
public static int strlenByte(final AbstractMemorySegmentImpl segment, |
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.
Note: clients of this method seems to always pass segment.byteSize()
for toOffset
. What is the value of passing it as an explicit parameter instead of having byteSize()
being called inside the method?
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 this is an internal API, I tried to keep it as similar as possible to the other bulk operations. But as you say, the value used here for the last parameter is always segment.byteSize()
. We could easily change it. What's your preference here?
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.
If the method works correctly on all end offsets (even when the offset is different from the segment size), then I'm ok leaving it as is. I'm mostly trying to make sure that endOffset = size is not an hidden invariant we depend on.
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've added a test for the end offset.
src/java.base/share/classes/jdk/internal/foreign/StringSupport.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/jdk/internal/foreign/SegmentBulkOperations.java
Show resolved
Hide resolved
@TheRealMDoerr and @offamitkumar ; Could you take a look at this and make sure it works using BE? |
Thanks for the notification. The java/foreign suite has passed on linux on Power (Big and Little Endian) as well as on AIX (Big Endian). I can run more tests over night if needed. |
I ran tier1 on s390x, didn't see any regression. |
Thanks, @TheRealMDoerr and @offamitkumar, for testing on BE machines. |
for (var charset : standardCharsets()) { | ||
for (var arena: arenas()) { | ||
try (arena) { | ||
MemorySegment strSegment = arena.allocateFrom(testString, charset); |
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.
This could just use String::getBytes ? E.g. you don't really need the strSegment
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.
True. But then again, I do not need the byte array either.
/integrate |
Going to push as commit 8dada73.
Your commit was automatically rebased without conflicts. |
This PR proposes to rewrite the
StringSupport::chunkedStrlen*
methods, fixing a bug in theshort_strlen
variant for odd offsets (offset % 2 != 0
).This PR also improves performance on modern hardware, as there is no need for pre-looping alignment. Removing this improves performance by about 30% for larger strings.
It passes the
jdk_foreign
test suit. Also,tier1
throughtier3
passes on various platforms and configurations.Base:
Patch:
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/22451/head:pull/22451
$ git checkout pull/22451
Update a local copy of the PR:
$ git checkout pull/22451
$ git pull https://git.openjdk.org/jdk.git pull/22451/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 22451
View PR using the GUI difftool:
$ git pr show -t 22451
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/22451.diff
Using Webrev
Link to Webrev Comment