In my implementation of assignment 2, I decided on simulating an authentication system, using randomly generated usernames and passwords. The passwords are encrypted with Rot13, a simple symmetric substitution cypher that works on the alphabetical characters in a string, leaving numerics and symbols untouched. The worker threads are constantly hammering the collection with a rough distribution of 90% reads and 10% writes, with results of any operation simply ignored, as this is a benchmarking application.
For the data structure, I settled on HashMaps, as they are a relatively efficient way to store (key,value) pairs. I implemented this data structure in three ways, leveraging different methods of concurrent access control. The first method, which proved to be the least efficient of the three used, was wrapping the standard java.util.HashMap class in a ReadWriteLock. The second method takes advantage of the java.util.concurrent.ConcurrentHashMap found in the JDK. The last method is the proposed version of ConcurrentHashMap for inclusion with Java 8, titled ConcurrentHashMapV8.
I ran a set of 12 benchmarks on each of 4 machines (excepting wolf, where I only ran 9 benchmarks due to a lack of resources). Each method was run through a series of increasing thread counts (1, 2, 10, 1000). The graphs below show this. From top to bottom, left to right of each set of graphs is the following order: 1 thread, 2 threads, 10 threads, and 1000 threads. Each graph has three bars, each bar from left to right representing the performance of the ReadWriteLock-wrapped HashMap, ConcurrentHashMap, and ConcurrentHashMapV8. The y-axis represents average operation time in nanoseconds.
Here's the data:
It should be noted that in all cases, ReadWriteLock-wrapped HashMap performed terribly. In most cases, it seems that ConcurrentHashMap outperformed ConcurrentHashMapV8. Oh, and rho's hardware is absolutely amazing for concurrently-designed applications.
-->Jake Peck, 20111024
UPDATE 20111101 - Code is now available here.
jsr166e.jar (reposted without permission)
data.dat (example data to populate the datastore with initially)
javac -cp '.:jsr166e.jar' *.java
java -cp '.:jsr166e.jar' Main <number of threads> <method>