October 06, 2004
Hilton Suites Toronto/Markham Conference Centre
Markham, ON
Associated with CASCON 2004
(http://www.cas.ibm.com/cascon)
Accelerating Java synchronization in Just-In-Time compiler-generated code
Mark Stoodley - IBM Toronto Lab
Synchronization is an essential tool that is widely used in Java
applications and in the Java class library to maintain data integrity
in a multithreaded environment. Locking and unlocking objects are
generally expensive operations, however, so Java Just-In-Time(JIT)
compilers employ a variety of ingenious tactics to reduce the cost of
synchronization. These tactics fall into two broad categories: 1)
techniques to reduce the cost of the lock and unlock operations, and
2) techniques to eliminate some of the operations altogether. The use
of flat locks and spin loops are two techniques in the first category
that reduce cost by avoiding the use of monitors at the operating
system level in the typical case that there is no thread contention
for an object's lock. Nested lock removal and lock coarsening are
examples of techniques in the second category that operate by removing
redundant synchronization operations or by combining the effects of
multiple operations so that the cost is not paid as often. In this
talk, I will first give a quick overview of the various technologies
used to improve the cost of synchronization in Java programs. I will
then describe in greater detail the lock coarsening technique used in
recent releases of IBM's JIT compilers to broaden the scope of code
across which locks are held so that fewer lock operations are
required. While improving performance is the obviously the main goal
of this optimization, maintaining correctness is critically important.
I will describe two extremely subtle problems that would have
sacrificed correctness for performance had our framework not been
specifically designed to detect and avoid them.
Presentation Slides.