Java puzzle, low latency queue
Join the DZone community and get the full member experience.
Join For FreeThere a number of ways to use queues. A simple and very fast queue is to use AtomicReference. (It stores 0 or 1 element)
1. Write a producer and consumer thread which communicates via an AtomicReference.
2. Have the consumer send messages back to the producer using another AtomicReference.
3. Time the throughput for one second repeatedly. What variation do you see?
4. Pad the AtomicReference to make sure they are at least 64 bytes apart in memory and measure again.
From http://vanillajava.blogspot.com/2011/11/java-puzzle-low-latency-queue.html
Java (programming language)
producer
consumer
Measure (physics)
Memory (storage engine)
Throughput (business)
Element
Opinions expressed by DZone contributors are their own.
Comments