RFR: 8321279: Implement hashCode() in Heap-X-Buffer.java.template [v7]

Alan Bateman alanb at openjdk.org
Tue Dec 12 15:10:34 UTC 2023


On Tue, 12 Dec 2023 08:01:47 GMT, Sergey Tsypanov <stsypanov at openjdk.org> wrote:

>> Currently `Heap*Buffer.hashCode()` is inherited from `*Buffer` and implemented as 
>> 
>> public int hashCode() {
>>     int h = 1;
>>     int p = position();
>>     for (int i = limit() - 1; i >= p; i--)
>>         h = 31 * h + (int)get(i);
>>     return h;
>> }
>> 
>> This can be improved using `ArraysSupport.vectorizedHashCode()`
>
> Sergey Tsypanov has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8320971: Rename method

Here's the results that I see

ByteBuffers.testHeapHashCode      16  avgt   30      21.364 ?  0.012  ns/op
ByteBuffers.testHeapHashCode    1024  avgt   30    1273.856 ?  1.102  ns/op
ByteBuffers.testHeapHashCode  131072  avgt   30  162732.079 ? 83.787  ns/op

with vectorizedHashCode:

ByteBuffers.testHeapHashCode      16  avgt   30     12.736 ? 0.025  ns/op
ByteBuffers.testHeapHashCode    1024  avgt   30     88.203 ? 0.049  ns/op
ByteBuffers.testHeapHashCode  131072  avgt   30  10639.662 ? 5.396  ns/op

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

PR Comment: https://git.openjdk.org/jdk/pull/16992#issuecomment-1852224418


More information about the nio-dev mailing list