On Fri, 2 Feb 2024 20:53:14 GMT, Claes Redestad <redes...@openjdk.org> wrote:
>> This patch streamlines and specializes various `String::indexOf` methods. >> Mainly avoids the need for clamping and doing checks that are redundant in >> almost all cases, moving the checks to the API boundary where they are >> needed. >> >> This improves performance both at peak and during startup/warmup. Since >> indexOf is heavily used in bootstrapping code it makes sense to slightly >> dial back abstraction and delegation, which in this case also brought some >> benefit to peak performance. >> >> Testing: tier1-3 > > Claes Redestad has updated the pull request incrementally with one additional > commit since the last revision: > > Add comment about preconditions Updated to clamp `fromIndex` to `value.length >> coder` since the intrinsic might silently deoptimize if passed a `fromIndex` value that's out of bounds. This correctness fix dials back the speed-up on some of the `indexOf(c, offset)` micros, but not by much: Name Cnt Base Error Test Error Unit Change StringIndexOf.searchChar16LongSuccess 5/25 14,909 ± 3,284 14,351 ± 0,105 ns/op 1,04x (p = 0,218 ) StringIndexOf.searchChar16LongWithOffsetSuccess 5/25 14,715 ± 0,870 14,098 ± 0,015 ns/op 1,04x (p = 0,004*) StringIndexOf.searchChar16MediumSuccess 5/25 6,611 ± 0,016 6,488 ± 0,025 ns/op 1,02x (p = 0,000*) StringIndexOf.searchChar16MediumWithOffsetSuccess 5/25 7,151 ± 0,026 7,064 ± 0,021 ns/op 1,01x (p = 0,000*) StringIndexOf.searchChar16ShortSuccess 5/25 2,667 ± 0,007 2,362 ± 0,002 ns/op 1,13x (p = 0,000*) StringIndexOf.searchChar16ShortWithOffsetSuccess 5/25 2,494 ± 0,112 2,543 ± 0,008 ns/op 0,98x (p = 0,018 ) StringIndexOf.searchCharLongSuccess 5/25 5,995 ± 0,017 5,270 ± 0,005 ns/op 1,14x (p = 0,000*) StringIndexOf.searchCharLongWithOffsetSuccess 5/25 6,377 ± 0,118 6,212 ± 0,003 ns/op 1,03x (p = 0,000*) StringIndexOf.searchCharMediumSuccess 5/25 2,350 ± 0,013 1,924 ± 0,002 ns/op 1,22x (p = 0,000*) StringIndexOf.searchCharMediumWithOffsetSuccess 5/25 2,675 ± 0,002 2,581 ± 0,005 ns/op 1,04x (p = 0,000*) StringIndexOf.searchCharShortSuccess 5/25 1,719 ± 0,002 1,243 ± 0,002 ns/op 1,38x (p = 0,000*) StringIndexOf.searchCharShortWithOffsetSuccess 5/25 1,635 ± 0,006 1,311 ± 0,001 ns/op 1,25x (p = 0,000*) * = significant ------------- PR Comment: https://git.openjdk.org/jdk/pull/17685#issuecomment-1925339945