Download PDFOpen PDF in browser

Automatic Space Bound Analysis for Functional Programs with Garbage Collection

21 pagesPublished: October 23, 2018

Abstract

This article introduces a novel system for deriving upper bounds on the heap-space requirements of functional programs with garbage collection. The space cost model is based on a perfect garbage collector that immediately deallocates memory cells when they become unreachable. Heap-space bounds are derived using type-based automatic amortized resource analysis (AARA), a template-based technique that efficiently reduces bound inference to linear programming. The first technical contribution of the work is a new operational cost semantics that models a perfect garbage collector. The second technical contribution is an extension of AARA to take into account automatic deallocation. A key observation is that deallocation of a perfect collector can be modeled with destructive pattern matching if data structures are used in a linear way. However, the analysis uses destructive pattern matching to accurately model deallocation even if data is shared. The soundness of the extended AARA with respect to the new cost semantics is proven in two parts via an intermediate linear cost semantics. The analysis and the cost semantics have been implemented as an extension to Resource Aware ML (RaML). An experimental evaluation shows that the system is able to derive tight symbolic heap-space bounds for common algorithms. Often the bounds are asymptotic improvements over bounds that RaML derives without taking into account garbage collection.

Keyphrases: amortized analysis, cost semantics, garbage collection, LP Solving, operational semantics, Resource Bound Analysis, static analysis, type inference, type systems

In: Gilles Barthe, Geoff Sutcliffe and Margus Veanes (editors). LPAR-22. 22nd International Conference on Logic for Programming, Artificial Intelligence and Reasoning, vol 57, pages 543--563

Links:
BibTeX entry
@inproceedings{LPAR-22:Automatic_Space_Bound_Analysis,
  author    = {Yue Niu and Jan Hoffmann},
  title     = {Automatic Space Bound Analysis for Functional Programs with Garbage Collection},
  booktitle = {LPAR-22. 22nd International Conference on Logic for Programming, Artificial Intelligence and Reasoning},
  editor    = {Gilles Barthe and Geoff Sutcliffe and Margus Veanes},
  series    = {EPiC Series in Computing},
  volume    = {57},
  pages     = {543--563},
  year      = {2018},
  publisher = {EasyChair},
  bibsource = {EasyChair, https://easychair.org},
  issn      = {2398-7340},
  url       = {https://easychair.org/publications/paper/dcnD},
  doi       = {10.29007/xkwx}}
Download PDFOpen PDF in browser