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

Mercury程序的基于区域的存储管理

Region-based memory management for Mercury programs

Quan Phan, Gerda Janssens, Zoltan Somogyi

摘要:

基于区域的存储管理(RBMM)是一种编译时存储管理的形式,在函数式编程世界中众所周知。在本文中,我们描述了我们的工作,实现RBMM的逻辑程序设计语言水星。Mercury的一个有趣之处在于,它是用强大的类型、模式和决定论系统设计的。这些系统不仅为Mercury程序员提供了几个直接的软件工程好处,如自文档化代码和清晰的程序逻辑,而且还为语言实现者提供了大量的信息,这些信息对程序分析非常有用。在这项工作中,我们利用这些信息来开发程序分析,确定数据分布到区域,并通过插入必要的区域操作来转换水星程序。我们证明了我们的程序分析和转换的正确性。为了执行带注释的程序,我们实现了运行时支持,以解决回溯带来的两个主要挑战。首先,回溯可能需要在正向执行期间移除的区域被“复活”;其次,在计算期间分配的任何内存都必须被迅速恢复,而无需等待所涉及的区域到达其生命周期的终点。我们详细描述了我们对这两个问题的解决方案。我们详细研究了我们的RBMM系统如何执行选择的基准程序,包括一些著名的困难的情况下RBMM。即使在这些困难的情况下,我们的RBMM使Mercury系统获得了明显更快的运行时间为18个基准测试中的15个相比,基本的Mercury系统与Boehm运行时垃圾收集器,平均运行时加速24%,平均减少95%的内存需求。事实上,我们的系统在某些程序中实现了最佳内存消耗。

英文摘要:

Region-based memory management (RBMM) is a form of compile time memory management, well-known from the functional programming world. In this paper we describe our work on implementing RBMM for the logic programming language Mercury. One interesting point about Mercury is that it is designed with strong type, mode, and determinism systems. These systems not only provide Mercury programmers with several direct software engineering benefits, such as self-documenting code and clear program logic, but also give language implementors a large amount of information that is useful for program analyses. In this work, we make use of this information to develop program analyses that determine the distribution of data into regions and transform Mercury programs by inserting into them the necessary region operations. We prove the correctness of our program analyses and transformation. To execute the annotated programs, we have implemented runtime support that tackles the two main challenges posed by backtracking. First, backtracking can require regions removed during forward execution to be "resurrected"; and second, any memory allocated during a computation that has been backtracked over must be recovered promptly and without waiting for the regions involved to come to the end of their life. We describe in detail our solution of both these problems. We study in detail how our RBMM system performs on a selection of benchmark programs, including some well-known difficult cases for RBMM. Even with these difficult cases, our RBMM-enabled Mercury system obtains clearly faster runtimes for 15 out of 18 benchmarks compared to the base Mercury system with its Boehm runtime garbage collector, with an average runtime speedup of 24%, and an average reduction in memory requirements of 95%. In fact, our system achieves optimal memory consumption in some programs.

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

↑