On Wed, 1 Mar 2023 14:28:55 GMT, Eirik Bjorsnos <d...@openjdk.org> wrote:

>> This PR suggests we add a vectorized equalsIgnoreCase benchmark to the set 
>> of benchmarks in `org.openjdk.bench.jdk.incubator.vector`. This benchmark 
>> serves as an example of how vectorization can be useful also in the area of 
>> text processing. It takes advantage of the fact that ASCII and Latin-1 were 
>> designed to optimize case-twiddling operations.
>> 
>> The code came about during the work on #12632, where vectorization was 
>> deemed out of scope.
>> 
>> Benchmark results:
>> 
>> 
>> Benchmark                             (size)  Mode  Cnt     Score   Error  
>> Units
>> EqualsIgnoreCaseBenchmark.scalar          16  avgt   15    21.575 ± 0.365  
>> ns/op
>> EqualsIgnoreCaseBenchmark.scalar          32  avgt   15    43.199 ± 2.786  
>> ns/op
>> EqualsIgnoreCaseBenchmark.scalar          64  avgt   15    71.389 ± 0.891  
>> ns/op
>> EqualsIgnoreCaseBenchmark.scalar         128  avgt   15   146.827 ± 1.115  
>> ns/op
>> EqualsIgnoreCaseBenchmark.scalar        1024  avgt   15  1062.759 ± 9.331  
>> ns/op
>> EqualsIgnoreCaseBenchmark.vectorized      16  avgt   15    21.483 ± 0.121  
>> ns/op
>> EqualsIgnoreCaseBenchmark.vectorized      32  avgt   15    10.538 ± 0.125  
>> ns/op
>> EqualsIgnoreCaseBenchmark.vectorized      64  avgt   15    13.182 ± 0.177  
>> ns/op
>> EqualsIgnoreCaseBenchmark.vectorized     128  avgt   15    19.192 ± 0.421  
>> ns/op
>> EqualsIgnoreCaseBenchmark.vectorized    1024  avgt   15    92.521 ± 3.494  
>> ns/op
>
> Eirik Bjorsnos has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Use GT, LT, EQ operations since they seem to outperform GE, LE, NE.

Benchmark looks good.

I think you need to look at the generated code and perf data to get more 
insight into the differences you are observing.

Sometimes array alignment can add variance to the results (which may not be the 
case here), and to rule that out i sometimes run vector tests with the HotSpot 
option `-XX:ObjectAlignmentInBytes` e.g. `-XX:ObjectAlignmentInBytes=32`.

test/micro/org/openjdk/bench/jdk/incubator/vector/EqualsIgnoreCaseBenchmark.java
 line 111:

> 109:                     .or(letter.and(upperA.eq(upperB)));
> 110: 
> 111:             if(equalsIgnoreCase.allTrue()) {

Suggestion:

            if (equalsIgnoreCase.allTrue()) {

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

PR: https://git.openjdk.org/jdk/pull/12790

Reply via email to