Java Reference
In-Depth Information
it has more allocation and GC overhead, a linked queue allows more concurrent access by
put s and take s than an array-based queue because the best linked queue algorithms allow
the head and tail to be updated independently. Because allocation is usually threadlocal, al-
gorithms that can reduce contention by doing more allocation usually scale better. (This is
another instance in which intuition based on traditional performance tuning runs counter to
what is needed for scalability.)
Figure 12.2. Comparing Blocking Queue Implementations.
12.2.3. Measuring Responsiveness
So far we have focused on measuring throughput, which is usually the most important per-
formance metric for concurrent programs. But sometimes it is more important to know how
long an individual action might take to complete, and in this case we want to measure the
variance of service time. Sometimes it makes sense to allow a longer average service time
if it lets us obtain a smaller variance; predictability is a valuable performance characteristic
too. Measuring variance allows us to estimate the answers to quality-of-service questions like
“What percentage of operations will succeed in under 100 milliseconds?”
Histograms of task completion times are normally the best way to visualize variance in ser-
vice time. Variances are only slightly more difficult to measure than averages—you need to
keep track of per-task completion times in addition to aggregate completion time. Since timer
granularity can be a factor in measuring individual task time (an individual task may take less
than or close to the smallest “timer tick”, which would distort measurements of task dura-
Search WWH ::




Custom Search