通过预言势能自动进行 Rust 线性资源界分析
Automatic Linear Resource Bound Analysis for Rust via Prophecy Potentials
AI总结:
本文提出 RaRust,一种基于类型的线性资源界分析系统,利用预言势能处理 Rust 的借用机制,为类型良好的 Rust 程序自动推断符号线性资源界,并通过实验验证其有效性。
摘要:
Rust 已成为一种流行的系统编程语言,在内存安全与性能之间取得了平衡。Rust 的类型系统确保了底层内存控制的安全性;然而,一个类型良好的 Rust 程序并不能保证具有高性能。本文研究 Rust 程序资源消耗的静态分析,旨在理解 Rust 程序的性能。尽管已有大量关于静态资源分析的研究,但利用 Rust 的内存安全性——尤其是借用机制及其属性——来辅助资源界分析,仍未被探索。本文提出了 RaRust,一种针对类型良好的 Rust 程序的基于类型的线性资源界分析。RaRust 遵循自动摊销资源分析(AARA)的方法论来构建资源感知类型系统。为了支持 Rust 的借用机制,包括共享借用和可变借用,RaRust 引入了共享的和新颖的预言势能,以组合方式推理借用。为了证明 RaRust 的可靠性,本文提出了资源感知借用演算(RABC),作为最近提出的低级借用演算(LLBC)的一个变体。对 RaRust 原型实现的实验评估表明,RaRust 能够为具有共享借用和可变借用、重借用、堆分配数据结构、循环和递归的 Rust 程序推断符号线性资源界。
英文摘要:
Rust has become a popular system programming language that strikes a balance between memory safety and performance. Rust's type system ensures the safety of low-level memory controls; however, a well-typed Rust program is not guaranteed to enjoy high performance. This article studies static analysis for resource consumption of Rust programs, aiming at understanding the performance of Rust programs. Although there have been tons of studies on static resource analysis, exploiting Rust's memory safety -- especially the borrow mechanisms and their properties -- to aid resource-bound analysis, remains unexplored. This article presents RaRust, a type-based linear resource-bound analysis for well-typed Rust programs. RaRust follows the methodology of automatic amortized resource analysis (AARA) to build a resource-aware type system. To support Rust's borrow mechanisms, including shared and mutable borrows, RaRust introduces shared and novel prophecy potentials to reason about borrows compositionally. To prove the soundness of RaRust, this article proposes Resource-Aware Borrow Calculus (RABC) as a variant of recently proposed Low-Level Borrow Calculus (LLBC). The experimental evaluation of a prototype implementation of RaRust demonstrates that RaRust is capable of inferring symbolic linear resource bounds for Rust programs featuring shared and mutable borrows, reborrows, heap-allocated data structures, loops, and recursion.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。