Transparently Reconciling Transactions with Locking for Java Synchronization

Concurrent data accesses in high-level languages like Java and C# are typically mediated using mutual-exclusion locks. Threads use locks to guard the operations performed while the lock is held, so that the lock's guarded operations can never be interleaved with operations of other threads that are guarded by the same lock. This way both atomicity and isolation properties of a thread's guarded operations are enforced. Recent proposals recognize that these properties can also be enforced by concurrency control protocols that avoid well-known problems associated with locking, by transplanting notions of transactions found in database systems to a programming language context. While higher-level than locks, software transactions incur significant implementation overhead. This overhead cannot be easily masked when there is little contention on the operations being guarded. We show how mutual-exclusion locks and transactions can be reconciled transparently within Java's monitor abstraction. We have implemented monitors for Java that execute using locks when contention is low and switch over to transactions when concurrent attempts to enter the monitor are detected. We formally argue the correctness of our solution with respect to Java's execution semantics and provide a detailed performance evaluation for different workloads and varying levels of contention. We demonstrate that our implementation has low overheads in the uncontended case (7% on average) and that significant performance improvements (up to 3×) can be achieved from running contended monitors transactionally.

[1]  Thomas R. Gross,et al.  Static conflict analysis for multi-threaded object-oriented programs , 2003, PLDI '03.

[2]  Keir Fraser,et al.  Language support for lightweight transactions , 2003, SIGP.

[3]  Erik Ruf,et al.  Effective synchronization removal for Java , 2000, PLDI '00.

[4]  Maurice Herlihy,et al.  Apologizing versus asking permission: optimistic concurrency control for abstract data types , 1990, TODS.

[5]  David J. DeWitt,et al.  The 007 Benchmark , 1993, SIGMOD '93.

[6]  Matthias Felleisen,et al.  Classes and mixins , 1998, POPL '98.

[7]  Emin Gün Sirer,et al.  Comprehensive synchronization elimination for Java , 2003, Sci. Comput. Program..

[8]  Jeremy Manson,et al.  The Java memory model , 2005, POPL '05.

[9]  L.A. Smith,et al.  A Parallel Java Grande Benchmark Suite , 2001, ACM/IEEE SC 2001 Conference (SC'01).

[10]  Stephen N. Freund,et al.  Atomizer: A dynamic atomicity checker for multithreaded programs , 2008, Sci. Comput. Program..

[11]  V. T. Rajan,et al.  A real-time garbage collector with low overhead and consistent utilization , 2003, POPL '03.

[12]  David J. DeWitt,et al.  The oo7 Benchmark , 1993, SIGMOD Conference.

[13]  Jong-Deok Choi,et al.  Efficient and precise datarace detection for multithreaded object-oriented programs , 2002, PLDI '02.

[14]  David J. DeWitt,et al.  A Status Report on the oo7 OODBMS Benchmarking Effort , 1994, OOPSLA.

[15]  Jong-Deok Choi,et al.  Hybrid dynamic data race detection , 2003, PPoPP '03.

[16]  Martin C. Rinard,et al.  ACM Conference on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA), November 2002 Ownership Types for Safe Programming: Preventing Data Races and Deadlocks , 2022 .

[17]  Bowen Alpern,et al.  Implementing jalapeño in Java , 1999, OOPSLA '99.

[18]  John M. Mellor-Crummey,et al.  On-the-fly detection of data races for programs with nested fork-join parallelism , 1991, Proceedings of the 1991 ACM/IEEE Conference on Supercomputing (Supercomputing '91).

[19]  J. T. Robinson,et al.  On optimistic methods for concurrency control , 1979, TODS.

[20]  Simon L. Peyton Jones,et al.  Composable memory transactions , 2005, CACM.

[21]  Y. S. Ramakrishna,et al.  An efficient meta-lock for implementing ubiquitous synchronization , 1999, OOPSLA '99.

[22]  Stephen M. Blackburn,et al.  Barriers: friend or foe? , 2004, ISMM '04.

[23]  Suresh Jagannathan,et al.  Concurrency Analysis for Java , 2000, SAS.

[24]  James Noble,et al.  Ownership types for flexible alias protection , 1998, OOPSLA '98.

[25]  Michael Stonebraker,et al.  Readings in Database Systems , 1988 .

[26]  Suresh Jagannathan,et al.  Transactional Monitors for Concurrent Objects , 2004, ECOOP.

[27]  Thomas R. Gross,et al.  Object race detection , 2001, OOPSLA '01.

[28]  Readings in Database Systems, Third Edition , 1998 .

[29]  Maurice Herlihy,et al.  Software transactional memory for dynamic-sized data structures , 2003, PODC '03.

[30]  Cormac Flanagan,et al.  Types for atomicity , 2003, TLDI '03.

[31]  E. B. Moss,et al.  Nested Transactions: An Approach to Reliable Distributed Computing , 1985 .

[32]  Mauricio J. Serrano,et al.  Thin locks: featherweight Synchronization for Java , 2004, SIGP.

[33]  Michael Burrows,et al.  Eraser: a dynamic data race detector for multithreaded programs , 1997, TOCS.

[34]  Stephen N. Freund,et al.  Type-based race detection for Java , 2000, PLDI '00.

[35]  Robert Gruber,et al.  Efficient optimistic concurrency control using loosely synchronized clocks , 1995, SIGMOD '95.