Affiliation:
1. University of California, Los Angeles, CA, USA
2. Microsoft Research, Redmond, WA, USA
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.
Funder
National Science Foundation
Publisher
Association for Computing Machinery (ACM)
Cited by
3 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献