Replace ConcurrentServiceBinding by ConcurrentHashMap

Description

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.

Environment

None

Assignee

Andrej Golovnin

Reporter

Andrej Golovnin

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

Yes, likely

Requires Release Note

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure