现代编程语言的默认并发安全

IF 1.5 2区 计算机科学 Q3 COMPUTER SCIENCE, SOFTWARE ENGINEERING
Lun Liu, T. Millstein, M. Musuvathi
{"title":"现代编程语言的默认并发安全","authors":"Lun Liu, T. Millstein, M. Musuvathi","doi":"10.1145/3462206","DOIUrl":null,"url":null,"abstract":"Modern “safe” programming languages follow a design principle that we call\n safety by default\n and\n performance by choice\n . By default, these languages enforce important programming abstractions, such as memory and type safety, but they also provide mechanisms that allow expert programmers to explicitly trade some safety guarantees for increased performance. However, these same languages have adopted the inverse design principle in their support for multithreading. By default, multithreaded programs violate important abstractions, such as program order and atomic access to individual memory locations to admit compiler and hardware optimizations that would otherwise need to be restricted. Not only does this approach conflict with the design philosophy of safe languages, but very little is known about the practical performance cost of providing a stronger default semantics.\n \n \n In this article, we propose a safe-by-default and performance-by-choice multithreading semantics for safe languages, which we call\n \n volatile\n \n -by-default\n . Under this semantics, programs have\n sequential consistency\n (SC) by default, which is the natural “interleaving” semantics of threads. However, the\n volatile\n -by-default design also includes annotations that allow expert programmers to avoid the associated overheads in performance-critical code. We describe the design, implementation, optimization, and evaluation of the\n volatile\n -by-default semantics for two different safe languages: Java and Julia. First, we present\n V\n BD-HotSpot and\n V\n BDA-HotSpot, modifications of Oracle’s HotSpot JVM that enforce the\n volatile\n -by-default semantics on Intel x86-64 hardware and ARM-v8 hardware. Second, we present\n S\n C-Julia, a modification to the just-in-time compiler within the standard Julia implementation that provides best-effort enforcement of the\n volatile\n -by-default semantics on x86-64 hardware for the purpose of performance evaluation. We also detail two different implementation techniques: a\n baseline\n approach that simply reuses existing mechanisms in the compilers for handling atomic accesses, and a\n speculative\n approach that avoids the overhead of enforcing the\n volatile\n -by-default semantics until there is the possibility of an SC violation. Our results show that the cost of enforcing SC is significant but arguably still acceptable for some use cases today. Further, we demonstrate that compiler optimizations as well as programmer annotations can reduce the overhead considerably.","PeriodicalId":50939,"journal":{"name":"ACM Transactions on Programming Languages and Systems","volume":"3 1","pages":"10:1-10:50"},"PeriodicalIF":1.5000,"publicationDate":"2021-09-30","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"3","resultStr":"{\"title\":\"Safe-by-default Concurrency for Modern Programming Languages\",\"authors\":\"Lun Liu, T. Millstein, M. Musuvathi\",\"doi\":\"10.1145/3462206\",\"DOIUrl\":null,\"url\":null,\"abstract\":\"Modern “safe” programming languages follow a design principle that we call\\n safety by default\\n and\\n performance by choice\\n . By default, these languages enforce important programming abstractions, such as memory and type safety, but they also provide mechanisms that allow expert programmers to explicitly trade some safety guarantees for increased performance. However, these same languages have adopted the inverse design principle in their support for multithreading. By default, multithreaded programs violate important abstractions, such as program order and atomic access to individual memory locations to admit compiler and hardware optimizations that would otherwise need to be restricted. Not only does this approach conflict with the design philosophy of safe languages, but very little is known about the practical performance cost of providing a stronger default semantics.\\n \\n \\n In this article, we propose a safe-by-default and performance-by-choice multithreading semantics for safe languages, which we call\\n \\n volatile\\n \\n -by-default\\n . Under this semantics, programs have\\n sequential consistency\\n (SC) by default, which is the natural “interleaving” semantics of threads. However, the\\n volatile\\n -by-default design also includes annotations that allow expert programmers to avoid the associated overheads in performance-critical code. We describe the design, implementation, optimization, and evaluation of the\\n volatile\\n -by-default semantics for two different safe languages: Java and Julia. First, we present\\n V\\n BD-HotSpot and\\n V\\n BDA-HotSpot, modifications of Oracle’s HotSpot JVM that enforce the\\n volatile\\n -by-default semantics on Intel x86-64 hardware and ARM-v8 hardware. Second, we present\\n S\\n C-Julia, a modification to the just-in-time compiler within the standard Julia implementation that provides best-effort enforcement of the\\n volatile\\n -by-default semantics on x86-64 hardware for the purpose of performance evaluation. We also detail two different implementation techniques: a\\n baseline\\n approach that simply reuses existing mechanisms in the compilers for handling atomic accesses, and a\\n speculative\\n approach that avoids the overhead of enforcing the\\n volatile\\n -by-default semantics until there is the possibility of an SC violation. Our results show that the cost of enforcing SC is significant but arguably still acceptable for some use cases today. Further, we demonstrate that compiler optimizations as well as programmer annotations can reduce the overhead considerably.\",\"PeriodicalId\":50939,\"journal\":{\"name\":\"ACM Transactions on Programming Languages and Systems\",\"volume\":\"3 1\",\"pages\":\"10:1-10:50\"},\"PeriodicalIF\":1.5000,\"publicationDate\":\"2021-09-30\",\"publicationTypes\":\"Journal Article\",\"fieldsOfStudy\":null,\"isOpenAccess\":false,\"openAccessPdf\":\"\",\"citationCount\":\"3\",\"resultStr\":null,\"platform\":\"Semanticscholar\",\"paperid\":null,\"PeriodicalName\":\"ACM Transactions on Programming Languages and Systems\",\"FirstCategoryId\":\"94\",\"ListUrlMain\":\"https://doi.org/10.1145/3462206\",\"RegionNum\":2,\"RegionCategory\":\"计算机科学\",\"ArticlePicture\":[],\"TitleCN\":null,\"AbstractTextCN\":null,\"PMCID\":null,\"EPubDate\":\"\",\"PubModel\":\"\",\"JCR\":\"Q3\",\"JCRName\":\"COMPUTER SCIENCE, SOFTWARE ENGINEERING\",\"Score\":null,\"Total\":0}","platform":"Semanticscholar","paperid":null,"PeriodicalName":"ACM Transactions on Programming Languages and Systems","FirstCategoryId":"94","ListUrlMain":"https://doi.org/10.1145/3462206","RegionNum":2,"RegionCategory":"计算机科学","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"Q3","JCRName":"COMPUTER SCIENCE, SOFTWARE ENGINEERING","Score":null,"Total":0}
引用次数: 3

摘要

现代“安全”编程语言遵循一种设计原则,我们称之为默认安全性和选择性能。默认情况下,这些语言强制执行重要的编程抽象,比如内存和类型安全,但它们也提供了一些机制,允许专业程序员显式地牺牲一些安全保证来提高性能。然而,这些语言在支持多线程方面采用了相反的设计原则。默认情况下,多线程程序违反了重要的抽象,例如程序顺序和对单个内存位置的原子访问,以允许编译器和硬件优化,否则这些优化将需要受到限制。这种方法不仅与安全语言的设计理念相冲突,而且对于提供更强的默认语义的实际性能成本也知之甚少。在本文中,我们为安全语言提出了默认安全和性能选择多线程语义,我们称之为默认volatile。在这种语义下,程序默认具有顺序一致性(SC),这是线程的自然“交错”语义。然而,volatile -by-default设计还包括注释,这些注释允许专业程序员在性能关键型代码中避免相关的开销。我们描述了两种不同安全语言(Java和Julia)的默认volatile语义的设计、实现、优化和评估。首先,我们介绍了V BD-HotSpot和V BDA-HotSpot,它们是对Oracle的HotSpot JVM的修改,在Intel x86-64硬件和ARM-v8硬件上强制执行volatile -by-default语义。其次,我们介绍S C-Julia,这是对标准Julia实现中的即时编译器的修改,它在x86-64硬件上为性能评估提供了volatile -by-default语义的最佳实施。我们还详细介绍了两种不同的实现技术:一种是基线方法,它简单地重用编译器中的现有机制来处理原子访问;另一种是推测方法,它避免了强制执行volatile -by-default语义的开销,直到有可能违反SC。我们的结果表明,执行SC的成本是显著的,但是对于今天的一些用例来说仍然是可以接受的。此外,我们还演示了编译器优化以及程序员注释可以大大减少开销。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
Safe-by-default Concurrency for Modern Programming Languages
Modern “safe” programming languages follow a design principle that we call safety by default and performance by choice . By default, these languages enforce important programming abstractions, such as memory and type safety, but they also provide mechanisms that allow expert programmers to explicitly trade some safety guarantees for increased performance. However, these same languages have adopted the inverse design principle in their support for multithreading. By default, multithreaded programs violate important abstractions, such as program order and atomic access to individual memory locations to admit compiler and hardware optimizations that would otherwise need to be restricted. Not only does this approach conflict with the design philosophy of safe languages, but very little is known about the practical performance cost of providing a stronger default semantics. In this article, we propose a safe-by-default and performance-by-choice multithreading semantics for safe languages, which we call volatile -by-default . Under this semantics, programs have sequential consistency (SC) by default, which is the natural “interleaving” semantics of threads. However, the volatile -by-default design also includes annotations that allow expert programmers to avoid the associated overheads in performance-critical code. We describe the design, implementation, optimization, and evaluation of the volatile -by-default semantics for two different safe languages: Java and Julia. First, we present V BD-HotSpot and V BDA-HotSpot, modifications of Oracle’s HotSpot JVM that enforce the volatile -by-default semantics on Intel x86-64 hardware and ARM-v8 hardware. Second, we present S C-Julia, a modification to the just-in-time compiler within the standard Julia implementation that provides best-effort enforcement of the volatile -by-default semantics on x86-64 hardware for the purpose of performance evaluation. We also detail two different implementation techniques: a baseline approach that simply reuses existing mechanisms in the compilers for handling atomic accesses, and a speculative approach that avoids the overhead of enforcing the volatile -by-default semantics until there is the possibility of an SC violation. Our results show that the cost of enforcing SC is significant but arguably still acceptable for some use cases today. Further, we demonstrate that compiler optimizations as well as programmer annotations can reduce the overhead considerably.
求助全文
通过发布文献求助,成功后即可免费获取论文全文。 去求助
来源期刊
ACM Transactions on Programming Languages and Systems
ACM Transactions on Programming Languages and Systems 工程技术-计算机:软件工程
CiteScore
3.10
自引率
7.70%
发文量
28
审稿时长
>12 weeks
期刊介绍: ACM Transactions on Programming Languages and Systems (TOPLAS) is the premier journal for reporting recent research advances in the areas of programming languages, and systems to assist the task of programming. Papers can be either theoretical or experimental in style, but in either case, they must contain innovative and novel content that advances the state of the art of programming languages and systems. We also invite strictly experimental papers that compare existing approaches, as well as tutorial and survey papers. The scope of TOPLAS includes, but is not limited to, the following subjects: language design for sequential and parallel programming programming language implementation programming language semantics compilers and interpreters runtime systems for program execution storage allocation and garbage collection languages and methods for writing program specifications languages and methods for secure and reliable programs testing and verification of programs
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术官方微信