RFR: 8273585: String.charAt performance degrades due to JDK-8268698 [v2]

Roland Westrelin roland at openjdk.java.net
Tue Oct 26 11:47:17 UTC 2021


On Tue, 26 Oct 2021 02:14:42 GMT, Yi Yang <yyang at openjdk.org> wrote:

>> String.charAt shows significant performance regression due to [JDK-8268698](https://bugs.openjdk.java.net/browse/JDK-8268698), which replaces index bound checking with Preconditions.checkIndex intrinsic method.
>> 
>> The result of "time linux-x86_64-server-release/images/jdk/bin/java Test":
>> 
>> 
>> Before JDK-8268698
>>     real 0m8.369s
>>     user 0m8.386s
>>     sys 0m0.019s
>> 
>> After JDK-8268698,
>>     real 0m19.722s
>>     user 0m19.748s
>>     sys 0m0.013s
>> 
>> 
>> The reason is Preconditions.checkIndex generates a CastII for index node as index is now known to be >= 0 and < length.:
>> 
>> https://github.com/openjdk/jdk/blob/5dab76b939e381312ce5c89b9aebca628238a387/src/hotspot/share/opto/library_call.cpp#L1077-L1083
>> 
>> CastII can not be recognized as a parallel induction variable because AddNode's input must be the PhiNode:
>> 
>> https://github.com/openjdk/jdk/blob/5dab76b939e381312ce5c89b9aebca628238a387/src/hotspot/share/opto/loopnode.cpp#L3177-L3184
>> 
>> It seems this prevents further loop unrolling. I think we can relax this constraint, i.e CastII can be the input of AddNode if its input is PhiNode. After applying this patch, performance regression disappears:
>> 
>> 
>> $time ./test.sh 
>> 
>> real    0m9.514s
>> user    0m10.310s
>> sys     0m0.155s
>> 
>> This is likely the reason for [JDK-8272493](https://bugs.openjdk.java.net/browse/JDK-8272493). Please help review it. Thanks!
>
> Yi Yang has updated the pull request incrementally with one additional commit since the last revision:
> 
>   use uncast

Looks good to me.

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

Marked as reviewed by roland (Reviewer).

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


More information about the hotspot-compiler-dev mailing list