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
8279833: Loop optimization issue in String.encodeUTF8_UTF16 #7026
Conversation
|
Webrevs
|
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 fine, consider touchups in benchmark code.
@cl4es This change now passes all automated pre-integration checks. 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 3 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
|
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.
A good find, hopefully it will be linked to the C2 issue.
This is the first change to both files in 2022 so you might have to update the copyright headers.
Thanks for reviewing, @shipilev and @AlanBateman /integrate |
Going to push as commit c3d0a94.
Your commit was automatically rebased without conflicts. |
Looks like there's one more similar case: #7034 |
In
String.encodeUTF8_UTF16
, making thechar c
local to each loop helps the performance of the method by helping C2 optimize each individual loop better.Results on the updated micros:
19-b04:
Patch:
Going back this seem to have been an issue since this method was introduced with JEP 254 in JDK 9:
8u311:
9:
(Interestingly JDK 9 seem faster on some of the micros than later iterations, while slower on others. The main issue is the slow non-ASCII loop, where the patch speeds things up ~2x. With the patch we're significantly faster than both JDK 8 and 9 on all measures.)
There's a JIT compiler bug hiding in plain sight here where the potentially uninitialized local
char c
appears to mess up optimization of the second loop. I'll file a separate bug for this (a standalone reproducer should be straightforward to produce). I think this patch is reasonable to put back into the JDK while we investigate if/how C2 can better handle this kind of condition. It might also be easier to backport, depending on whether the C2 fix is trivial or not.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/7026/head:pull/7026
$ git checkout pull/7026
Update a local copy of the PR:
$ git checkout pull/7026
$ git pull https://git.openjdk.java.net/jdk pull/7026/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 7026
View PR using the GUI difftool:
$ git pr show -t 7026
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/7026.diff