Abstract
A core, but often neglected, aspect of a programming language design is its memory (consistency) model. Sequential consistency~(SC) is the most intuitive memory model for programmers as it guarantees sequential composition of instructions and provides a simple abstraction of shared memory as a single global store with atomic read and writes. Unfortunately, SC is widely considered to be impractical due to its associated performance overheads.
Perhaps contrary to popular opinion, this paper demonstrates that SC is achievable with acceptable performance overheads for mainstream languages that minimize mutable shared heap. In particular, we modify the Glasgow Haskell Compiler to insert fences on all writes to shared mutable memory accessed in nonfunctional parts of the program. For a benchmark suite containing 1,279 programs, SC adds a geomean overhead of less than 0.4\% on an x86 machine.
The efficiency of SC arises primarily due to the isolation provided by the Haskell type system between purely functional and thread-local imperative computations on the one hand, and imperative computations on the global heap on the other. We show how to use new programming idioms to further reduce the SC overhead; these create a virtuous cycle of less overhead and even stronger semantic guarantees (static data-race freedom).
- criterion: a Haskell microbenchmarking library. http://www.serpentine.com/criterion/.Google Scholar
- S. Adve and K. Gharachorloo. Shared memory consistency models: a tutorial. Computer, 29(12):66--76, 1996. Google Scholar
Digital Library
- S. V. Adve and H.-J. Boehm. Memory models: A case for rethinking parallel languages and hardware. Commun. ACM, 53(8):90--101, Aug. 2010. Google Scholar
Digital Library
- S. V. Adve and M. D. Hill. Weak Ordering--A New Definition. In Proceedings of the Seventeenth International Symposium on Computer Architecture, pages 2--14, Seattle, WA, May 1990.Google Scholar
- J. Alglave, D. Kroening, V. Nimal, and D. Poetzl. Don't sit on the fence - A static analysis approach to automatic fence insertion. In Computer Aided Verification - 26th International Conference, CAV 2014, pages 508--524, 2014.Google Scholar
- C. Blundell, M. Martin, and T. Wenisch. InvisiFence: performance-transparent memory ordering in conventional multiprocessors. In ISCA '09, pages 233--244, 2009. Google Scholar
Digital Library
- R. L. Bocchino Jr, V. S. Adve, D. Dig, S. V. Adve, S. Heumann, R. Komuravelli, J. Overbey, P. Simmons, H. Sung, and M. Vakilian. A type and effect system for deterministic parallel java. ACM Sigplan Notices, 44(10):97--116, 2009. Google Scholar
Digital Library
- H.-J. Boehm and S. V. Adve. Foundations of the CGoogle Scholar
- Concurrency Memory Model. In Proceedings of the SIGPLAN 2008 Conference on Programming Language Design and Implementation, Tucson, AZ, June 2008.Google Scholar
- G. Boudol and G. Petri. Relaxed memory models: An operational approach. In Proceedings of the 36th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL '09, pages 392--403, New York, NY, USA, 2009. ACM. Google Scholar
Digital Library
- C. Boyapati, R. Lee, and M. Rinard. Ownership types for safe programming: Preventing data races and deadlocks. In OOPSLA '02, pages 211--230, 2002.Google Scholar
Digital Library
- C. Boyapati and M. Rinard. A parameterized type system for race-free Java programs. In OOPSLA '01, pages 56--69, 2001. Google Scholar
Digital Library
- L. Ceze, J. Tuck, P. Montesinos, and J. Torrellas. BulkSC: bulk enforcement of sequential consistency. In ISCA '07, pages 278--289, 2007. Google Scholar
Digital Library
- Y. Duan, A. Muzahid, and J. Torrellas. Weefence: Toward making fences free in TSO. In Proceedings of the 40th Annual International Symposium on Computer Architecture, ISCA '13, pages 213--224. ACM, 2013. Google Scholar
Digital Library
- C. Flanagan and S. N. Freund. FastTrack: Efficient and precise dynamic race detection. In Proceedings of the 2009 ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI '09, pages 121--133, New York, NY, USA, 2009. ACM. Google Scholar
Digital Library
- K. Gharachorloo, A. Gupta, and J. Hennessy. Two techniques to enhance the performance of memory consistency models. In Proceedings of the 1991 International Conference on Parallel Processing, ICPP '91, pages 355--364, 1991.Google Scholar
- C. S. Gordon, M. J. Parkinson, J. Parsons, A. Bromfield, and J. Duffy. Uniqueness and reference immutability for safe parallelism. SIGPLAN Not., 47(10):21--40, Oct. 2012. Google Scholar
Digital Library
- T. Harris, S. Marlow, S. Peyton-Jones, and M. Herlihy. Composable memory transactions. In Proceedings of the Tenth ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming, PPoPP '05, pages 48--60, New York, NY, USA, 2005. ACM. Google Scholar
Digital Library
- A. Kamil, J. Su, and K. Yelick. Making sequential consistency practical in Titanium. In Proceedings of the 2005 ACM/IEEE conference on Supercomputing, page 15. IEEE Computer Society, 2005. Google Scholar
Digital Library
- L. Kuper, A. Todd, S. Tobin-Hochstadt, and R. R. Newton. Taming the parallel effect zoo: Extensible deterministic parallelism with lvish. In Proceedings of the 35th ACM SIGPLAN Conference on Programming Language Design and Implementation, page 2. ACM, 2014. Google Scholar
Digital Library
- L. Kuper, A. Turon, N. R. Krishnaswami, and R. R. Newton. Freeze after writing: quasi-deterministic parallel programming with lvars. In POPL, pages 257--270, 2014. Google Scholar
Digital Library
- L. Lamport. How to make a multiprocessor computer that correctly executes multiprocess programs. IEEE transactions on computers, 100(9):690--691, 1979. Google Scholar
Digital Library
- J. Launchbury and S. L. Peyton Jones. Lazy functional state threads. In ACM SIGPLAN Notices, volume 29, pages 24--35. ACM, 1994. Google Scholar
Digital Library
- C. Lin, V. Nagarajan, R. Gupta, and B. Rajaram. Efficient sequential consistency via conflict ordering. In Proceedings of the Seventeenth International Conference on Architectural Support for Programming Languages and Operating Systems, ASPLOS XVII, pages 273--286, New York, NY, USA, 2012. ACM. Google Scholar
Digital Library
- J. M. Lucassen and D. K. Gifford. Polymorphic effect systems. In Proceedings of the 15th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL '88, pages 47--57, New York, NY, USA, 1988. ACM. Google Scholar
Digital Library
- P. Maier and P. Trinder. Implementing a high-level distributed-memory parallel haskell in haskell. In Implementation and Application of Functional Languages, pages 35--50. Springer, 2012. Google Scholar
Digital Library
- J. Manson, W. Pugh, and S. Adve. The Java Memory Model. In Conference Record of the Thirty-Second ACM Symposium on Principles of Programming Languages, Long Beach, CA, January 2005.Google Scholar
- D. Marino, A. Singh, T. Millstein, M. Musuvathi, and S. Narayanasamy. A case for an SC-preserving compiler. In Proceedings of the 32Nd ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI '11, pages 199--210, New York, NY, USA, 2011. ACM.Google Scholar
Digital Library
- S. Marlow, R. Newton, and S. Peyton Jones. A monad for deterministic parallelism. In Proceedings of the 4th ACM symposium on Haskell, Haskell '11, pages 71--82. ACM, 2011. Google Scholar
Digital Library
- K. Naden, R. Bocchino, J. Aldrich, and K. Bierhoff. A type system for borrowing permissions. In Proceedings of the 39th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL '12, pages 557--570, New York, NY, USA, 2012. ACM. Google Scholar
Digital Library
- M. Naik, A. Aiken, and J. Whaley. Effective static race detection for Java. In PLDI '06: Proceedings of the 2006 ACM SIGPLAN conference on Programming language design and implementation, pages 308--319, 2006. Google Scholar
Digital Library
- W. Partain. The nofib benchmark suite of Haskell programs. In Functional Programming, Glasgow 1992, Workshops in Computing, pages 195--202. Springer-Verlag, 1993. Google Scholar
Cross Ref
- S. Peyton Jones, A. Gordon, and S. Finne. Concurrent haskell. In Proceedings of the 23rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL '96, pages 295--308, New York, NY, USA, 1996. ACM. Google Scholar
Digital Library
- P. Pratikakis, J. S. Foster, and M. Hicks. LOCKSMITH: Context-sensitive correlation analysis for race detection. In Proceedings of the 2006 ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI '06, pages 320--331, New York, NY, USA, 2006. ACM. Google Scholar
Digital Library
- P. Ranganathan, V. S. Pai, and S. V. Adve. Using speculative retirement and larger instruction windows to narrow the performance gap between memory consistency models. In Proceedings of the Ninth Annual ACM Symposium on Parallel Algorithms and Architectures, SPAA '97, pages 199--210, New York, NY, USA, 1997. ACM. Google Scholar
Digital Library
- S. Sarkar, P. Sewell, F. Z. Nardelli, S. Owens, T. Ridge, T. Braibant, M. O. Myreen, and J. Alglave. The semantics of x86-cc multiprocessor machine code. SIGPLAN Not., 44(1):379--391, Jan. 2009. Google Scholar
Digital Library
- D. Shasha and M. Snir. Efficient and Correct Execution of Parallel Programs that Share Memory. TOPLAS, 10(2), 1988.Google Scholar
- A. Singh, S. Narayanasamy, D. Marino, T. Millstein, and M. Musuvathi. End-to-end sequential consistency. SIGARCH Comput. Archit. News, 40(3):524--535, June 2012. Google Scholar
Digital Library
- Z. Sura, X. Fang, C. Wong, S. Midkiff, J. Lee, and D. Padua. Compiler Techniques for High Performance Sequentially Consistent Java Programs. In PPoPP, 2005. Google Scholar
Digital Library
- K. Takeuchi, K. Honda, and M. Kubo. An interaction-based language and its typing system. In In PARLE'94, volume 817 of LNCS, pages 398--413. Springer-Verlag, 1994.Google Scholar
Cross Ref
- D. Terei, S. Marlow, S. Peyton Jones, and D. Mazières. Safe Haskell. In Proceedings of the 2012 Haskell Symposium, Haskell '12, pages 137--148, New York, NY, USA, 2012. ACM. Google Scholar
Digital Library
- J. Terrace, S. R. Beard, and N. P. K. Katta. JavaScript in JavaScript (js.js): Sandboxing third-party scripts. In Proceedings of the 3rd USENIX Conference on Web Application Development, WebApps'12, pages 9--9, Berkeley, CA, USA, 2012. USENIX Association.Google Scholar
Digital Library
- E. Z. Yang and D. Mazières. Dynamic Space Limits for Haskell. In Proceedings of the 35th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI '14, pages 588--598, New York, NY, USA, 2014. ACM. Google Scholar
Digital Library
Index Terms
SC-Haskell: Sequential Consistency in Languages That Minimize Mutable Shared Heap
Recommendations
SC-Haskell: Sequential Consistency in Languages That Minimize Mutable Shared Heap
PPoPP '17: Proceedings of the 22nd ACM SIGPLAN Symposium on Principles and Practice of Parallel ProgrammingA core, but often neglected, aspect of a programming language design is its memory (consistency) model. Sequential consistency~(SC) is the most intuitive memory model for programmers as it guarantees sequential composition of instructions and provides a ...
DRFX: a simple and efficient memory model for concurrent programming languages
PLDI '10The most intuitive memory model for shared-memory multithreaded programming is sequential consistency(SC), but it disallows the use of many compiler and hardware optimizations thereby impacting performance. Data-race-free (DRF) models, such as the ...
DRFX: a simple and efficient memory model for concurrent programming languages
PLDI '10: Proceedings of the 31st ACM SIGPLAN Conference on Programming Language Design and ImplementationThe most intuitive memory model for shared-memory multithreaded programming is sequential consistency(SC), but it disallows the use of many compiler and hardware optimizations thereby impacting performance. Data-race-free (DRF) models, such as the ...









Comments