arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2402.12863cs.SE
收藏

发现 Datalog 引擎中的跨规则优化缺陷

Finding Cross-rule Optimization Bugs in Datalog Engines

Chi Zhang, Linzhang Wang, Manuel Rigger

AI总结:

本文提出增量规则求值方法 IRE 及工具 Deopt,通过对比优化前后 Datalog 程序结果来检测跨规则优化缺陷,在四个成熟引擎中发现 30 个缺陷,并显著提升有效测试用例生成效率。

摘要:

Datalog 是一种流行且广泛使用的声明式逻辑编程语言。Datalog 引擎会应用许多跨规则优化;这些优化中的缺陷可能导致错误结果。为了检测此类优化缺陷,我们提出了一种名为增量规则求值(Incremental Rule Evaluation,IRE)的自动化测试方法,该方法协同解决了测试预言和测试用例生成问题。测试预言背后的核心思想是比较经过优化的程序与未进行跨规则优化的程序的结果;任何差异都表明 Datalog 引擎中存在缺陷。我们的核心见解是,对于一个经过优化的、增量生成的 Datalog 程序,我们可以通过构造一个参考程序来禁用多个规则之间执行的优化,从而单独求值所有规则。增量生成测试用例不仅使我们能够为每个新生成的规则应用测试预言——我们还可以确保每个新添加的规则以给定概率生成非空结果,并避免重新计算已知事实。我们将 IRE 实现为一个名为 Deopt 的工具,并在四个成熟的 Datalog 引擎上评估了 Deopt,即 Soufflé、CozoDB、μZ 和 DDlog,共发现了 30 个缺陷。其中 13 个是逻辑缺陷,其余为崩溃和错误缺陷。Deopt 能够检测出 queryFuzz(一种最先进的方法)发现的所有缺陷。在 Deopt 识别出的缺陷中,queryFuzz 可能无法检测到 5 个。我们的增量测试用例生成方法是高效的;例如,对于包含 60 条规则的测试用例,我们的增量方法能够产生朴素随机方法 1.17 倍(DDlog)到 31.02 倍(Soufflé)之多的具有非空结果的有效测试用例。我们相信该方法的简洁性和通用性将使其在实践中得到广泛采用。

英文摘要:

Datalog is a popular and widely-used declarative logic programming language. Datalog engines apply many cross-rule optimizations; bugs in them can cause incorrect results. To detect such optimization bugs, we propose an automated testing approach called Incremental Rule Evaluation (IRE), which synergistically tackles the test oracle and test case generation problem. The core idea behind the test oracle is to compare the results of an optimized program and a program without cross-rule optimization; any difference indicates a bug in the Datalog engine. Our core insight is that, for an optimized, incrementally-generated Datalog program, we can evaluate all rules individually by constructing a reference program to disable the optimizations that are performed among multiple rules. Incrementally generating test cases not only allows us to apply the test oracle for every new rule generated-we also can ensure that every newly added rule generates a non-empty result with a given probability and eschew recomputing already-known facts. We implemented IRE as a tool named Deopt, and evaluated Deopt on four mature Datalog engines, namely Soufflé, CozoDB, $μ$Z, and DDlog, and discovered a total of 30 bugs. Of these, 13 were logic bugs, while the remaining were crash and error bugs. Deopt can detect all bugs found by queryFuzz, a state-of-the-art approach. Out of the bugs identified by Deopt, queryFuzz might be unable to detect 5. Our incremental test case generation approach is efficient; for example, for test cases containing 60 rules, our incremental approach can produce 1.17$\times$ (for DDlog) to 31.02$\times$ (for Soufflé) as many valid test cases with non-empty results as the naive random method. We believe that the simplicity and the generality of the approach will lead to its wide adoption in practice.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑