Advertisement

Lock Reservation for Java Reconsidered

  • Tamiya Onodera
  • Kikyokuni Kawachiya
  • Akira Koseki
Conference paper
Part of the Lecture Notes in Computer Science book series (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.

Keywords

Virtual Machine Synchronization Overhead Program Order Spin Lock Lock State 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Adve, S.V., Gharachorloo, K.: Shared Memory Consistency Models: A Tutorial. IEEE Computer 29(12), 66–76 (1996)Google Scholar
  2. 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)CrossRefGoogle Scholar
  3. 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. 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)CrossRefGoogle Scholar
  5. 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. 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. 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. 8.
    Bogda, J., Hölzle, U.: Removing Unnecessary Synchronization in Java. In: Proceedings of ACM OOPSLA 1999, pp. 35–46 (1999)Google Scholar
  9. 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. 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. 11.
    Dijkstra, E.W.: Solution of a Problem in Concurrent Programming and Control. Communications of the ACM 8(9), 569 (1965)CrossRefGoogle Scholar
  12. 12.
    Dijkstra, E.W.: Cooperating Sequential Processes, pp. 43–112. Academic Press, New York (1968)Google Scholar
  13. 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. 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. 15.
    Gosling, J., Joy, B., Steele, G.: The Java Language Specification. Addison-Wesley, Reading (1996)zbMATHGoogle Scholar
  16. 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. 17.
    Hoare, C.A.R.: Monitors: An Operating System Structuring Concept. Communications of the ACM 17(10), 549–557 (1974)zbMATHCrossRefGoogle Scholar
  18. 18.
    IBM developerWorks Java Technology Zone, http://www.ibm.com/developerworks/java/
  19. 19.
    Intel Corporation. IA-32 Intel Architecture Software Developer’s Manual Volume 3: System Programming Guide, Order Number 245472-010 (2002)Google Scholar
  20. 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. 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. 22.
    Lamport, L.: A Fast Mutual Exclusion Algorithm. ACM Transactions on Computer Systems 5(1), 1–11 (1987)CrossRefGoogle Scholar
  23. 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)CrossRefGoogle Scholar
  24. 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. 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. 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. 27.
    Park, Y.G., Goldberg, B.: Escape Analysis on Lists. In: Proceedings of ACM PLDI 1992, pp. 116–127 (1992)Google Scholar
  28. 28.
    Peterson, G.L.: Myths about the Mutual Exclusion Problem. Information Processing Letters 12(3), 115–116 (1981)zbMATHCrossRefGoogle Scholar
  29. 29.
    Ruf, E.: Effective Synchronization Removal for Java. In: Proceedings of ACM PLDI 2000, pp. 208–218 (2000)Google Scholar
  30. 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. 31.
    Standard Performance Evaluation Corporation: SPEC JVM98 Benchmarks, http://www.spec.org/osg/jvm98/
  32. 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. 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

Copyright information

© Springer-Verlag Berlin Heidelberg 2004

Authors and Affiliations

  • Tamiya Onodera
    • 1
  • Kikyokuni Kawachiya
    • 1
  • Akira Koseki
    • 1
  1. 1.IBM Research, Tokyo Research LaboratoryKanagawa-kenJapan

Personalised recommendations