RFR: 8282664: Unroll by hand StringUTF16 and StringLatin1 polynomial hash loops [v13]

Claes Redestad redestad at openjdk.org
Thu Dec 22 13:12:54 UTC 2022


On Wed, 21 Dec 2022 00:11:34 GMT, Sandhya Viswanathan <sviswanathan at openjdk.org> wrote:

>> Passing the constant node through as an input as suggested by @iwanowww and @sviswa7 meant we could eliminate most of the `instruct` blocks, removing a significant chunk of code and a little bit of complexity from the proposed patch.
>
> @cl4es Thanks for passing the constant node through, the code looks much cleaner now. The attached patch should handle the signed bytes/shorts as well. Please take a look. 
> [signed.patch](https://github.com/openjdk/jdk/files/10273480/signed.patch)

I ran tests and some quick microbenchmarking to validate @sviswa7's patch to activate vectorization for `short` and `byte` arrays and it looks good:

Before:

Benchmark                   (size)  Mode  Cnt     Score    Error  Units
ArraysHashCode.bytes         10000  avgt    5  7845.586 ± 23.440  ns/op
ArraysHashCode.chars         10000  avgt    5  1203.163 ± 11.995  ns/op
ArraysHashCode.ints          10000  avgt    5  1131.915 ±  7.843  ns/op
ArraysHashCode.multibytes    10000  avgt    5  4136.487 ±  5.790  ns/op
ArraysHashCode.multichars    10000  avgt    5   671.328 ± 17.629  ns/op
ArraysHashCode.multiints     10000  avgt    5   699.051 ±  8.135  ns/op
ArraysHashCode.multishorts   10000  avgt    5  4139.300 ± 10.633  ns/op
ArraysHashCode.shorts        10000  avgt    5  7844.019 ± 26.071  ns/op


After: 

Benchmark                   (size)  Mode  Cnt     Score    Error  Units
ArraysHashCode.bytes         10000  avgt    5  1193.208 ±  1.965  ns/op
ArraysHashCode.chars         10000  avgt    5  1193.311 ±  5.941  ns/op
ArraysHashCode.ints          10000  avgt    5  1132.592 ± 10.410  ns/op
ArraysHashCode.multibytes    10000  avgt    5   657.343 ± 25.343  ns/op
ArraysHashCode.multichars    10000  avgt    5   672.668 ±  5.229  ns/op
ArraysHashCode.multiints     10000  avgt    5   697.143 ±  3.929  ns/op
ArraysHashCode.multishorts   10000  avgt    5   666.738 ± 12.236  ns/op
ArraysHashCode.shorts        10000  avgt    5  1193.563 ±  5.449  ns/op

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

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


More information about the core-libs-dev mailing list