Fine-Grained Adaptive Biased Locking

Pizlo, Filip and Frampton, Daniel and Hosking, Antony L.

Abstract

Mutual-exclusion locking is the prevailing technique for protecting shared resources in concurrent programs. Fine-grained locking maximizes the opportunities for concurrent execution while preserving correctness, but increases both the number of locks and the frequency of lock operations. Adding to the frequency of these operations is the practice of using locks defensively — such as in library code designed for use in both concurrent and single-threaded scenarios. If the library does not protect itself with locks, an engineering burden is placed on the library’s users; if the library does use locks, it punishes those who use it only from a single thread. Biased locking is a dynamic protocol for eliminating this trade-off, in which the underlying run-time system optimizes lock operations by biasing a lock to a specific thread when the lock is dynamically found to be thread-local. Biased locking protocols are distinguished by how many opportunities for optimization are found, and what performance trade-offs for non-local locks are experienced. Of particular concern is the relatively high cost involved in revoking the bias of a lock, which makes existing biased locking protocols susceptible to performance pathologies for programs with specific patterns of contention.

This work presents the biased locking protocol used in Jikes RVM, a high-throughput Java virtual machine. The protocol, dubbed FABLE, builds on prior work by adding per-object-instance dynamic adaptation and inexpensive bias revocation. We describe the protocol, detail how it was implemented, and use it in offering the most thorough evaluation of Java locking protocols to date. FABLE is shown to provide speed-ups over traditional Java locking across a broad spectrum of benchmarks while being robust to cases previous protocols handled poorly.

@inproceedings{Pizlo+2011PPPJ,
  author = {Pizlo, Filip and Frampton, Daniel and Hosking, Antony L.},
  title = {Fine-Grained Adaptive Biased Locking},
  booktitle = {International Conference on the Principles and Practice of
                    Programming on the Java platform: virtual machines,
                    languages, and tools},
  series = {PPPJ},
  year = {2011},
  pages = {171--181},
  month = {August},
  address = {Kongens Lyngby, Denmark},
  doi = {10.1145/2093157.2093184},
  acm = {http://dl.acm.org/authorize?N93654},
  gscholar = {9}
}