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

Roland Westrelin roland at openjdk.org
Tue Jul 11 14:21:14 UTC 2023


On Fri, 30 Jun 2023 17:28:03 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:

>> 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.
>
> src/hotspot/share/opto/loopopts.cpp line 1704:
> 
>> 1702:                   cast = prev;
>> 1703:                 } else {
>> 1704:                   register_new_node(cast, x_ctrl);
> 
> 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`?

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?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14732#discussion_r1259809938


More information about the hotspot-compiler-dev mailing list