RFR: 8308103: Massive (up to ~30x) increase in C2 compilation time since JDK 17

Roland Westrelin roland at openjdk.org
Thu Jul 13 15:45:02 UTC 2023


On Wed, 12 Jul 2023 05:25:46 GMT, Tobias Hartmann <thartmann at openjdk.org> wrote:

> 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:

  386  RShiftI  === _ 385 316  [[ 441 417 429 ]]  !orig=[615] !jvms: TestSinkingNodesCausesLongCompilation::mainTest @ bci:104 (line 46)                                                                                                                                          
 ```
It has 3 uses so 3 casts are created:

 1137  CastII  === 426 385  [[ ]]  #int unconditional dependency                                                                                                                                                                                                                  
 1139  CastII  === 414 385  [[ ]]  #int unconditional dependency                                                                                                                                                                                                                  
 1141  CastII  === 438 385  [[ ]]  #int unconditional dependency     


Next:
```  
385  AddI  === _ 384 605  [[ 1141 1137 1139 ]]  !jvms: TestSinkingNodesCausesLongCompilation::mainTest @ bci:99 (line 45)

(input of previous one)
The 3 previous casts are removed and new ones are created:

 1143  CastII  === 414 384  [[ ]]  #int unconditional dependency                                                                                                                                                                                                                  
 1145  CastII  === 426 384  [[ ]]  #int unconditional dependency                                                                                                                                                                                                                  
 1147  CastII  === 438 384  [[ ]]  #int unconditional dependency              


next:

  384  LShiftI  === _ 605 383  [[ 1147 1143 1145 ]]  !jvms: TestSinkingNodesCausesLongCompilation::mainTest @ bci:99 (line 45) 

input of previous one. Same as step before, 3 just created casts are moved and new ones created:

 1149  CastII  === 426 605  [[ ]]  #int unconditional dependency                                                                                                                                                                                                                  
 1151  CastII  === 414 605  [[ ]]  #int unconditional dependency                                                                                                                                                                                                                  
 1153  CastII  === 438 605  [[ ]]  #int unconditional dependency                


next:

  605  RShiftI  === _ 606 316  [[ 1146 1153 1142 1144 1149 1151 ]]  !orig=[386],[615] !jvms: TestSinkingNodesCausesLongCompilation::mainTest @ bci:104 (line 46)

which was input to both 384 and 385 just sunk. It has 6 uses. The 3 casts above and 3 clones of 385.
So 3 casts are removed and 6 casts are created:

 1155  CastII  === 414 606  [[ ]]  #int unconditional dependency                                                                                                                                                                                                                  
 1157  CastII  === 426 606  [[ ]]  #int unconditional dependency                                                                                                                                                                                                                  
 1159  CastII  === 426 606  [[ ]]  #int unconditional dependency                                                                                                                                                                                                                  
 1161  CastII  === 414 606  [[ ]]  #int unconditional dependency                                                                                                                                                                                                                  
 1163  CastII  === 438 606  [[ ]]  #int unconditional dependency                                                                                                                                                                                                                  
 1165  CastII  === 438 606  [[ ]]  #int unconditional dependency                                                                                                                                                                                                                  

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.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/14732#issuecomment-1634476079


More information about the hotspot-compiler-dev mailing list