RFR: 8312424: 80% throughput decrease in Arrays.hashCode(Object[]) after JDK-8312164
Chen Liang
liach at openjdk.org
Thu Jul 20 02:07:44 UTC 2023
On Thu, 20 Jul 2023 01:27:41 GMT, Glavo <duke at openjdk.org> wrote:
>> The changes to `Arrays.hashCode(Object[])` in JDK-8312164 caused its performance is reduced by about 80%.
>>
>> This PR reverts this change.
>
>> A similar performance decrease have been discussed here: [#14752 (comment)](https://github.com/openjdk/jdk/pull/14752#discussion_r1250888931)
>>
>> Can you check whether adding `@ForceInline` on `Objects.equals` help with JIT? If it helps, then I think adding `@ForceInline` might be a better solution.
>
> I added `@ForceInline` on `Objects.hashCode(Object)`, but the JMH results did not change.
@Glavo I have created a test case with polymorphic objects in an array: https://github.com/liachmodded/jdk/tree/explore/arrays-hash-poly
Can you see if you can produce the same outcome on your patch, and how the existing `Objects.equals` behave on the polymorphicObjects case?
Benchmark (size) Mode Cnt Score Error Units
ArraysHashCode.objects 1 avgt 15 0.770 ± 0.011 ns/op
ArraysHashCode.objects 10 avgt 15 4.704 ± 0.059 ns/op
ArraysHashCode.objects 100 avgt 15 54.610 ± 0.384 ns/op
ArraysHashCode.objects 10000 avgt 15 6053.742 ± 35.244 ns/op
Benchmark (size) Mode Cnt Score Error Units
ArraysHashCode.polymorphicObjects 1 avgt 15 0.921 ± 0.069 ns/op
ArraysHashCode.polymorphicObjects 10 avgt 15 23.322 ± 1.076 ns/op
ArraysHashCode.polymorphicObjects 100 avgt 15 211.325 ± 2.200 ns/op
ArraysHashCode.polymorphicObjects 10000 avgt 15 81850.916 ± 2427.661 ns/op
-------------
PR Comment: https://git.openjdk.org/jdk/pull/14944#issuecomment-1642998263
More information about the core-libs-dev
mailing list