I am transforming my application to work with multiple threads instead of a thread, but I have not been able to find a map that works on multiple threads and does not cause degradation in performance due to very large values on the map.
ConcurrentHashMap and HashMap, iterate over the Values and Keys when I use the get()
or containsKey()
method, instead, the gnu.trove
maps only iterate over the keys, which makes them 4-5 times faster than a hashmap
or concurrenthashmap
.
I would like to know, if someone knows a Trove-like map, that it does not iterate over Values, and serves for many Thread applications, or a way to prevent saving actual Values on the map and placing Reference Values.
Benchmark (32k String): ConcurrentHashMap took 2007ms to use 100 million times. containsKey gnu.trove.map.hash.TLongObjectHashMap () takes 408ms to use 100 million times. containsKey
The larger the size of the Value Object, the more it saves, the longer ConcurrentHashMap takes.
Note: I have already lowered the concurrency level of% co_from% to 1, because it iterates over values, more than 1 generates degradation in performance.