Abstract
Hofmann and Jost have presented a heap space analysis [1] that finds linear space bounds for many functional programs. It uses an amortised analysis: assigning hypothetical amounts of free space (called potential) to data structures in proportion to their sizes using type annotations. Constraints on these annotations in the type system ensure that the total potential assigned to the input is an upper bound on the total memory required to satisfy all allocations.
We describe a related system for bounding the stack space requirements which uses the depth of data structures, by expressing potential in terms of maxima as well as sums. This is achieved by adding extra structure to typing contexts (inspired by O’Hearn’s bunched typing [2]) to describe the form of the bounds. We will also present the extra steps that must be taken to construct a typing during the analysis.
Chapter PDF
References
Hofmann, M., Jost, S.: Static prediction of heap space usage for first-order functional programs. In: POPL 2003: Proceedings of the 30th ACM Symposium on Principles of Programming Languages, New Orleans. ACM Press, New York (2003)
O’Hearn, P.: On bunched typing. Journal of Functional Programming 13(4), 747–796 (2003)
Aspinall, D., Gilmore, S., Hofmann, M., Sannella, D., Stark, I.: Mobile resource guarantees for smart devices. In: Barthe, G., Burdy, L., Huisman, M., Lanet, J.-L., Muntean, T. (eds.) CASSIS 2004. LNCS, vol. 3362, pp. 1–26. Springer, Heidelberg (2005)
Jost, S., Loidl, H.W., Hammond, K.: Report on stack-space analysis (revised). Deliverable D05, The Embounded Project (IST-510255) (2007)
Campbell, B.: Prediction of linear memory usage for first-order functional programs. In: Trends in Functional Programming, vol. 9 (2008) (to appear)
Tarjan, R.E.: Amortized computational complexity. SIAM Journal on Algebraic and Discrete Methods 6(2), 306–318 (1985)
Campbell, B.: Type-based amortized stack memory prediction. PhD thesis, University of Edinburgh (2008)
Jost, S., Loidl, H.W., Hammond, K.: Report on heap-space analysis. Deliverable D11, The Embounded Project (IST-510255 ) (2007)
Jost, S.: Amortised Analysis for Functional Programs. PhD thesis, Ludwig-Maximilians-University (forthcoming, provisional title) (2008)
Hofmann, M., Jost, S.: Type-based amortised heap-space analysis (for an object-oriented language). In: Sestoft, P. (ed.) ESOP 2006. LNCS, vol. 3924, pp. 22–37. Springer, Heidelberg (2006)
Reistad, B., Gifford, D.K.: Static dependent costs for estimating execution time. In: LFP 1994: Proceedings of the 1994 ACM conference on LISP and functional programming, pp. 65–78. ACM Press, New York (1994)
Hughes, J., Pareto, L.: Recursion and dynamic data-structures in bounded space: towards embedded ML programming. In: ICFP 1999: Proceedings of the fourth ACM SIGPLAN International Conference on Functional Programming, pp. 70–81. ACM Press, New York (1999)
Chin, W.N., Khoo, S.C.: Calculating sized types. Higher Order and Symbolic Computation 14(2-3), 261–300 (2001)
Chin, W.N., Khoo, S.C., Xu, D.N.: Extending sized type with collection analysis. In: PEPM 2003: Proceedings of the 2003 ACM SIGPLAN workshop on Partial Evaluation and Semantics-based Program Manipulation, pp. 75–84. ACM Press, New York (2003)
Chin, W.N., Khoo, S.C., Qin, S., Popeea, C., Nguyen, H.H.: Verifying safety policies with size properties and alias controls. In: ICSE 2005: Proceedings of the 27th International Conference on Software Engineering, pp. 186–195. ACM Press, New York (2005)
Chin, W.N., Nguyen, H.H., Qin, S., Rinard, M.: Memory usage verification for OO programs. In: Hankin, C., Siveroni, I. (eds.) SAS 2005. LNCS, vol. 3672, pp. 70–86. Springer, Heidelberg (2005)
Chin, W.N., Nguyen, H.H., Popeea, C., Qin, S.: Analysing memory resource bounds for low-level programs. In: ISMM 2008: Proceedings of the 7th international symposium on Memory management, pp. 151–160. ACM, New York (2008)
Vasconcelos, P.: Space Cost Analysis Using Sized Types. PhD thesis, University of St Andrews (2008)
Debray, S.K., Lin, N.W.: Cost analysis of logic programs. ACM Transactions on Programming Languages and Systems 15(5), 826–875 (1993)
Vasconcelos, P.B., Hammond, K.: Inferring cost equations for recursive, polymorphic and higher-order functional programs. In: Trinder, P., Michaelson, G.J., Peña, R. (eds.) IFL 2003. LNCS, vol. 3145, pp. 86–101. Springer, Heidelberg (2004)
Albert, E., Arenas, P., Genaim, S., Puebla, G.: Automatic inference of upper bounds for recurrence relations in cost analysis. In: Alpuente, M., Vidal, G. (eds.) SAS 2008. LNCS, vol. 5079, pp. 221–237. Springer, Heidelberg (2008)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2009 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Campbell, B. (2009). Amortised Memory Analysis Using the Depth of Data Structures. In: Castagna, G. (eds) Programming Languages and Systems. ESOP 2009. Lecture Notes in Computer Science, vol 5502. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-00590-9_14
Download citation
DOI: https://doi.org/10.1007/978-3-642-00590-9_14
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-00589-3
Online ISBN: 978-3-642-00590-9
eBook Packages: Computer ScienceComputer Science (R0)