1U 1 UltraSparc2 650
4U 4 UltraSparc2 450
8U 8 UltraSparc3 750
24U 24 UltraSparc3 750
5。1 Overhead
Uncontended overhead was measured by running only one thread, subtracting the time per iteration taken with a version setting S=0 (zero probability of accessing shared random) from a run with S=1。 Table 2 displays these estimates of the per-lock overhead of synchronized code over unsynchronized code, in
nanoseconds。 The Mutex class comes closest to testing the basic cost of the framework。 The additional overhead for Reentrant locks indicates the cost of recording the current owner thread and of error-checking, and for Fair locks the additional cost of first checking whether the queue is empty。
Table 2 also shows the cost of tryAcquire versus the "fast path" of a built-in lock。 Differences here mostly reflect the costs of using different atomic instructions and memory barriers across locks and machines。 On multiprocessors, these instructions tend to completely overwhelm all others。 The main differences between Builtin and synchronizer classes are apparently due to Hotspot locks using a compareAndSet for both locking and unlocking, while these synchronizers use a compareAndSet for acquire and a volatile write (i。e。, with a memory barrier on multiprocessors, and reordering constraints on all processors) on release。 The absolute and relative costs of each vary across machines。
At the other extreme, Table 3 shows per-lock overheads with S=1 and running 256 concurrent threads, creating massive lock contention。 Under complete saturation, barging-FIFO locks have about an order of magnitude less overhead (and equivalently greater throughput) than Builtin locks, and often two orders of magnitude less than Fair locks。 This demonstrates the effectiveness of the barging-FIFO policy in maintaining thread progress even under extreme contention。
Table 2 Uncontended Per-Lock Overhead in Nanoseconds
Machine Builtin Mutex Reentrant Fair
1P 18 9 31 37
2P 58 71 77 81
2A 13 21 31 30
4P 116 95 109 117
1U 90 40 58 67
4U 122 82 100 115
8U 160 83 103