SAW: Java Synchronization Selection from Lock or Software Transactional Memory

To rewrite a sequential program into a concurrent one, the programmer has to enforce atomic execution of a sequence of accesses to shared memory to avoid unexpected inconsistency. There are two means of enforcing this atomicity: one is the use of lock-based synchronization and the other is the use of software transactional memory (STM). However, it is difficult to predict which one is more suitable for an application than the other without trying both mechanisms because their performance heavily depends on the application. We have developed a system named \emph{SAW} that decouples the synchronization mechanism from the application logic of a Java program and enables the programmer to statically select a suitable synchronization mechanism from a lock or an STM. We introduce annotations to specify critical sections and shared objects. In accordance with the annotated source program and the programmer's choice of a synchronization mechanism, SAW generates aspects representing the synchronization processing. By comparing the rewriting cost using SAW and that using individual synchronization mechanism directly, we show that SAW relieves the programmer's burden. Through several benchmarks, we demonstrate that SAW is an effective way of switching synchronization mechanisms according to the characteristics of each application.

[1]  Antony L. Hosking,et al.  Nested transactional memory: Model and architecture sketches , 2006, Sci. Comput. Program..

[2]  Michael F. Spear Lightweight, robust adaptivity for software transactional memory , 2010, SPAA '10.

[3]  Adam Welc,et al.  Practical weak-atomicity semantics for java stm , 2008, SPAA '08.

[4]  David Gay,et al.  Autolocker: synchronization inference for atomic sections , 2006, POPL '06.

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

[6]  Yannis Smaragdakis,et al.  Adaptive Locks: Combining Transactions and Locks for Efficient Concurrency , 2009, 2009 18th International Conference on Parallel Architectures and Compilation Techniques.

[7]  Virendra J. Marathe,et al.  Adaptive Software Transactional Memory , 2005, DISC.

[8]  Kunle Olukotun,et al.  STAMP: Stanford Transactional Applications for Multi-Processing , 2008, 2008 IEEE International Symposium on Workload Characterization.

[9]  Bratin Saha,et al.  McRT-STM: a high performance software transactional memory system for a multi-core runtime , 2006, PPoPP '06.

[10]  Charles Zhang FlexSync: An aspect-oriented approach to Java synchronization , 2009, 2009 IEEE 31st International Conference on Software Engineering.

[11]  Frank Tip,et al.  Associating synchronization constraints with data in an object-oriented language , 2006, POPL '06.

[12]  Nir Shavit,et al.  Software transactional memory , 1995, PODC '95.

[13]  Torvald Riegel,et al.  Dynamic performance tuning of word-based software transactional memory , 2008, PPoPP.

[14]  Nir Shavit,et al.  Transactional Locking II , 2006, DISC.

[15]  David Eisenstat,et al.  Lowering the Overhead of Software Transactional Memory , 2006 .

[16]  J. Eliot B. Moss Open Nested Transactions: Semantics and Support , 2006 .

[17]  Martín Abadi,et al.  Semantics of transactional memory and automatic mutual exclusion , 2011, TOPL.

[18]  Shigeru Chiba,et al.  Extending AspectJ for separating regions , 2009, GPCE '09.

[19]  Torvald Riegel,et al.  Snapshot Isolation for Software Transactional Memory , 2006 .

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

[21]  Maurice Herlihy,et al.  A flexible framework for implementing software transactional memory , 2006, OOPSLA '06.