-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
8308103: Massive (up to ~30x) increase in C2 compilation time since JDK 17 #14732
Conversation
👋 Welcome back roland! A progress list of the required criteria for merging this PR into |
Webrevs
|
cast->destruct(&_igvn); | ||
cast = prev; | ||
} else { | ||
register_new_node(cast, x_ctrl); |
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.
Can you move creation of cast
here so you don't need to destroy it in case of previous cast existance?
Or it is possible that ConstraintCastNode::make_cast_for_type() can return
null`?
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 looking at this, Vladimir.
I'm not sure I understand what you're suggesting. Is it to not allocate a new node so it doesn't have to be destroyed if an identical node exist? But without a node it's not possible to rely on IGVN hashing?
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.
You are right. Using hash to look for existing node is smart.
* @test | ||
* @bug 8308103 | ||
* @summary Massive (up to ~30x) increase in C2 compilation time since JDK 17 | ||
* @run main/othervm -Xcomp -XX:CompileOnly=TestSinkingNodesCausesLongCompilation::mainTest -XX:RepeatCompilation=30 TestSinkingNodesCausesLongCompilation |
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.
You should add -XX:+UnlockDiagnosticVMOptions
since RepeatCompilation
is diagnostic.
|
||
public static void main(String[] strArr) { | ||
TestSinkingNodesCausesLongCompilation _instance = new TestSinkingNodesCausesLongCompilation(); | ||
for (int i = 0; i < 10; i++ ) { |
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 (int i = 0; i < 10; i++ ) { | |
for (int i = 0; i < 10; i++) { |
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 the comments. I updated the change.
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.
Good.
@rwestrel 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 84 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 |
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 fix looks good to me but I still have a hard time to comprehend that this leads to a 30x increase in compilation time. And I'm worried that we have similar issues in other code. As a follow-up, could we have PhaseIdealLoop::register_new_node
check the hash and return an existing node?
There's an exponential increase of the number of casts that are created. First node to be sunk is:
It has 3 uses so 3 casts are created:
Next:
(input of previous one)
next:
input of previous one. Same as step before, 3 just created casts are moved and new ones created:
next:
which was input to both 384 and 385 just sunk. It has 6 uses. The 3 casts above and 3 clones of 385.
The same sequence of nodes repeats and every 3 nodes there's a RShiftI and the number of clones double. At the last step, the number of casts is 12288. That happens after 39 nodes are sunk. All of this seems pretty specific to that transformation so a local fix seems good enough to me. |
Makes sense. Thanks for the details, Roland. |
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 good to me, too!
@vnkozlov @TobiHartmann @chhagedorn thanks for the reviews. |
/integrate |
Going to push as commit c6ab9c2.
Your commit was automatically rebased without conflicts. |
A long chain of nodes are sunk out of a loop. Every time a node is
moved out of the loop, a cast is created to pin the node out of the
loop. When its input is next sunk, the cast is removed (the cast is
replaced by its input) and a new cast is created. Some nodes on the
chain have 2 other nodes in the chain as uses. When such a node is
sunk, 2 cast nodes are created, one for each use. So as the compiler
moves forward in the chain, the number of cast to remove grows. From
some profiling, removing those casts is what takes a lot of time.
The fix I propose is, when a node is processed, to check whether a
cast at the out of loop control was already created for that node and
to reuse it.
The test case takes 6 minutes when I run it without the fix and 3
seconds with it.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/14732/head:pull/14732
$ git checkout pull/14732
Update a local copy of the PR:
$ git checkout pull/14732
$ git pull https://git.openjdk.org/jdk.git pull/14732/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 14732
View PR using the GUI difftool:
$ git pr show -t 14732
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/14732.diff
Webrev
Link to Webrev Comment