paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Safe-by-default Concurrency for Modern Programming Languages

现代编程语言的安全默认并发
TOPLAS 43(3)2021匹配度 2/10 · 该论文属于编程语言与编译器领域的并发/内存模型研究,虽兼具形式化语义与工业级实现,但未涉及用户核心关注的静态分析、LLM/Agent、浮点程序分析或贝叶斯程序分析。其主题与画像中“PL→AI”“AI→PL”等方向几乎没有直接交集。引用 6 inbox
Lun Liu, Todd Millstein, Madanlal Musuvathi
crossref: 2026-09-10

AI 速览

一句话:提出 volatile-by-default 并发语义,使安全语言默认顺序一致,并允许通过注解按需放弃以保证性能。

现代安全语言遵循默认安全、按需性能的原则,但在多线程上却相反:默认弱内存模型允许编译器和硬件优化,却破坏程序顺序与单内存位置的原子访问,且强默认语义的实际性能代价未知。本文提出 volatile-by-default 语义,默认提供顺序一致性,并用注解让专家在性能关键代码中避免开销。作者为 Java 的 HotSpot JVM 和 Julia 的 JIT 实现该语义,采用复用原子访问机制的基线方案和延迟到可能违反 SC 时才付出代价的推测方案。评估显示,强制 SC 开销显著,但部分用例仍可接受;编译器优化和程序员注解能大幅降低开销。

问题
安全语言默认保证内存和类型安全,但多线程支持却默认采用弱内存模型,破坏程序顺序和单内存位置原子访问,以允许编译器和硬件优化;强默认语义的实际性能代价尚不清楚。
方法
提出 volatile-by-default 语义,默认顺序一致并提供注解按需放弃保证;在 Java HotSpot JVM 与 Julia JIT 中实现,采用基线复用原子访问机制和推测式延迟开销两种技术。
评估
在 x86-64 和 ARM-v8 上实现并测量性能,结果表明强制 SC 开销显著但部分场景可接受,编译器优化与程序员注解可大幅降低开销。
原文摘要(Abstract)

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.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot1212,
  title = {Safe-by-default Concurrency for Modern Programming Languages},
  author = {Lun Liu and Todd Millstein and Madanlal Musuvathi},
  journal = {ACM Transactions on Programming Languages and Systems},
  volume = {43},
  number = {3},
  year = {2021},
  doi = {10.1145/3462206}
}