一句话:提出嵌入 Scala 的 Datalog 编译器 Flan,用多阶段编程生成专用代码,兼顾表达力与性能。
现有 Datalog 系统在程序分析中面临表达力与性能难以兼得的问题:Soufflé 性能高但缺少与宿主语言的无缝互操作,Flix、Datafun、Formulog 等扩展语言灵活但常牺牲性能。本文提出 Flan,一个完全嵌入 Scala 的 Datalog 编译器,利用多阶段编程为整个计算生成专用代码,并与宿主语言无缝集成。其简单算子接口支持任意聚合、用户定义函数、格,以及二分/多路连接和树/哈希表索引等多种执行策略。基准评测显示,Flan 与主流 Datalog 引擎相比具有竞争力的性能,在实际重要工作负载上相对最先进系统取得加速。
Datalog has gained prominence in program analysis due to its expressiveness and ease of use. Its generic fixpoint resolution algorithm over relational domains simplifies the expression of many complex analyses. The performance and scalability issues of early Datalog approaches have been addressed by tools such as Soufflé through specialized code generation. Still, while pure Datalog is expressive enough to support a wide range of analyses, there is a growing need for extensions to accommodate increasingly complex analyses This has led to the development of various extensions, such as Flix, Datafun, and Formulog, which enhance Datalog with features like arbitrary lattices and SMT constraints. Most of these extensions recognize the need for full interoperability between Datalog and a full-fledged programming language, a functionality that high-performance systems like Soufflé lack. Specifically, in most cases, they construct languages from scratch with first-class Datalog support, allowing greater flexibility. However, this flexibility often comes at the cost of performance due to the conflicting requirements of prioritizing modularity and abstraction over efficiency. Consequently, achieving both flexibility and compilation to highly-performant specialized code poses a significant challenge. In this work, we reconcile the competing demands of expressiveness and performance with Flan, a Datalog compiler fully embedded in Scala that leverages multi-stage programming to generate specialized code for enhanced performance. Our approach combines the flexibility of Flix with Soufflé’s performance, offering seamless integration with the host language that enables the addition of powerful extensions while generating specialized code for the entire computation. Flan’s simple operator interface allows the addition of an extensive set of features, including arbitrary aggregates, user-defined functions, and lattices, with multiple execution strategies such as binary and multi-way joins, supported by different indexing structures like specialized trees and hash tables, with minimal effort. We evaluate our system on a variety of benchmarks and compare it to established Datalog engines. Our results demonstrate competitive performance and speedups in the range of to compared to state-of-the-art systems for workloads of practical importance.
@article{paperbot2634,
title = {Flan: An Expressive and Efficient Datalog Compiler for Program Analysis},
author = {Supun Abeysinghe and Anxhelo Xhebraj and Tiark Rompf},
journal = {Proceedings of the ACM on Programming Languages},
volume = {8},
number = {POPL},
year = {2024},
doi = {10.1145/3632928}
}