[Introduction]

Concurrent version of HashMap was laregely used in the multiple thread programming. But most of them based on JDK, how about other alternative?

Today we will compare Click Cliff version of NonBlockingHashMap vs JDK ConcurrentHashMap

 

[Lab Environment]

 

Laptop: Dell E6400

CPU: Intel Core 2  (with 2 core)

Memory: 4G DDR2

JDK: Sun JDK 1.6 u21

 

//Forget: add OS information

OS: Windows XP sp3

 

 

[Testing Senario]

 

start   16 threads currently write string (UUID), each thread will write 1000  numbers of string,into the underlying single queue instance, and at  them  same time start 16 threads  concurrently reading the string, each  thread will read 1000 numbers of  string,has been inserted from the same  underlying single queue instance.

 

I have tested 3 rounds for each version:

 

VersionRound 1
Round 2
Round 3

GetGetGet
JSR 166 ConcurrentHashMapAVG: 3440.396AVG: 5284.996AVG: 3259.3
Cliff NonBlockingHashMapAVG: 2935.274AVG: 3158.488AVG: 7471.13

PutPutPut
JSR 166 ConcurrentHashMapAVG: 36421688.57AVG: 11300718.2AVG: 8250990.84
Cliff NonBlockingHashMapAVG: 91931746.36AVG: 63642538.64AVG: 57540781

 

Note: 

1. All the results was NanoSeconds.

2. Don't forget if running with JSR jar please add one JVM parameters: "-Xbootclasspath/p:D:/tmp/distribution/lib/concurrent/jsr166.jar" and modify the path to yours.

3. As HashMap will pre-consume memory. So please remember add "-Xmx" JVM parameters.

 

[Summary]

1. JSR166 ConcurrentHashMap was comparatively better than Cliff NonBlockingHashMap in the system with little core cpu.

2. If you need most was read operation, you can try Cliff NonBlockingHashMap. As the scalability and performance of read was it's strength.

 

Very important part:

As the condition was limited, so I couldn't find the powerful machine (Like 16Core or more). So the comparision may not be fair to Cliff's implementation. And Windows Azul has it's build-in JVM. So the behavior will be changed if moved to their machines.

 

 

[Reference]

1. Doug Lea : http://gee.cs.oswego.edu/dl/concurrency-interest/

2. Bootclasspath: http://www.tedneward.com/files/Papers/BootClasspath/BootClasspath.pdf

3. JSR 166.jar: http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166.jar

4. Cliff's blog:http://www.azulsystems.com/blogs/cliff

5. Cliff none-blocking collection project: http://sourceforge.net/projects/high-scale-lib/