While looking through the source code of Hibernate I found the class ConcurrentServiceBinding. My first thought was: cool idea, maybe I can use something similar too. And the second thought was: is it really faster than IdentityHashMap or ConcurrentHashMap. To answer this question I have created small JMH tests. Here are the results from the execution of this tests on Intel Core i7 2 GHz:
Same as above but with 10 threads:
baseConcurrentServiceBindingXXX uses the current implementation of ConcurrentServiceBinding in Hibernate. chmConcurrentServiceBindingXXX uses ConcurrentHashMap and ihmConcurrentServiceBinding uses IdentityHashMap.
As you can see CHM based implementation is faster than the current implementation of ConcurrentServiceBinding. The IdentityHashMap based implementation is only slightly faster than the CHM based. Therefore I think it is not worth to maintain an extra class when CHM is good enough and suggest to replace ConcurrentServiceBinding by ConcurrentHashMap.