论文标题
最佳预测具有同步的种族
Optimal Prediction of Synchronization-Preserving Races
论文作者
论文摘要
众所周知,同时程序很难正确编写,因为计划非确定性引入了很难检测和复制的微妙错误。最常见的并发错误是(数据)种族,这是在同时执行内存冲突动作时发生的。因此,为开发有效的种族检测技术而付出了巨大的努力。最常见的方法是动态种族预测:鉴于并发程序的观察到的,无种族的跟踪$σ$,任务是确定是否可以正确地将$σ$的事件重新排序到trace $σ^*$,该$σ^*$见证了隐藏在$σ$中的种族。 在这项工作中,我们介绍了同步(Hronization)的概念 - 保证种族。当有一个证人$σ^*$中,同步操作(例如,锁的采集和释放)以与$σ$相同的顺序出现,以$σ$进行同步种族。这是一个广泛的定义,它严格涵盖了著名的种族概念。我们的主要结果如下。首先,我们开发了一种声音和完整的算法,用于预测具有同步的种族。对于诸如线程数之类的参数值的中等值,该算法以$ \ widetilde {o}(\ Mathcal {n})$时间和空间运行,其中$ \ Mathcal {n} $是trace $σ$的长度。其次,我们表明该问题具有$ω(\ MATHCAL {n}/\ log^2 \ Mathcal {n})$ space下限,因此我们的算法本质上是时间和空间最佳的。第三,我们表明,即使只有两个同步操作的单个反转预测种族是$ \ permatatorName {np} $ - 完成,甚至$ \ operatatorName {w} [1] $ - 当由线程数参数化时,很难。因此,同步保护精确地表征了种族预测的障碍性边界,而我们的算法对于可拖动的侧几乎是最佳的。
Concurrent programs are notoriously hard to write correctly, as scheduling nondeterminism introduces subtle errors that are both hard to detect and to reproduce. The most common concurrency errors are (data) races, which occur when memory-conflicting actions are executed concurrently. Consequently, considerable effort has been made towards developing efficient techniques for race detection. The most common approach is dynamic race prediction: given an observed, race-free trace $σ$ of a concurrent program, the task is to decide whether events of $σ$ can be correctly reordered to a trace $σ^*$ that witnesses a race hidden in $σ$. In this work we introduce the notion of sync(hronization)-preserving races. A sync-preserving race occurs in $σ$ when there is a witness $σ^*$ in which synchronization operations (e.g., acquisition and release of locks) appear in the same order as in $σ$. This is a broad definition that strictly subsumes the famous notion of happens-before races. Our main results are as follows. First, we develop a sound and complete algorithm for predicting sync-preserving races. For moderate values of parameters like the number of threads, the algorithm runs in $\widetilde{O}(\mathcal{N})$ time and space, where $\mathcal{N}$ is the length of the trace $σ$. Second, we show that the problem has a $Ω(\mathcal{N}/\log^2 \mathcal{N})$ space lower bound, and thus our algorithm is essentially time and space optimal. Third, we show that predicting races with even just a single reversal of two sync operations is $\operatorname{NP}$-complete and even $\operatorname{W}[1]$-hard when parameterized by the number of threads. Thus, sync-preservation characterizes exactly the tractability boundary of race prediction, and our algorithm is nearly optimal for the tractable side.