RFR: JDK-8316991: Reduce nullable allocation merges
Cesar Soares Lucas
cslucas at openjdk.org
Mon Oct 16 23:24:24 UTC 2023
On Mon, 16 Oct 2023 09:32:40 GMT, Tobias Hartmann <thartmann at openjdk.org> wrote:
>> ### Description
>>
>> Many, if not most, allocation merges (Phis) are nullable because they join object allocations with "NULL", or objects returned from method calls, etc. Please review this Pull Request that improves Reduce Allocation Merge implementation so that it can reduce at least some of these allocation merges.
>>
>> Overall, the improvements are related to 1) making rematerialization of merges able to represent "NULL" objects, and 2) being able to reduce merges used by CmpP/N and CastPP.
>>
>> The approach to reducing CmpP/N and CastPP is pretty similar to that used in the `MemNode::split_through_phi` method: a clone of the node being split is added on each input of the Phi. I make use of `optimize_ptr_compare` and some type information to remove redundant CmpP and CastPP nodes. I added a bunch of ASCII diagrams illustrating what some of the more important methods are doing.
>>
>> ### Benchmarking
>>
>> **Note:** In some of these tests no reduction happens. I left them in to validate that no perf. regression happens in that case.
>> **Note 2:** Marging of error was negligible.
>>
>> | Benchmark | No RAM (ms/op) | Yes RAM (ms/op) |
>> |--------------------------------------|------------------|-------------------|
>> | TestTrapAfterMerge | 19.515 | 13.386 |
>> | TestArgEscape | 33.165 | 33.254 |
>> | TestCallTwoSide | 70.547 | 69.427 |
>> | TestCmpAfterMerge | 16.400 | 2.984 |
>> | TestCmpMergeWithNull_Second | 27.204 | 27.293 |
>> | TestCmpMergeWithNull | 8.248 | 4.920 |
>> | TestCondAfterMergeWithAllocate | 12.890 | 5.252 |
>> | TestCondAfterMergeWithNull | 6.265 | 5.078 |
>> | TestCondLoadAfterMerge | 12.713 | 5.163 |
>> | TestConsecutiveSimpleMerge | 30.863 | 4.068 |
>> | TestDoubleIfElseMerge | 16.069 | 2.444 |
>> | TestEscapeInCallAfterMerge | 23.111 | 22.924 |
>> | TestGlobalEscape | 14.459 | 14.425 |
>> | TestIfElseInLoop | 246.061 | 42.786 |
>> | TestLoadAfterLoopAlias | 45.808 | 45.812 |
>> ...
>
> I'm still seeing the following failures:
>
>
> # A fatal error has been detected by the Java Runtime Environment:
> #
> # Internal Error (/workspace/open/src/hotspot/share/opto/escape.cpp:1299), pid=1574160, tid=1574500
> # assert(false) failed: SafePointScalarMerge nodes can't be nested.
> #
> # JRE version: Java(TM) SE Runtime Environment (22.0) (fastdebug build 22-internal-2023-10-12-0503164.tobias.hartmann.jdk2)
> # Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 22-internal-2023-10-12-0503164.tobias.hartmann.jdk2, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-aarch64)
> # Problematic frame:
> # V [libjvm.so+0xab151c] ConnectionGraph::verify_ram_nodes(Compile*, Node*)+0x6e8
>
> Current CompileTask:
> C2:39141 8262 ! 4 akka.actor.ActorCell::invokeAll$1 (577 bytes)
>
> Stack: [0x0000fffea024c000,0x0000fffea044a000], sp=0x0000fffea0444d50, free space=2019k
> Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
> V [libjvm.so+0xab151c] ConnectionGraph::verify_ram_nodes(Compile*, Node*)+0x6e8 (escape.cpp:1299)
> V [libjvm.so+0x90d1e4] Compile::Optimize()+0x744 (compile.cpp:2336)
> V [libjvm.so+0x90f098] Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x1504 (compile.cpp:854)
> V [libjvm.so+0x75b12c] C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x10c (c2compiler.cpp:130)
> V [libjvm.so+0x91b124] CompileBroker::invoke_compiler_on_method(CompileTask*)+0x8e4 (compileBroker.cpp:2282)
> V [libjvm.so+0x91bc3c] CompileBroker::compiler_thread_loop()+0x5bc (compileBroker.cpp:1943)
> V [libjvm.so+0xdb4bc0] JavaThread::thread_main_inner()+0xec (javaThread.cpp:720)
> V [libjvm.so+0x1600764] Thread::call_run()+0xb0 (thread.cpp:220)
> V [libjvm.so+0x1368ff8] thread_native_entry(Thread*)+0x138 (os_linux.cpp:785)
> C [libc.so.6+0x82a28] start_thread+0x2d4
>
>
> # A fatal error has been detected by the Java Runtime Environment:
> #
> # Internal Error (/workspace/open/src/hotspot/share/opto/narrowptrnode.cpp:84), pid=3481386, tid=3481478
> # assert(t != TypeNarrowKlass::NULL_PTR) failed: null klass?
> #
> # JRE version: Java(TM) SE Runtime Environment (22.0) (fastdebug build 22-internal-2023-10-12-0503164.tobias.hartmann.jdk2)
> # Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 22-internal-2023-10-12-0503164.tobias.hartmann.jdk2, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
> # Problematic frame:
> # V [libjvm.so+0x140fcf4] DecodeNKlass...
Thank you again for running the tests @TobiHartmann
-------------
PR Comment: https://git.openjdk.org/jdk/pull/15825#issuecomment-1765416119
More information about the hotspot-dev
mailing list