Skip to main content

Lock Reservation for Java Reconsidered

  • Conference paper

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 3086))

Abstract

Lock reservation, a powerful optimization for Java locks, is based on the observation that, in Java, each lock tends to be dominantly acquired and released by a specific thread. Reserving a lock for such a dominant thread allows the owner thread of the lock to acquire and release the lock without any atomic read-modify-write instructions.

A recently proposed algorithm has embodied this idea and significantly reduced the synchronization overhead on a reservation hit. However, on a reservation miss, the algorithm stops the owner thread in order to cancel the reservation, which incurs a significant performance penalty.

We propose a new algorithm for lock reservation for Java without such penalties. We derive the algorithm in two steps. First, we create a new, reservation-based algorithm for spin lock. Second, observing that the conventional spin lock is embedded in a widely-used Java lock, we attempt to replace it with our new spin lock.

We evaluated our algorithm in IBM’s production virtual machine and JIT compiler. The results show that our algorithm attained comparable speedups in the SPECjvm98 benchmarks, and that it even improved the performance of two scientific programs which the previous algorithm actually degraded.

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   84.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   109.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Adve, S.V., Gharachorloo, K.: Shared Memory Consistency Models: A Tutorial. IEEE Computer 29(12), 66–76 (1996)

    Google Scholar 

  2. Anderson, T.E.: The Performance of Spin Lock Alternatives for Shared-Memory Multiprocessors. IEEE Transactions on Parallel and Distributed Systems 1(1), 6–16 (1990)

    Article  Google Scholar 

  3. Agesen, O., Detlefs, D., Garthwaite, A., Knippel, R., Ramakrishna, Y.S., White, D.: An Efficient Meta-lock for Implementing Ubiquitous Synchronization. In: Proceedings of ACM OOPSLA 1999, pp. 207–222 (1999)

    Google Scholar 

  4. Aldrich, J., Chambers, C., Sirer, E.G., Eggers, S.: Static Analyses for Eliminating Unnecessary Synchronization from Java Programs. In: Cortesi, A., Filé, G. (eds.) SAS 1999. LNCS, vol. 1694, pp. 19–38. Springer, Heidelberg (1999)

    Chapter  Google Scholar 

  5. Bacon, D.F.: Fast and Effective Optimization of Statically Typed Object-Oriented Languages. Ph.D. Thesis UCB/CSD-98-1017, University of California (1997)

    Google Scholar 

  6. Bacon, D.F., Konuru, R., Murthy, C., Serrano, M.: Thin Locks: Featherweight Synchronization for Java. In: Proceedings of ACM PLDI 1998, pp. 258–268 (1998)

    Google Scholar 

  7. Blanchet, B.: Escape Analysis for Object-Oriented Languages: Application to Java. In: Proceedings of ACM OOPSLA 1999, pp. 20–34 (1999)

    Google Scholar 

  8. Bogda, J., Hölzle, U.: Removing Unnecessary Synchronization in Java. In: Proceedings of ACM OOPSLA 1999, pp. 35–46 (1999)

    Google Scholar 

  9. Choi, J.-D., Gupta, M., Serrano, M., Sreedhar, V.C., Midkiff, S.: Escape Analysis for Java. In: Proceedings of ACM OOPSLA 1999, pp. 1–19 (1999)

    Google Scholar 

  10. Culler, D.E., Singh, J.P., Gupta, A.: Parallel Computer Architecture: A Hardware/Software Approach, pp. 681–700. Morgan Kaufmann, San Francisco (1999)

    Google Scholar 

  11. Dijkstra, E.W.: Solution of a Problem in Concurrent Programming and Control. Communications of the ACM 8(9), 569 (1965)

    Article  Google Scholar 

  12. Dijkstra, E.W.: Cooperating Sequential Processes, pp. 43–112. Academic Press, New York (1968)

    Google Scholar 

  13. Gagnon, E.M., Hendren, L.J.: SableVM: A Research Framework for the Efficient Execution of Java Bytecode. In: Proceedings of USENIX JVM 2001, pp. 27–39 (2001)

    Google Scholar 

  14. Gomes, B.A., Bak, L., Stoutamire, D.P.: Method and Apparatus for Speculatively Locking Objects in an Object-Based System. United States Patent, US 6,487,652 B1 (2002)

    Google Scholar 

  15. Gosling, J., Joy, B., Steele, G.: The Java Language Specification. Addison-Wesley, Reading (1996)

    MATH  Google Scholar 

  16. Greenwald, M., Cheriton, D.: The Synergy Between Non-blocking Synchronization and Operating System Structure. In: Proceedings of USENIX OSDI 1996, pp. 123–136 (1996)

    Google Scholar 

  17. Hoare, C.A.R.: Monitors: An Operating System Structuring Concept. Communications of the ACM 17(10), 549–557 (1974)

    Article  MATH  Google Scholar 

  18. IBM developerWorks Java Technology Zone, http://www.ibm.com/developerworks/java/

  19. Intel Corporation. IA-32 Intel Architecture Software Developer’s Manual Volume 3: System Programming Guide, Order Number 245472-010 (2002)

    Google Scholar 

  20. Karlin, A.R., Li, K., Manasse, M.S., Owicki, S.: Empirical Studies of Competitive Spinning for A Shared-Memory Multiprocessor. In: Proceedings of ACM SOSP 1991, pp. 41–55 (1991)

    Google Scholar 

  21. Kawachiya, K., Koseki, A., Onodera, T.: Lock Reservation: Java Locks Can Mostly Do Without Atomic Operations. In: Proceedings of ACM OOPSLA 2002, pp. 131–141 (2002)

    Google Scholar 

  22. Lamport, L.: A Fast Mutual Exclusion Algorithm. ACM Transactions on Computer Systems 5(1), 1–11 (1987)

    Article  Google Scholar 

  23. Mellor-Crummey, J.M., Scott, M.L.: Algorithms for Scalable Synchronization on Shared-Memory Multiprocessors. ACM Transactions on Computer Systems 9(1), 21–65 (1991)

    Article  Google Scholar 

  24. Muller, G., Moura, B., Bellard, F., Consel, C.: Harissa: A Flexible and Efficient Java Environment Mixing Bytecode and Compiled Code. In: Proceedings of the 3rd USENIX Conference on Object Oriented Technologies and Systems (COOTS 1997), pp. 1–20 (1997)

    Google Scholar 

  25. Onodera, T., Kawachiya, K.: A Study of Locking Objects with Bimodal Fields. In: Proceedings of ACM OOPSLA 1999, pp. 223–237 (1999)

    Google Scholar 

  26. Ousterhout, J.K.: Scheduling Techniques for Concurrent Systems. In: Proceedings of the 3rd International Conference on Distributed Computing Systems, pp. 22–30 (1982)

    Google Scholar 

  27. Park, Y.G., Goldberg, B.: Escape Analysis on Lists. In: Proceedings of ACM PLDI 1992, pp. 116–127 (1992)

    Google Scholar 

  28. Peterson, G.L.: Myths about the Mutual Exclusion Problem. Information Processing Letters 12(3), 115–116 (1981)

    Article  MATH  Google Scholar 

  29. Ruf, E.: Effective Synchronization Removal for Java. In: Proceedings of ACM PLDI 2000, pp. 208–218 (2000)

    Google Scholar 

  30. Salcianu, A., Rinard, M.: Pointer and Escape Analysis for Multithreaded Programs. In: Proceedings of ACM PPoPP 2001, pp. 12–23 (2001)

    Google Scholar 

  31. Standard Performance Evaluation Corporation: SPEC JVM98 Benchmarks, http://www.spec.org/osg/jvm98/

  32. Whaley, J., Rinard, M.: Compositional Pointer and Escape Analysis for Java Programs. In: Proceedings of ACM OOPSLA 1999, pp. 187–206 (1999)

    Google Scholar 

  33. Woo, S.C., Ohara, M., Torrie, E., Singh, J.P., Gupta, A.: The SPLASH-2 Programs: Characterization and Methodological Considerations. In: Proceedings of ACM ISCA 1995, pp. 12–23 (1995)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2004 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Onodera, T., Kawachiya, K., Koseki, A. (2004). Lock Reservation for Java Reconsidered. In: Odersky, M. (eds) ECOOP 2004 – Object-Oriented Programming. ECOOP 2004. Lecture Notes in Computer Science, vol 3086. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-24851-4_26

Download citation

  • DOI: https://doi.org/10.1007/978-3-540-24851-4_26

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-22159-3

  • Online ISBN: 978-3-540-24851-4

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics