System.identityHashCode

John Rose john.r.rose at oracle.com
Mon May 11 23:08:15 UTC 2020


On May 11, 2020, at 2:35 PM, John Rose <john.r.rose at oracle.com> wrote:
> 
> On May 11, 2020, at 2:02 PM, forax at univ-mlv.fr wrote:
>> 
>> I was thinking about doing a reduce using a xor between the primitive fields and the klass,
>> but i've discovered that reduceLanes(XOR) provided by the panama vector API is not one AVX operation :(
> 
> The best cross-lane bit-mixer is AES step, followed by
> long multiply.  Reduce-lanes XOR is many times worse.

P.S. Multiply comes in CLMUL flavor also (H/T Doug Lea).
In any case, multiply operations work best if you collect
high and low halves and fold them together.  Roughly
similarly, AES step is far stronger if it is done at depth
two.  Single AES step fails smhasher but passes when
doubled.  AES mixes 128 bits at a time, which gives it
a specific edge over multiply.  These considerations
feed into my basic position that hash codes should
be “cook’s choice” by the JVM, rather than specified
forever in Javadoc.

See https://openjdk.java.net/jeps/8201462.



More information about the valhalla-dev mailing list