When calling the computeIfAbsent method, the hashCode method will only be called once, and the equals method will probably not be called. Using MethodCacheKey is inefficient.
Comment From: jhoeller
The use of MethodCacheKey
in an isolated ConcurrentHashMap
benchmark is consistently faster than using Method
itself as a key there, possibly due to the pre-computed hash codes of the existing entries in the cache. In a regular scenario, it is about 30% faster; with overloaded methods in the mix (which leads to Method hash code collisions and equals
calls), it is even 40% faster.
As a consequence, it seems sensible to preserve our existing caching arrangement there.
Comment From: kang-hl
Are you benchmarking with the latest code? If not, you should use the latest code.
---Original---
From: "Juergen @.>
Date: Fri, Nov 24, 2023 00:19 AM
To: @.>;
Cc: @.**@.**>;
Subject: Re: [spring-projects/spring-framework] Remove MethodCacheKey
(PR#31309)
The use of MethodCacheKey in an isolated ConcurrentHashMap benchmark is consistently faster than using Method itself as a key there, possibly due to the pre-computed hash codes of the existing entries in the cache. In a regular scenario, it is about 30% faster; with overloaded methods in the mix (which leads to Method hash code collisions and equals calls), it is even 40% faster.
As a consequence, it seems sensible to preserve our existing caching arrangement there.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>