The Optimistic Readers Transformation
Monitors, such as Java classes with synchronized methods, are a convenient and safe abstraction for designing and reasoning about multithreaded object-oriented programs. However, the straightforward implementation of monitors can be inefficient, particularly in programs in which the majority of calls are to read-only methods. We introduce the optimistic readers program transformation, which may be implemented either as a compiler optimization, or as a “design pattern.” This transformation produces an implementation whose observable behavior is equivalent to that of a monitor, but in which read-only methods do not acquire locks or perform any shared writes. As a result, programmers can reason about their programs as if each shared object were implemented using mutual exclusion, while achieving the performance benefits of unsynchronized reads. We present the program transformation using the platform-independent abstraction CRF. We then demonstrate the performance of this transformation as applied to benchmarks derived from the core module of a practical system — a Java-based publish-subscribe router. We compare the performance of the optimistic readers transformation to unoptimized synchronized methods and to reader and writer locks.
KeywordsShared Memory Hash Table Memory Model Version Number Instance Variable
Unable to display preview. Download preview PDF.
- 1.Bacon, D. F., Strom, R. E., and Tarafdar, A., “Guava: A Dialect of Java without Data Races,” In OOPSLA 2000 Conference Proceedings, pp. 382–400, October 2000.Google Scholar
- 2.Gharachorloo, K. “Memory Consistency Models for Shared Memory Multiprocessors, ” PhD thesis, Stanford University, 1995.Google Scholar
- 4.Pugh, W., “ Fixing the Java Memory Model”. In Proceeedings of the ACM Java Grande Conference, June 1999.Google Scholar
- 5.Pugh, W., “Semantics of Multithreaded Java”, URL: http://www.cs.umd.edu/~pugh/java/memoryModel/semantics.pdf
- 6.Maessen, J-W., Arvind, and Shen, X., “ Improving the Java Memory Model Using CRF”, In OOPSLA 2000 Conference Proceedings, pp. 1–12., October 2000.Google Scholar
- 7.Shen, X., Arvind, and Rudolph, L. “Commit-Reconcile and Fences (CRF): A New Memory Model for Architects and Compiler Writers” In Proceedings of the 26th International Symposium On Computer Architecture, Atlanta, Georgia, May 1999.Google Scholar
- 8.Java Memory Model Workshop, URL: http://www.cs.umd.edu/~pugh/java/memoryModel/workshop.
- 10.Banavar, G., Chandra, T., Mukherjee, B., Nagarajarao, J., Strom, R., and Sturman, D., “An Efficient Multicast Protocol for Content-based Publish-Subscribe Systems”, In Proceedings of the International Conference on Distributed Computing Systems, 1999.Google Scholar
- 11.Kung, H.T., and. Robinson, J.T., “On Optimistic Methods for Concurrency Control”, ACM TODS, v. 6, no. 2, pp. 213–226, June 1981.Google Scholar
- 12.Reiman, M., and. Wright, P.E., “Performance analysis of concurrent-read exclusivewrite”. In Joint International Conference on Measurement and Modeling of Computer Systems (ACM SIGMETRICS) San Diego, CA, Pages 168–177, May 1991.Google Scholar