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.
This is a preview of subscription content, access via your institution.
Buying options
Preview
Unable to display preview. Download preview PDF.
References
Adve, S.V., Gharachorloo, K.: Shared Memory Consistency Models: A Tutorial. IEEE Computer 29(12), 66–76 (1996)
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)
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)
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)
Bacon, D.F.: Fast and Effective Optimization of Statically Typed Object-Oriented Languages. Ph.D. Thesis UCB/CSD-98-1017, University of California (1997)
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)
Blanchet, B.: Escape Analysis for Object-Oriented Languages: Application to Java. In: Proceedings of ACM OOPSLA 1999, pp. 20–34 (1999)
Bogda, J., Hölzle, U.: Removing Unnecessary Synchronization in Java. In: Proceedings of ACM OOPSLA 1999, pp. 35–46 (1999)
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)
Culler, D.E., Singh, J.P., Gupta, A.: Parallel Computer Architecture: A Hardware/Software Approach, pp. 681–700. Morgan Kaufmann, San Francisco (1999)
Dijkstra, E.W.: Solution of a Problem in Concurrent Programming and Control. Communications of the ACM 8(9), 569 (1965)
Dijkstra, E.W.: Cooperating Sequential Processes, pp. 43–112. Academic Press, New York (1968)
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)
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)
Gosling, J., Joy, B., Steele, G.: The Java Language Specification. Addison-Wesley, Reading (1996)
Greenwald, M., Cheriton, D.: The Synergy Between Non-blocking Synchronization and Operating System Structure. In: Proceedings of USENIX OSDI 1996, pp. 123–136 (1996)
Hoare, C.A.R.: Monitors: An Operating System Structuring Concept. Communications of the ACM 17(10), 549–557 (1974)
IBM developerWorks Java Technology Zone, http://www.ibm.com/developerworks/java/
Intel Corporation. IA-32 Intel Architecture Software Developer’s Manual Volume 3: System Programming Guide, Order Number 245472-010 (2002)
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)
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)
Lamport, L.: A Fast Mutual Exclusion Algorithm. ACM Transactions on Computer Systems 5(1), 1–11 (1987)
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)
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)
Onodera, T., Kawachiya, K.: A Study of Locking Objects with Bimodal Fields. In: Proceedings of ACM OOPSLA 1999, pp. 223–237 (1999)
Ousterhout, J.K.: Scheduling Techniques for Concurrent Systems. In: Proceedings of the 3rd International Conference on Distributed Computing Systems, pp. 22–30 (1982)
Park, Y.G., Goldberg, B.: Escape Analysis on Lists. In: Proceedings of ACM PLDI 1992, pp. 116–127 (1992)
Peterson, G.L.: Myths about the Mutual Exclusion Problem. Information Processing Letters 12(3), 115–116 (1981)
Ruf, E.: Effective Synchronization Removal for Java. In: Proceedings of ACM PLDI 2000, pp. 208–218 (2000)
Salcianu, A., Rinard, M.: Pointer and Escape Analysis for Multithreaded Programs. In: Proceedings of ACM PPoPP 2001, pp. 12–23 (2001)
Standard Performance Evaluation Corporation: SPEC JVM98 Benchmarks, http://www.spec.org/osg/jvm98/
Whaley, J., Rinard, M.: Compositional Pointer and Escape Analysis for Java Programs. In: Proceedings of ACM OOPSLA 1999, pp. 187–206 (1999)
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)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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