Java Reference
In-Depth Information
memory bus, operations that are time-consuming and divert computing resources from the
program.
Java 6 uses an improved algorithm for managing intrinsic locks, similar to that used by
ReentrantLock , that closes the scalability gap considerably. Figure 13.1 shows the per-
formance difference between intrinsic locks and ReentrantLock on Java 5.0 and on a
prerelease build of Java 6 on a four-way Opteron system running Solaris. The curves repres-
ent the “speedup” of ReentrantLock over intrinsic locking on a single JVM version. On
Java 5.0, ReentrantLock offers considerably better throughput, but on Java 6, the two are
quite close. [2] The test program is the same one used in Section 11.5 , this time comparing the
throughput of a HashMap guarded by an intrinsic lock and by a ReentrantLock .
Figure 13.1. Intrinsic Locking Versus ReentrantLock Performance on Java 5.0 and Java 6.
On Java 5.0, the performance of intrinsic locking drops dramatically in going from one thread
(no contention) to more than one thread; the performance of ReentrantLock drops far
less, showing its better scalability. But on Java 6, it is a different story—intrinsic locks no
longer fall apart under contention, and the two scale fairly similarly.
Graphs like Figure 13.1 remind us that statements of the form “ X is faster than Y ” are at best
short-lived. Performance and scalability are sensitive to platform factors such as CPU, pro-
cessor count, cache size, and JVM characteristics, all of which can change over time. [3]
Search WWH ::




Custom Search