[Introduction]

Everyone current only use JDK provided concurrent library as that can meet many situations. But if you need more scalable one, I think maybe Doug Lea maintained new version of concurrent library would be your first considerations.

 

Today we will compare two version LinkedBlockingQueue performance

 

[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 LinkedBlockingQueueAVG: 259435.8AVG: 209333.5AVG: 261711.1
JDK  LinkedBlockingQueueAVG: 805892.1AVG: 381774.3AVG: 477590.5
PutPutPut
JSR 166 LinkedBlockingQueueAVG: 47124513.2AVG: 94489344.8AVG: 289728496
JDK LinkedBlockingQueueAVG: 240820336.6AVG: 268540401AVG: 108976599

Note:  All the results was NanoSeconds. 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.


[Summary]

If you do need high scalability for Queue implementation we think JSR 166 LinkedBlockingQueue will be first choice for you.

 

We think one important change had already made into LinkedBlockingQueue but still not includes with latest JDK 1.6 library.

"http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/main/java/util/concurrent/LinkedBlockingQueue.java?view=log reversion 1.54

move value allocation outside the lock scope."

make the two versions behavior differently.

 

Next round we will compare Dr.Click Cliff LockFreeHashtable vs Doug Lea ConncurrentHashMap

 

 

[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