面向OCaml的自动资源边界分析
Towards Automatic Resource Bound Analysis for OCaml
摘要:
本文介绍了一个面向OCaml程序的资源分析系统。该系统自动推导出最坏情况下的资源边界的高阶多态程序与用户定义的归纳类型。该技术在资源中是参数化的,并且可以导出时间、内存分配和能量使用的界限。导出的边界是多变量资源多项式,它们是取决于标准OCaml类型的不同大小参数的函数。边界推理是全自动的,并减少到一个线性优化问题,传递到现成的LP求解器。在技术上,分析系统是基于一种新的多元自动摊销资源分析(AARA)。它建立在现有的工作上的线性AARA高阶程序与用户定义的归纳类型和多变量AARA的一阶程序与内置的列表和二叉树。这是第一次,可以自动推导出高阶函数的多项式边界和依赖于用户定义的归纳类型的多项式边界。此外,分析处理程序的副作用,甚至优于以前的系统的线性约束推理。同时,它保留了现有AARA技术的表现力和效率。分析系统的实用性与Inria的OCaml编译器的实现和集成证明。该实现用于自动推导来自OCaml库、CompCert编译器和教科书算法实现的411个函数和6018行代码的资源边界。在一个案例研究中,系统推断了OCaml程序发送到DynamoDB(一种商业NoSQL云数据库服务)的查询数量的界限。
英文摘要:
This article presents a resource analysis system for OCaml programs. This system automatically derives worst-case resource bounds for higher-order polymorphic programs with user-defined inductive types. The technique is parametric in the resource and can derive bounds for time, memory allocations and energy usage. The derived bounds are multivariate resource polynomials which are functions of different size parameters that depend on the standard OCaml types. Bound inference is fully automatic and reduced to a linear optimization problem that is passed to an off-the-shelf LP solver. Technically, the analysis system is based on a novel multivariate automatic amortized resource analysis (AARA). It builds on existing work on linear AARA for higher-order programs with user-defined inductive types and on multivariate AARA for first-order programs with built-in lists and binary trees. For the first time, it is possible to automatically derive polynomial bounds for higher-order functions and polynomial bounds that depend on user-defined inductive types. Moreover, the analysis handles programs with side effects and even outperforms the linear bound inference of previous systems. At the same time, it preserves the expressivity and efficiency of existing AARA techniques. The practicality of the analysis system is demonstrated with an implementation and integration with Inria's OCaml compiler. The implementation is used to automatically derive resource bounds for 411 functions and 6018 lines of code derived from OCaml libraries, the CompCert compiler, and implementations of textbook algorithms. In a case study, the system infers bounds on the number of queries that are sent by OCaml programs to DynamoDB, a commercial NoSQL cloud database service.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。