Combining Lock Inference with Lock-Based Software Transactional Memory

Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8664)


An atomic block is a language construct that simplifies the programming of critical sections. In the past, software transactional memory (STM) and lock inference have been used to implement atomic blocks. Both approaches have strengths and weaknesses. STM provides fine-grained locking but has high overheads due to logging and potential rollbacks. Lock inference is a static analysis that computes which locks an atomic block must acquire in order to guarantee atomicity. Lock inference avoids both logging overhead and rollbacks, but with a growing number of variables accessed in an atomic block, locking becomes coarse-grained and hence reduces parallelism.

The first contribution of this paper is an approach that combines these advantages without the drawbacks. A compiler analysis determines if lock inference can achieve a fine-grained synchronization or if STM is better for an atomic block. The generated code then either uses lock inference, STM, or a combination of both that allows the atomic block to switch from STM to lock inference during its execution. The second contribution are two optimizations that remove some of the limits of state-of-the-art static lock inference analysis and therefore extend its applicability. These optimizations make more atomic blocks amenable to fine-grained lock inference.

We use the STAMP benchmark suite to prove the practicability of our work. The reduced contention due to fine-grained locking and less transactional overhead lead to execution times that are between \(1.1\) and \(6.0\) times faster than a pure STM or lock inference implementation.


  1. 1.
    Bronson, N.G., Casper, J., Chafi, H., Olukotun, K.: A practical concurrent binary search tree. In: PPoPP’10: Proceedings of the Symposium on Principles and Practice Parallel Programming, Bangalore, India, pp. 257–268, Jan 2010Google Scholar
  2. 2.
    Bronson, N.G., Casper, J., Chafi, H., Olukotun, K.: Transactional predication: high-performance concurrent sets and maps for STM. In: PODC’10: Proceedings of the Symposium on Principles of Distributed Computing, Zurich, Switzerland, pp. 6–15, Jul 2010Google Scholar
  3. 3.
    Cao Minh, C., Chung, J., Kozyrakis, C., Olukotun, K.: STAMP: stanford transactional applications for multi-processing. In: Proceedings of the Symposium on Workload Characterization (IISWC’08), Seattle, WA, pp. 35–46, Sep 2008Google Scholar
  4. 4.
    Dragojević, A., Guerraoui, R., Kapalka, M.: Stretching transactional memory. In: PLDI ’09: Proceedings of the Conference on Programming Language Design and Implementation, Dublin, Ireland, pp. 155–165, June 2009Google Scholar
  5. 5.
    Fomitchev, M., Ruppert, E.: Lock-free linked lists and skip lists. In: PODC’04: Proceedings of the Symposium on Principles of Distributed Computing, St. John’s, Newfoundland, Canada, pp. 50–59, Jul 2004Google Scholar
  6. 6.
    Golan-Gueta, G., Bronson, N., Aiken, A., Ramalingam, G., Sagiv, M., Yahav, E.: Automatic fine-grain locking using shape properties. In: OOPSLA’11: Proceedings of the International Conference on Object Oriented Programming Systems Languages and Applications, Portland, OR, pp. 225–242, Oct 2011Google Scholar
  7. 7.
    Gudka, K., Harris, T., Eisenbach, S.: Lock inference in the presence of large libraries. In: Noble, J. (ed.) ECOOP 2012. LNCS, vol. 7313, pp. 308–332. Springer, Heidelberg (2012) CrossRefGoogle Scholar
  8. 8.
    Herlihy, M., Koskinen, E.: Transactional boosting: a methodology for highly-concurrent transactional objects. In: PPoPP’08: Proceedings of the Symposium on Principles and Practice Parallel Programming, Salt Lake City, UT, pp. 207–216, Feb 2008Google Scholar
  9. 9.
    Herlihy, M., Moss, J.E.B.: Transactional memory: architectural support for lock-free data structures. ACM SIGARCH Comput. Archit. News 21(2), 289–300 (1993)CrossRefGoogle Scholar
  10. 10.
    Hicks, M., Foster, J.S., Prattikakis, P.: Lock inference for atomic sections. In: Proceedings of the Workshop on Languages, Compilers, and Hardware Support for Transactional Computing (TRANSACT’06), Ottawa, Canada, pp. 304–315, June 2006Google Scholar
  11. 11.
    Kulkarni, M., Pingali, K., Walter, B., Ramanarayanan, G., Bala, K., Chew, L.P.: Optimistic parallelism requires abstractions. In: PLDI ’07: Proceedings of the Conference on Programming Language Design and Implementation, PLDI ’07, San Diego, CA, pp. 211–222, June 2007Google Scholar
  12. 12.
    Lattner, C., Adve, V.: LLVM: a compilation framework for lifelong program analysis and transformation. In: CGO’04: Proceedings of the International Symposium on Code Generation and Optimization, Palo Alto, CA, pp. 75–85, March 2004Google Scholar
  13. 13.
    Michael, M.M.: Hazard pointers: safe memory reclamation for lock-free objects. IEEE Trans. Parallel Distrib. Syst. 15(6), 491–504 (2004)CrossRefGoogle Scholar
  14. 14.
    Saltz, J.H., Mirchandaney, R., Crowley, K.: Run-time parallelization and scheduling of loops. IEEE Trans. Comput. 40(5), 603–612 (1991)CrossRefGoogle Scholar
  15. 15.
    Usui, T., Behrends, R., Evans, J., Smaragdakis, Y.: Adaptive locks: Combining transactions and locks for efficient concurrency. In: PACT’09: Proceedings of the International Conference on Parallel Architectures and Compilation Techniques, Raleigh, NC, pp. 3–14, Sep 2009Google Scholar
  16. 16.
    Wamhoff, J.T., Fetzer, C., Felber, P., Rivière, E., Muller, G.: FastLane: improving performance of software transactional memory for low thread counts. In: PPoPP’13: Proceedings of the Symposium on Principles and Practice Parallel Programming, Shenzhen, China, pp. 113–122, Feb 2013Google Scholar
  17. 17.
    Zhang, Y., Sreedhar, V.C., Zhu, W., Sarkar, V., Gao, G.R.: Minimum lock assignment: a method for exploiting concurrency among critical sections. In: Amaral, J.N. (ed.) LCPC 2008. LNCS, vol. 5335, pp. 141–155. Springer, Heidelberg (2008) CrossRefGoogle Scholar

Copyright information

© Springer International Publishing Switzerland 2014

Authors and Affiliations

  • Stefan Kempf
    • 1
  • Ronald Veldema
    • 1
  • Michael Philippsen
    • 1
  1. 1.Computer Science Department, Programming Systems GroupUniversity of Erlangen-NurembergErlangenGermany

Personalised recommendations