RFR: 8340602: C2: LoadNode::split_through_phi might exhaust nodes in case of base_is_phi [v4]
Christian Hagedorn
chagedorn at openjdk.org
Mon Sep 30 06:48:38 UTC 2024
On Fri, 27 Sep 2024 02:47:03 GMT, Daohan Qu <dqu at openjdk.org> wrote:
>> # Description
>>
>> [JDK-6934604](https://github.com/openjdk/jdk/commit/b4977e887a53c898b96a7d37a3bf94742c7cc194) introduces the flag `AggressiveUnboxing` in jdk8u, and [JDK-8217919](https://github.com/openjdk/jdk/commit/71759e3177fcd6926bb36a30a26f9f3976f2aae8) enables it by default in jdk13u.
>>
>> But it seems that JDK-6934604 forgets to check duplicate `PhiNode` generated in the function `LoadNode::split_through_phi(PhaseGVN *phase)` (in `memnode.cpp`) in the case that `base` is phi but `mem` is not phi. More exactly, `LoadNode::Identity(PhaseTransform *phase)` doesn't search for `PhiNode` in the correct region in that case.
>>
>> This might cause infinite split in the case of a loop, which is similar to the bugs fixed in [JDK-6673473](https://github.com/openjdk/jdk/commit/30dc0edfc877000c0ae20384f228b45ba82807b7). The infinite split results in "Out of nodes" and make the method "not compilable".
>>
>> Since JDK-8217919 (in jdk13u), all the later versions of jdks are affected by this bug when the expected optimization pattern appears in the code. For example, the following three micro-benchmarks running with
>>
>>
>> make test \
>> TEST="micro:org.openjdk.bench.java.util.stream.tasks.IntegerMax.Bulk.bulk_seq_inner micro:org.openjdk.bench.java.util.stream.tasks.IntegerMax.Lambda.bulk_seq_lambda micro:org.openjdk.bench.java.util.stream.tasks.IntegerMax.Lambda.bulk_seq_methodRef" \
>> MICRO="FORK=1;WARMUP_ITER=2" \
>> TEST_OPTS="VM_OPTIONS=-XX:+UseParallelGC"
>>
>>
>> shows performance improvement after this PR applied. (`-XX:+UseParallelGC` is only for reproduce this bug, all the bms in the following table are run with this option.)
>>
>> |benchmark (throughput, unit: ops/s)| jdk-before-this-patch | jdk-after-this-patch |
>> |---|---|---|
>> |org.openjdk.bench.java.util.stream.tasks.IntegerMax.Bulk.bulk_seq_inner | 26.452 ±(99.9%) 0.185 ops/s | 62.060 ±(99.9%) 0.878 ops/s |
>> |org.openjdk.bench.java.util.stream.tasks.IntegerMax.Lambda.bulk_seq_lambda | 26.922 ±(99.9%) 1.710 ops/s | 67.961 ±(99.9%) 0.850 ops/s |
>> |org.openjdk.bench.java.util.stream.tasks.IntegerMax.Lambda.bulk_seq_methodRef | 28.382 ±(99.9%) 1.021 ops/s | 67.998 ±(99.9%) 0.751 ops/s |
>>
>> # Reproduction
>>
>> Compiled and run the reduced test case `Test.java` in the appendix below using
>>
>>
>> java -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:+LogCompilation -XX:LogFile=comp.log -XX:+UseParallelGC Test
>>
>>
>> and you could find that `Test$Obj.calc` is tagged with `make_not_compilable` and...
>
> Daohan Qu has updated the pull request incrementally with one additional commit since the last revision:
>
> Add jtreg requirements and fix some format issues
Thanks for the updated description! I will have a closer look at it later this week. I gave your patch a spinning in our testing over the weekend and found some timeouts for tests `compiler/eliminateAutobox/Test*Boxing.java` with various flag combos.
For example, `compiler/eliminateAutobox/TestIntBoxing.java` on linux-aarch64-debug with `-ea -esa -XX:CompileThreshold=100 -XX:+UnlockExperimentalVMOptions -server -XX:-TieredCompilation` is stuck in `phi_or_self()`. Here is the stacktrace at the timeout:
Thread 15 (Thread 0xffff95e001d0 (LWP 2990058)):
#0 0x0000ffffb9b13130 in LoadNode::phi_or_self(PhaseGVN*) () from /opt/mach5/mesos/work_dir/jib-master/install/2024-09-27-2011498.christian.hagedorn.jdk-test/linux-aarch64-debug.jdk/jdk-24/fastdebug/lib/server/libjvm.so
#1 0x0000ffffb9b1db4c in LoadNode::split_through_phi(PhaseGVN*, bool) () from /opt/mach5/mesos/work_dir/jib-master/install/2024-09-27-2011498.christian.hagedorn.jdk-test/linux-aarch64-debug.jdk/jdk-24/fastdebug/lib/server/libjvm.so
#2 0x0000ffffb9b27ea8 in LoadNode::Ideal(PhaseGVN*, bool) () from /opt/mach5/mesos/work_dir/jib-master/install/2024-09-27-2011498.christian.hagedorn.jdk-test/linux-aarch64-debug.jdk/jdk-24/fastdebug/lib/server/libjvm.so
#3 0x0000ffffb9cc3d2c in PhaseIterGVN::transform_old(Node*) () from /opt/mach5/mesos/work_dir/jib-master/install/2024-09-27-2011498.christian.hagedorn.jdk-test/linux-aarch64-debug.jdk/jdk-24/fastdebug/lib/server/libjvm.so
#4 0x0000ffffb9cba950 in PhaseIterGVN::optimize() () from /opt/mach5/mesos/work_dir/jib-master/install/2024-09-27-2011498.christian.hagedorn.jdk-test/linux-aarch64-debug.jdk/jdk-24/fastdebug/lib/server/libjvm.so
#5 0x0000ffffb9204364 in Compile::Optimize() () from /opt/mach5/mesos/work_dir/jib-master/install/2024-09-27-2011498.christian.hagedorn.jdk-test/linux-aarch64-debug.jdk/jdk-24/fastdebug/lib/server/libjvm.so
#6 0x0000ffffb9207504 in Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*) () from /opt/mach5/mesos/work_dir/jib-master/install/2024-09-27-2011498.christian.hagedorn.jdk-test/linux-aarch64-debug.jdk/jdk-24/fastdebug/lib/server/libjvm.so
....
Can also be observed on other platforms like linux-x64-debug or Windows.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/21134#issuecomment-2382244739
More information about the hotspot-compiler-dev
mailing list