一句话:提出无顺序区域(OFR)可串行化一致性模型,并实现默认保证 OFR 原子性的并发错误检测工具 SOFRITEST 与运行时系统 SOPRO。
多线程程序的正确同步十分困难,原子性违反等同步错误会导致程序失败。已有的强内存一致性模型虽能排除部分失败,却依赖程序员自行编写的加锁代码。本文提出新的无顺序区域(Ordering-Free Region, OFR)可串行化一致性模型:OFR 指两次相邻定序构造(如 barrier)之间的动态指令区间,该模型保证 OFR 的原子性,同时不破坏锁操作处的原子性。作者实现了 SOFRITAS 平台,使 C/C++ 程序默认执行结果等价于 OFR 的某种串行化,并据此构建两套系统:面向测试的并发错误发现工具 SOFRITEST(在 OFR 粒度过粗时能自动建议细化注解)与生产级纯软件运行时系统 SOPRO。SOFRITEST 在 memcached 中发现了较弱一致性模型会漏掉的多临界区原子性违反;SOPRO 性能高、可随并行度良好扩展,即使加锁代码存在错误也能避免失败。在远弱于该模型语义的 pthreads 内存模型下,SOFRITAS 的平均开销仅为单线程 1.59 倍、十六线程 1.51 倍。
Correctly synchronizing multithreaded programs is challenging and errors can lead to program failures such as atomicity violations. Existing strong memory consistency models rule out some possible failures, but are limited by depending on programmer-defined locking code. We present the new Ordering-Free Region (OFR) serializability consistency model that ensures atomicity for OFRs, which are spans of dynamic instructions between consecutive ordering constructs (e.g., barriers), without breaking atomicity at lock operations. Our platform, Serializable Ordering-Free Regions for Increasing Thread Atomicity Scalably (SOFRITAS), ensures a C/C++ program's execution is equivalent to a serialization of OFRs by default. We build two systems that realize the SOFRITAS idea: a concurrency bug finding tool for testing called SOFRITEST, and a production runtime system called SOPRO. SOFRITEST uses OFRs to find concurrency bugs, including a multi-critical-section atomicity violation in memcached that weaker consistency models will miss. If OFR's are too coarse-grained, SOFRITEST suggests refinement annotations automatically. Our software-only SOPRO implementation has high performance, scales well with increased parallelism, and prevents failures despite bugs in locking code. SOFRITAS has an average overhead of just 1.59x on a single-threaded execution and 1.51x on sixteen threads, despite pthreads' much weaker memory model.