Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
10.1145/3018743.3018746acmconferencesArticle/Chapter ViewAbstractPublication PagesppoppConference Proceedingsconference-collections
research-article
Public Access

SC-Haskell: Sequential Consistency in Languages That Minimize Mutable Shared Heap

Published: 26 January 2017 Publication History

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).

References

[1]
criterion: a Haskell microbenchmarking library. http://www.serpentine.com/criterion/.
[2]
S. Adve and K. Gharachorloo. Shared memory consistency models: a tutorial. Computer, 29(12):66--76, 1996.
[3]
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.
[4]
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.
[5]
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.
[6]
C. Blundell, M. Martin, and T. Wenisch. InvisiFence: performance-transparent memory ordering in conventional multiprocessors. In ISCA '09, pages 233--244, 2009.
[7]
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.
[8]
H.-J. Boehm and S. V. Adve. Foundations of the C
[9]
Concurrency Memory Model. In Proceedings of the SIGPLAN 2008 Conference on Programming Language Design and Implementation, Tucson, AZ, June 2008.
[10]
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.
[11]
C. Boyapati, R. Lee, and M. Rinard. Ownership types for safe programming: Preventing data races and deadlocks. In OOPSLA '02, pages 211--230, 2002.
[12]
C. Boyapati and M. Rinard. A parameterized type system for race-free Java programs. In OOPSLA '01, pages 56--69, 2001.
[13]
L. Ceze, J. Tuck, P. Montesinos, and J. Torrellas. BulkSC: bulk enforcement of sequential consistency. In ISCA '07, pages 278--289, 2007.
[14]
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.
[15]
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.
[16]
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.
[17]
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.
[18]
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.
[19]
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.
[20]
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.
[21]
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.
[22]
L. Lamport. How to make a multiprocessor computer that correctly executes multiprocess programs. IEEE transactions on computers, 100(9):690--691, 1979.
[23]
J. Launchbury and S. L. Peyton Jones. Lazy functional state threads. In ACM SIGPLAN Notices, volume 29, pages 24--35. ACM, 1994.
[24]
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.
[25]
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.
[26]
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.
[27]
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.
[28]
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.
[29]
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.
[30]
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.
[31]
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.
[32]
W. Partain. The nofib benchmark suite of Haskell programs. In Functional Programming, Glasgow 1992, Workshops in Computing, pages 195--202. Springer-Verlag, 1993.
[33]
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.
[34]
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.
[35]
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.
[36]
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.
[37]
D. Shasha and M. Snir. Efficient and Correct Execution of Parallel Programs that Share Memory. TOPLAS, 10(2), 1988.
[38]
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.
[39]
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.
[40]
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.
[41]
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.
[42]
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.
[43]
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.

Cited By

View all
  • (2023)Parallelism in a Region Inference ContextProceedings of the ACM on Programming Languages10.1145/35912567:PLDI(884-906)Online publication date: 6-Jun-2023
  • (2019)Accelerating sequential consistency for Java with speculative compilationProceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and Implementation10.1145/3314221.3314611(16-30)Online publication date: 8-Jun-2019
  • (2017)Adaptive lock-free data structures in Haskell: a general method for concurrent implementation swappingACM SIGPLAN Notices10.1145/3156695.312297352:10(197-211)Online publication date: 7-Sep-2017
  • Show More Cited By

Recommendations

Reviews

Jacques Carette

Concurrency remains a hard problem. Efficient concurrency is even harder. But what if there were a setting where writing correct concurrent programs was significantly easier, at a very modest cost in efficiency Too good to be true, right But this is exactly what the authors show for Haskell and similar languages, which naturally promote minimal use of shared heap mutation. The most fundamental invariant in this setting is sequential consistency (SC), a very natural memory model to program with. The authors modify GHC, the main Haskell compiler, to enforce SC. They then extensively benchmark this in a variety of situations, and convincingly show that their solution not only works, but its overhead is remarkably small. One sometimes finds, buried behind a technically accurate title, a superb paper. While not a fundamental breakthrough, this paper is nevertheless scholarship at its best: well written, carefully motivated, based on extremely precise (and fully spelled out) theory, implemented in a real setting, and aggressively benchmarked in an adversarial manner (the authors go out of their way to show worst-case results). And as is increasingly standard, the full source is provided. They also go beyond this, proving preloaded virtual machines to allow independent verification. I will use this paper as an exemplar to my graduate students. Unsurprisingly, such work did uncover a couple of bugs in GHC (as documented in the paper). While the paper says that these would be fixed by GHC 8.2, it turns out that the bug fixes were already implemented in version 8.0.2, as a bit of spelunking in the public bug database reveals. Any referee depressed with all of the rotten papers they've been forced to read can gain a respite by reading this great paper, to remind them that there are excellent papers out there-whether or not they have any particular interest in Haskell or concurrency. Online Computing Reviews Service

Access critical reviews of Computing literature here

Become a reviewer for Computing Reviews.

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
PPoPP '17: Proceedings of the 22nd ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming
January 2017
476 pages
ISBN:9781450344937
DOI:10.1145/3018743
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 26 January 2017

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. functional programming
  2. memory models
  3. sequential consistency

Qualifiers

  • Research-article

Funding Sources

Conference

PPoPP '17
Sponsor:

Acceptance Rates

PPoPP '17 Paper Acceptance Rate 29 of 132 submissions, 22%;
Overall Acceptance Rate 230 of 1,014 submissions, 23%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)174
  • Downloads (Last 6 weeks)38
Reflects downloads up to 09 Nov 2024

Other Metrics

Citations

Cited By

View all
  • (2023)Parallelism in a Region Inference ContextProceedings of the ACM on Programming Languages10.1145/35912567:PLDI(884-906)Online publication date: 6-Jun-2023
  • (2019)Accelerating sequential consistency for Java with speculative compilationProceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and Implementation10.1145/3314221.3314611(16-30)Online publication date: 8-Jun-2019
  • (2017)Adaptive lock-free data structures in Haskell: a general method for concurrent implementation swappingACM SIGPLAN Notices10.1145/3156695.312297352:10(197-211)Online publication date: 7-Sep-2017
  • (2017)Adaptive lock-free data structures in Haskell: a general method for concurrent implementation swappingProceedings of the 10th ACM SIGPLAN International Symposium on Haskell10.1145/3122955.3122973(197-211)Online publication date: 7-Sep-2017
  • (2021)A Survey of Programming Language Memory ModelsProgramming and Computing Software10.1134/S036176882106005047:6(439-456)Online publication date: 3-Dec-2021

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Get Access

Login options

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media