RFR: 8278518: String(byte[], int, int, Charset) constructor and String.translateEscapes() miss bounds check elimination [v2]

Vladimir Kozlov kvn at openjdk.java.net
Thu Jan 13 00:36:23 UTC 2022


On Wed, 12 Jan 2022 10:22:53 GMT, Roland Westrelin <roland at openjdk.org> wrote:

>> In the micro benchmark for this bug, the bytecode has a single loop
>> head with 2 backedges. One branch is taken a lot more frequently than
>> the other (for instance, profiling reports 3820938 for the most
>> common, 134068 for the least common). When ciTypeFlow builds its loop
>> tree, the least common loop ends up as the inner loop (ciTypeFlow uses
>> the tail block number to order loops with a shared header). Then
>> ciTypeFlow clones the inner loop head.
>> 
>> The results I get then is:
>> 
>> StringBenchmark.safeDecoding    avgt    5  141.965 ± 53.511  ns/op
>> StringBenchmark.unsafeDecoding  avgt    5  123.051 ± 77.855  ns/op
>> 
>> The unsafe version uses unsafe instead of standard array accesses. The
>> reason for the unsafe version is to demonstrate that a missed range
>> check elimination in the common path hurts performance (the range
>> check is not performed on the loop iv but another phi so can't be
>> eliminated).
>> 
>> The patch I propose takes back branch count (from profile data) into
>> account when building the ciTypeFlow tree. As a consequence, the inner
>> loop (the one for which the loop head is cloned), is the most most
>> frequent one. The range check in the common path is also hoisted in
>> that case (it's now performed on the iv). Running the micro benchmark
>> again, I get:
>> 
>> StringBenchmark.safeDecoding    avgt    5  53.368 ± 2.232  ns/op
>> StringBenchmark.unsafeDecoding  avgt    5  55.565 ± 5.124  ns/op
>> 
>> Both are improved (2-3x) and the unsafe version doesn't perform better.
>
> Roland Westrelin has updated the pull request incrementally with one additional commit since the last revision:
> 
>   review

I run testing and in tier3 our `Kitchensink` closed testing failed:

#  Internal Error (/workspace/open/src/hotspot/share/ci/ciTypeFlow.cpp:2497), pid=15398, tid=15431
#  Error: ShouldNotReachHere()

Stack: [0x00007fd0fcf68000,0x00007fd0fd069000],  sp=0x00007fd0fd0657e0,  free space=1013k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x9cc2e7]  profiled_count(ciMethod*, ciTypeFlow::Loop*)+0x537
V  [libjvm.so+0x9cc4dd]  ciTypeFlow::Loop::sorted_merge(ciTypeFlow::Loop*, ciMethod*)+0x4d
V  [libjvm.so+0x9cff00]  ciTypeFlow::build_loop_tree(ciTypeFlow::Block*)+0x1c0
V  [libjvm.so+0x9d1b32]  ciTypeFlow::df_flow_types(ciTypeFlow::Block*, bool, ciTypeFlow::StateVector*, ciTypeFlow::JsrSet*)+0x632
V  [libjvm.so+0x9d208e]  ciTypeFlow::flow_types()+0x41e
V  [libjvm.so+0x9d2bb6]  ciTypeFlow::do_flow()+0x26
V  [libjvm.so+0x965b24]  ciMethod::get_flow_analysis()+0x64
V  [libjvm.so+0x7473ae]  InlineTree::check_can_parse(ciMethod*)+0xee
V  [libjvm.so+0x8b7579]  CallGenerator::for_inline(ciMethod*, float)+0x19
V  [libjvm.so+0xa999d4]  Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x12e4

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

PR: https://git.openjdk.java.net/jdk/pull/7034


More information about the hotspot-compiler-dev mailing list