Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. empty map makes Java implementation the smallest
  2. with 8 elements have maps similar size
  3. from 256 elements the max saving for NonBlickingHashMapLong and Long2ObjectMap is achieved

Performance

Martin Thompson's style of PerfTest

2 consumers, 2 producers. Producers putting with key value pair that is their id and random object. Consumers removing with key that is their id. Basically a bunch of <1,O> or <2, O> putting and removing with <1> or <2>.

Code Block
titlePerformance
Java
_______________________
0 - 2 producers 2 consumers: 4,782,614 ops/sec - MapsPerfTest
1 - 2 producers 2 consumers: 4,194,545 ops/sec - MapsPerfTest
2 - 2 producers 2 consumers: 4,726,670 ops/sec - MapsPerfTest
3 - 2 producers 2 consumers: 5,339,190 ops/sec - MapsPerfTest
4 - 2 producers 2 consumers: 4,952,414 ops/sec - MapsPerfTest

Cliff's
______________________
0 - 2 producers 2 consumers: 23,030,573 ops/sec - MapsPerfTest
1 - 2 producers 2 consumers: 31,244,208 ops/sec - MapsPerfTest
2 - 2 producers 2 consumers: 30,630,539 ops/sec - MapsPerfTest
3 - 2 producers 2 consumers: 28,825,699 ops/sec - MapsPerfTest
4 - 2 producers 2 consumers: 26,588,300 ops/sec - MapsPerfTest

Long2ObjectMap (FastUtil)
______________________
0 - 2 producers 2 consumers: 5,569,578 ops/sec - MapsPerfTest
1 - 2 producers 2 consumers: 5,940,526 ops/sec - MapsPerfTest
2 - 2 producers 2 consumers: 5,883,532 ops/sec - MapsPerfTest
3 - 2 producers 2 consumers: 5,798,396 ops/sec - MapsPerfTest
4 - 2 producers 2 consumers: 5,537,185 ops/sec - MapsPerfTest
Using JMH Approach 1

2 consumers, 2 producers. Map is initially empty. Producers execute put with random long 0-10. Consumer are removing with random long 0-10.

Code Block
     [java] Benchmark                                                           Mode  Samples      Score      Error   Units
     [java] i.n.i.ThreadSafeMapsPerfTest.concurrentHashMap                     thrpt        5  17205.845 ± 1549.392  ops/ms
     [java] i.n.i.ThreadSafeMapsPerfTest.concurrentHashMap:putChm              thrpt        5   8031.802 ±  627.409  ops/ms
     [java] i.n.i.ThreadSafeMapsPerfTest.concurrentHashMap:removeChm           thrpt        5   9174.043 ±  938.380  ops/ms
     [java] i.n.i.ThreadSafeMapsPerfTest.nonBlockingHashMapLong                thrpt        5  22120.230 ± 1674.090  ops/ms
     [java] i.n.i.ThreadSafeMapsPerfTest.nonBlockingHashMapLong:putNbhml       thrpt        5  10369.226 ±  505.723  ops/ms
     [java] i.n.i.ThreadSafeMapsPerfTest.nonBlockingHashMapLong:removeNbhml    thrpt        5  11751.004 ± 1391.759  ops/ms
Using JMH Approach 2

3 threads.. Map is filled with 1000 elements. Each tread removes the element with random 0-1000 remove and then puts back the removed element to the map right away with same key.

Code Block
     [java] Benchmark                                               Mode  Samples      Score     Error   Units
     [java] i.n.i.ThreadSafeMapsPerfTest.concurrentHashMap         thrpt        5  16033.299 ± 642.117  ops/ms
     [java] i.n.i.ThreadSafeMapsPerfTest.nonBlockingHashMapLong    thrpt        5  27084.222 ± 323.981  ops/ms

Saving With NonBlockingHashMapLong

...