RFR: 8320448: Accelerate IndexOf using AVX2 [v49]

Emanuel Peter epeter at openjdk.org
Thu May 30 13:59:18 UTC 2024


On Thu, 30 May 2024 13:19:57 GMT, Scott Gibbons <sgibbons at openjdk.org> wrote:

>> Re-write the IndexOf code without the use of the pcmpestri instruction, only using AVX2 instructions.  This change accelerates String.IndexOf on average 1.3x for AVX2.  The benchmark numbers:
>> 
>> 
>> Benchmark	                                               Score		Latest		
>> StringIndexOf.advancedWithMediumSub   343.573		317.934		0.925375393x
>> StringIndexOf.advancedWithShortSub1	  1039.081		1053.96		1.014319384x
>> StringIndexOf.advancedWithShortSub2	      55.828		110.541		1.980027943x
>> StringIndexOf.constantPattern	                9.361		11.906		1.271872663x
>> StringIndexOf.searchCharLongSuccess	        4.216		4.218		1.000474383x
>> StringIndexOf.searchCharMediumSuccess	3.133		3.216		1.02649218x
>> StringIndexOf.searchCharShortSuccess	3.76		        3.761		1.000265957x
>> StringIndexOf.success	                                9.186		9.713		1.057369911x
>> StringIndexOf.successBig	                      14.341		46.343		3.231504079x
>> StringIndexOfChar.latin1_AVX2_String	  6220.918		12154.52		1.953814533x
>> StringIndexOfChar.latin1_AVX2_char	  5503.556		5540.044		1.006629895x
>> StringIndexOfChar.latin1_SSE4_String	  6978.854		6818.689		0.977049957x
>> StringIndexOfChar.latin1_SSE4_char	  5657.499		5474.624		0.967675646x
>> StringIndexOfChar.latin1_Short_String	  7132.541		6863.359		0.962260014x
>> StringIndexOfChar.latin1_Short_char	16013.389	      16162.437		1.009307711x
>> StringIndexOfChar.latin1_mixed_String	  7386.123	      14771.622		1.999915517x
>> StringIndexOfChar.latin1_mixed_char	  9901.671		9782.245		0.987938803
>
> Scott Gibbons has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Stupid EOL at end
>  - Add @test block; fix test indentation

test/jdk/java/lang/String/IndexOf.java line 25:

> 23: 
> 24: /*
> 25:  * @test

You should add the `@bug 8320448` for all runs.

test/jdk/java/lang/String/IndexOf.java line 27:

> 25:  * @test
> 26:  * @summary test String indexOf() intrinsic
> 27:  * @run main/othervm IndexOf

Suggestion:

 * @run main IndexOf

You do not need a new VM if you have no arguments ;)

test/jdk/java/lang/StringBuffer/ECoreIndexOf.java line 25:

> 23: 
> 24: /* @test
> 25:  * @bug 4162796 4162796

You need to fix the bug numbers.

test/jdk/java/lang/StringBuffer/ECoreIndexOf.java line 27:

> 25:  * @bug 4162796 4162796
> 26:  * @summary Test indexOf and lastIndexOf
> 27:  * @run main/othervm -Xbatch -XX:-TieredCompilation -XX:CompileCommand=dontinline,ECoreIndexOf.indexOfKernel ECoreIndexOf

I would also add a line without `-XX:-TieredCompilation`, then C1 can be tested with this too

test/jdk/java/lang/StringBuffer/ECoreIndexOf.java line 32:

> 30: 
> 31: /* @test
> 32:  * @bug 4162796 4162796

Here too

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16753#discussion_r1620760730
PR Review Comment: https://git.openjdk.org/jdk/pull/16753#discussion_r1620756896
PR Review Comment: https://git.openjdk.org/jdk/pull/16753#discussion_r1620753321
PR Review Comment: https://git.openjdk.org/jdk/pull/16753#discussion_r1620754948
PR Review Comment: https://git.openjdk.org/jdk/pull/16753#discussion_r1620753577


More information about the hotspot-compiler-dev mailing list