On Fri, 2 Feb 2024 13:54:46 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

M1 MacBook:
```Name                                              Cnt   Base   Error    Test 
  Error  Unit  Change
StringIndexOf.searchChar16LongSuccess               5 14,909 ± 3,284  14,480 ± 
0,256 ns/op   1,03x (p = 0,324 )
StringIndexOf.searchChar16LongWithOffsetSuccess     5 14,715 ± 0,870  14,373 ± 
0,382 ns/op   1,02x (p = 0,024 )
StringIndexOf.searchChar16MediumSuccess             5  6,611 ± 0,016   6,476 ± 
0,050 ns/op   1,02x (p = 0,000*)
StringIndexOf.searchChar16MediumWithOffsetSuccess   5  7,151 ± 0,026   6,884 ± 
0,014 ns/op   1,04x (p = 0,000*)
StringIndexOf.searchChar16ShortSuccess              5  2,667 ± 0,007   2,369 ± 
0,005 ns/op   1,13x (p = 0,000*)
StringIndexOf.searchChar16ShortWithOffsetSuccess    5  2,494 ± 0,112   2,102 ± 
0,006 ns/op   1,19x (p = 0,000*)
StringIndexOf.searchCharLongSuccess                 5  5,995 ± 0,017   5,276 ± 
0,017 ns/op   1,14x (p = 0,000*)
StringIndexOf.searchCharLongWithOffsetSuccess       5  6,377 ± 0,118   5,735 ± 
0,014 ns/op   1,11x (p = 0,000*)
StringIndexOf.searchCharMediumSuccess               5  2,350 ± 0,013   1,927 ± 
0,012 ns/op   1,22x (p = 0,000*)
StringIndexOf.searchCharMediumWithOffsetSuccess     5  2,675 ± 0,002   2,247 ± 
0,057 ns/op   1,19x (p = 0,000*)
StringIndexOf.searchCharShortSuccess                5  1,719 ± 0,002   1,245 ± 
0,005 ns/op   1,38x (p = 0,000*)
StringIndexOf.searchCharShortWithOffsetSuccess      5  1,635 ± 0,006   1,247 ± 
0,009 ns/op   1,31x (p = 0,000*)
  * = significant


`-Xint`, M1 MacBook:
```Name                                              Cnt     Base    Error      
Test    Error  Unit  Change
StringIndexOf.searchChar16LongSuccess               5 4683,186 ±  6,431  
4482,179 ± 26,216 ns/op   1,04x (p = 0,000*)
StringIndexOf.searchChar16LongWithOffsetSuccess     5 4586,540 ± 39,266  
4403,976 ± 18,652 ns/op   1,04x (p = 0,000*)
StringIndexOf.searchChar16MediumSuccess             5 2123,355 ±  3,885  
1942,100 ± 77,042 ns/op   1,09x (p = 0,000*)
StringIndexOf.searchChar16MediumWithOffsetSuccess   5 2007,646 ± 52,087  
1859,545 ± 67,424 ns/op   1,08x (p = 0,000*)
StringIndexOf.searchChar16ShortSuccess              5  548,599 ±  3,048   
386,671 ± 60,860 ns/op   1,42x (p = 0,000*)
StringIndexOf.searchChar16ShortWithOffsetSuccess    5  459,164 ±  5,782   
302,377 ± 39,086 ns/op   1,52x (p = 0,000*)
StringIndexOf.searchCharLongSuccess                 5  908,953 ± 78,580   
799,114 ± 34,290 ns/op   1,14x (p = 0,000*)
StringIndexOf.searchCharLongWithOffsetSuccess       5  855,726 ± 28,357   
790,690 ± 19,452 ns/op   1,08x (p = 0,000*)
StringIndexOf.searchCharMediumSuccess               5  360,903 ±  3,214   
262,320 ±  1,706 ns/op   1,38x (p = 0,000*)
StringIndexOf.searchCharMediumWithOffsetSuccess     5  322,950 ±  5,790   
268,992 ±  8,008 ns/op   1,20x (p = 0,000*)
StringIndexOf.searchCharShortSuccess                5  274,718 ±  7,208   
174,274 ±  3,445 ns/op   1,58x (p = 0,000*)
StringIndexOf.searchCharShortWithOffsetSuccess      5  254,141 ± 11,992   
186,917 ± 11,471 ns/op   1,36x (p = 0,000*)
  * = significant

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

PR Comment: https://git.openjdk.org/jdk/pull/17685#issuecomment-1923869466

Reply via email to