
Doug Lea JSR166 ConcurrentHashMap vs Click Cliff NonBlockingHashMap
Posted by andy.song in Twins Father on Nov 21, 2010 10:08:19 PM[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:
Version | Round 1 | Round 2 | Round 3 |
---|---|---|---|
Get | Get | Get | |
JSR 166 ConcurrentHashMap | AVG: 3440.396 | AVG: 5284.996 | AVG: 3259.3 |
Cliff NonBlockingHashMap | AVG: 2935.274 | AVG: 3158.488 | AVG: 7471.13 |
Put | Put | Put | |
JSR 166 ConcurrentHashMap | AVG: 36421688.57 | AVG: 11300718.2 | AVG: 8250990.84 |
Cliff NonBlockingHashMap | AVG: 91931746.36 | AVG: 63642538.64 | AVG: 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/
-
ConcurrentMapTester.java.zip 931 bytes
-
NonBlockingMapTester.java.zip 952 bytes
-
Comp2.xls 2.7 MB
Comments