RFR: 8273585: String.charAt performance degrades due to JDK-8268698 [v2]
Yi Yang
yyang at openjdk.java.net
Tue Oct 26 02:14:42 UTC 2021
> 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
-------------
Changes:
- all: https://git.openjdk.java.net/jdk/pull/6096/files
- new: https://git.openjdk.java.net/jdk/pull/6096/files/8029f673..992906df
Webrevs:
- full: https://webrevs.openjdk.java.net/?repo=jdk&pr=6096&range=01
- incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=6096&range=00-01
Stats: 11 lines in 1 file changed: 1 ins; 9 del; 1 mod
Patch: https://git.openjdk.java.net/jdk/pull/6096.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/6096/head:pull/6096
PR: https://git.openjdk.java.net/jdk/pull/6096
More information about the hotspot-compiler-dev
mailing list