Fast and Optimal Extraction for Sparse Equality Graphs

被引:1
作者
Goharshady, Amir Kafshdar [1 ,2 ]
Lam, Chun Kit [1 ,2 ]
Parreaux, Lionel [1 ,2 ]
机构
[1] Hong Kong Univ Sci & Technol HKUST, Dept Comp Sci, Hong Kong, Peoples R China
[2] Hong Kong Univ Sci & Technol HKUST, Dept Math, Hong Kong, Peoples R China
来源
PROCEEDINGS OF THE ACM ON PROGRAMMING LANGUAGES-PACMPL | 2024年 / 8卷 / OOPSLA期
关键词
e-graphs; equality saturation; extraction; treewidth; MODEL CHECKING; TREE-WIDTH; TREEWIDTH; ALGORITHM; MINORS; EFFICIENT; PROGRAMS;
D O I
10.1145/3689801
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Equality graphs (e-graphs) are used to compactly represent equivalence classes of terms in symbolic reason-ing systems. Beyond their original roots in automated theorem proving, e-graphs have been used in a varietyof applications. They have become particularly important as the key ingredient in the popular technique ofequality saturation, which has notable applications in compiler optimization, program synthesis, programverification, and symbolic execution, among others. In a typical equality saturation workflow, an e-graph isused to store a large number of equalities that are generated by local rewrites during a saturation phase, afterwhich an optimal term isextractedfrom the e-graph as the output of the technique. However, despite itscrucial role in equality saturation, e-graph extraction has received relatively little attention in the literature,which we seek to start addressing in this paper. Extraction is a challenging problem and is notably known tobe NP-hard in general, so current equality saturation tools rely either on slow optimal extraction algorithmsbased on integer linear programming (ILP) or on heuristics that may not always produce the optimal result.In fact, in this paper, we show that e-graph extraction ishard to approximatewithin any constant ratio. Thus,any such heuristic will produce wildly suboptimal results in the worst case. Fortunately, we show that theproblem becomes tractable when the e-graph is sparse, which is the case in many practical applications. Wepresent a novel parameterized algorithm for extracting optimal terms from e-graphs with low treewidth, ameasure of how "tree-like" a graph is, and prove its correctness. We also present an efficient Rust implemen-tation of our algorithm and evaluate it against ILP on a number of benchmarks extracted from the Craneliftbenchmark suite, a real-world compiler optimization library based on equality saturation. Our algorithm op-timally extracts e-graphs with treewidths of up to 10 in a fraction of the time taken by ILP. These resultssuggest that our algorithm can be a valuable tool for equality saturation users who need to extract optimalterms from sparse e-graphs
引用
收藏
页数:27
相关论文
共 92 条
  • [1] htd - A Free, Open-Source Framework for (Customized) Tree Decompositions and Beyond
    Abseher, Michael
    Musliu, Nysret
    Woltran, Stefan
    [J]. INTEGRATION OF AI AND OR TECHNIQUES IN CONSTRAINT PROGRAMMING, CPAIOR 2017, 2017, 10335 : 376 - 386
  • [2] Efficient Approximations for Cache-Conscious Data Placement
    Ahmadi, Ali
    Daliri, Majid
    Goharshady, Amir Kafshdar
    Pavlogiannis, Andreas
    [J]. PROCEEDINGS OF THE 43RD ACM SIGPLAN INTERNATIONAL CONFERENCE ON PROGRAMMING LANGUAGE DESIGN AND IMPLEMENTATION (PLDI '22), 2022, : 857 - 871
  • [3] Aiswarya C., 2022, ACM SIGLOG News, V9, P6, DOI 10.1145/3527540.3527542
  • [4] Formally Verified EVM Block-Optimizations
    Albert, Elvira
    Genaim, Samir
    Kirchner, Daniel
    Martin-Martin, Enrique
    [J]. COMPUTER AIDED VERIFICATION, CAV 2023, PT III, 2023, 13966 : 176 - 189
  • [5] Super-optimization of Smart Contracts
    Albert, Elvira
    Gordillo, Pablo
    Hernandez-Cerezo, Alejandro
    Rubio, Albert
    Schett, Maria A.
    [J]. ACM TRANSACTIONS ON SOFTWARE ENGINEERING AND METHODOLOGY, 2022, 31 (04)
  • [6] A Max-SMT Superoptimizer for EVM handling Memory and Storage
    Albert, Elvira
    Gordillo, Pablo
    Hernandez-Cerezo, Alejandro
    Rubio, Albert
    [J]. TOOLS AND ALGORITHMS FOR THE CONSTRUCTION AND ANALYSIS OF SYSTEMS, TACAS 2022, PT I, 2022, 13243 : 201 - 219
  • [7] Don't run on fumes-Parametric gas bounds for smart contracts
    Albert, Elvira
    Correas, Jesus
    Gordillo, Pablo
    Roman-Diez, Guillermo
    Rubio, Albert
    [J]. JOURNAL OF SYSTEMS AND SOFTWARE, 2021, 176
  • [8] Algorithmic Construction of Sets for k-Restrictions
    Alon, Noga
    Moshkovitz, Dana
    Safra, Shmuel
    [J]. ACM TRANSACTIONS ON ALGORITHMS, 2006, 2 (02) : 153 - 177
  • [9] [Anonymous], 1972, Complexity of Computer Computations, DOI 10.1007/978-3-540-68279-0-8
  • [10] [Anonymous], Bytecode Alliance. 2023c. Wasmtime: A fast and secure runtime for WebAssembly