Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
In BookKeeper there are many instances of maps and sets that use ledger id
and entry ids as keys or values. JDK concurrent collections have the overhead
of boxing all the primitive values into objects (eg: long --> Long) that would
need to be allocated from the heap. In addition to that, JDK map implementations
are closed hash tables and they will require at least one more allocation to hold
the linked-list/tree node.
There are already available libraries that offer primitive collections with
zero-allocation, but none of these support concurrent maps/sets.
We have added a handful of specializations, all based on the same implementation
idea. We have a hash table which is broken down into multiple sections. Each
sections, on its own, is an open hash table with linear probing, protected by
a stamped lock.
All insertions, lookups and iterations on these collections are allocation free.
ConcurrentLongHashMap: Map<long, Object> ConcurrentLongHashSet: Set<long> ConcurrentLongLongHashMap: Map<long, long> ConcurrentLongLongPairHashMap: Map< Pair<long, long>, Pair<long, long> > ConcurrentOpenHashMap: Map<Object, Object> ConcurrentOpenHashSet: Set<Object>