Hostname: page-component-78c5997874-t5tsf Total loading time: 0 Render date: 2024-11-05T06:15:28.719Z Has data issue: false hasContentIssue false

Empirical and analytic study of stack versus heap cost for languages with closures

Published online by Cambridge University Press:  07 November 2008

Andrew W. Appel
Affiliation:
Department of Computer Science, Princeton University, Princeton, NJ 08544-2087, USA
Zhong Shao
Affiliation:
Department of Computer Science, Princeton University, Princeton, NJ 08544-2087, USA
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

We present a comprehensive analysis of all the components of creation, access and disposal of heap-allocated and stack-allocated activation records. Among our results are:

•Although stack frames are known to have a better cache read-miss rate than heap frames, our simple analytical model (backed up by simulation results) shows that the difference is too trivial to matter.

•The cache write-miss rate of heap frames is very high; we show that a variety of miss-handling strategies (exemplified by specific modern machines) can give good performance, but not all can.

•Stacks restrict the flexibility of closure representations (for higher-order functions) in important (and costly) ways.

•The extra load placed on the garbage collector by heap-allocated frames is small.

•The demands of modern programming languages make stacks complicated to implement efficiently and correctly.

Overall, the execution cost of stack-allocated and heap-allocated frames is similar; but heap frames are simpler to implement and allow very efficient first-class continuations.

Type
Articles
Copyright
Copyright © Cambridge University Press 1996

References

Allen, M. S. and Becker, M. C. (1993) Multiprocessing aspects of the PowerPC 601. In: IEEE COMPCON, pp. 117126, February. IEEE Press.Google Scholar
Appel, A. W. (1987) Garbage collection can be faster than stack allocation. Infor. Process. Lett., 25(4): 275279.CrossRefGoogle Scholar
Appel, A. W. (1989) Simple generational garbage collection and fast allocation. Software—Practice and Experience, 19(2): 171183.Google Scholar
Appel, A. W. (1992) Compiling with Continuations. Cambridge University Press.Google Scholar
Appel, A. W. (1994) Emulating write-allocate on a no-write-allocate cache. Technical Report CS-TR-459-94. Princeton University.Google Scholar
Appel, A. W. and Trevor, J. (1989) Continuation-passing, closure-passing style. In: 16th ACM Symp. on Principles of Programming Languages, pp. 293302. ACM Press.Google Scholar
Appel, A. W. and Kai, Li. (1991) Virtual memory primitives for user programs. In: 4th Int. Conf. Architectural Support for Programming Languages and Operating Systems (SIGPLAN Notices 26(4): 96107). ACM Press.Google Scholar
Appel, A. W. and MacQueen, D. B. (1991) Standard ML of New Jersey. In: Wirsing, M., editor, 3rd Int. Symp. on Programming Language Implementation and Logic Programming, pp. 113. Springer-Verlag.Google Scholar
Appel, A. W. and Shao, Z. (1992) Callee-save registers in continuation-passing style. Lisp and Symbolic Computation, 5: 189219.Google Scholar
Asprey, T., Averill, G. S., DeLano, E., Mason, R., Weiner, B. and Yetter, J. (1993) Performance features of the PA7100 microprocessor. IEEE Micro, 13(3).Google Scholar
Augustsson, L. (1989) Garbage collection in the < v, g >-machine. Technical Report PMG memo 73 Department of Computer Sciences, Chalmers University of Technology.Google Scholar
Baker, H. G. (1976) The buried binding and stale binding problems of LISP 1.5. Unpublished paper.Google Scholar
Cardelli, L. (1984) Compiling a functional language. In: Symposium on LISP and Functional Programming, pp. 208217. ACM Press.Google Scholar
Chase, D. R. (1988) Safety considerations for storage allocation optimizations. In: Proc. ACM SIGPLAN Conf. on Programming Language Design and Implementation, pp. 19. ACM Press.Google Scholar
Clinger, W. D., Hartheimer, A. H. and Ost, E. M. (1988) Implementation strategies for continuations. In: ACM Conf. on Lisp and Functional Programming, pp. 124131. ACM Press.Google Scholar
Danvy, O. (1987) Memory allocation and higher-order functions. In: Proc. SIGPLAN'87 Symp. on Interpreters and Interpretive Techniques, pp. 241252. ACM Press.Google Scholar
Digital Equipment Corp. (1992) DECchip(tm) 21064-AA Microprocessor Hardware Reference Manual. First edition. DEC, Maynard, MA.Google Scholar
Diwan, A., Tarditi, D. and Moss, E. (1994) Memory subsystem performance of programs using copying garbage collection. In: Proc. 21st Ann. ACM SIGPLAN-SIGACT Symp. on Principles of Programming Languages, pp. 114. ACM Press.Google Scholar
Doligez, D. and Gonthier, G. (1994) Re: stack scanning for generational g.c. Email message <[email protected]>..>Google Scholar
Duba, B., Harper, R. and MacQueen, D. (1991) Typing first-class continuations in ML. In: 18th Ann. ACM Symp. on Principles of Programming Languages, pp. 163173. ACM Press.Google Scholar
Hanson, D. R. (1980) A portable storage management system for the Icon programming language. Software—Practice and Experience, 10: 489500.Google Scholar
Hanson, C. (1990) Efficient stack allocation for tail-recursive languages. In: ACM Conf. on Lisp and Fucntional Programming, pp. 106118. ACM Press.Google Scholar
Hardell, W. R., Hicks, A. A., Howell, L. C., Maule, W. E., Montoye, R. and Tuttle, D. P. (1990) Data cache and storage control units. In: IBM RISC System/6000 Technology, pp. 4450. IBM.Google Scholar
Hieb, R., Dybvig, R. K. and Bruggeman, C. (1990) Representing control in the presence of first-class continuations. In: Proc. ACM SIGPLAN Conf. on Programming Language Design and Implementation, pp. 6677. ACM Press.Google Scholar
Hill, M. D. (1988) A case for direct-mapped caches. IEEE Computer, 21(12): 2540.CrossRefGoogle Scholar
Jones, R. (1992) Tail recursion without space leaks. J. Functional Programming, 2(1): 7379.Google Scholar
Jouppi, N. P. (1993) Cache write policies and performance. In: Proc. 20th Ann. Int. Symposium on Computer Architecture, pp. 191201. ACM Press.Google Scholar
Kranz, D., Kelsey, R., Rees, J., Hudak, P., Philbin, J. and Adams, N. (1986) ORBIT: An optimizing compiler for Scheme. SIGPLAN Notices (Proc. Sigplan '86 Symp. on Compiler Construction), 21(7): 219233.Google Scholar
Kranz, D. (1987) ORBIT: An optimizing compiler for Scheme. PhD thesis, Yale University.Google Scholar
Leroy, X. (1992) Unboxed objects and polymorphic typing. In: 19th Ann. ACM Symp. on Principles of Programming Languages, pp. 177188. ACM Press.Google Scholar
Rees, J. and Clinger, W. (1986) Revised report on the algorithmic language Scheme. SIGPLAN Notices, 21(12): 3779.Google Scholar
Reinhold, M. B. (1994) Cache performance of garbage-collected programs. In: Proc. SIGPLAN Symp. on Programming Language Design and Implementation, pp. 206217. ACM Press.Google Scholar
Reppy, J. H. (1991) CML: A higher-order concurrent language. In: Proc. ACM SIGPLAN Conf. on Programming Language Design and Implementation, pp. 293305. ACM Press.Google Scholar
Reppy, J. H. (1993) A high-performance garbage collector for Standard ML. Technical memorandum, AT&T Bell Laboratories, Murray Hill, NJ.Google Scholar
Runciman, C. and Wakeling, D. (1993)Heap profiling of lazy functional programs. J. Functional Programming, 3(2): 217246.CrossRefGoogle Scholar
Shao, Z. and Appel, A. W. (1994) Space-efficient closure representations. In: Proc. ACM Conf. on Lisp and Functional Programming, pp. 150161. ACM Press.Google Scholar
Steele, G. L. (1978) Rabbit: a compiler for Scheme. Technical Report AI-TR-474, MIT, Cambridge, MA.Google Scholar
Stefanovic, D. and Moss, J. E. B. (1994) Characterization of object behaviour in Standard ML of New Jersey. In: Proc. ACM Conf. on Lisp and Functional Programming, pp. 4354. ACM Press.Google Scholar
System Performance Evaluation Corp. (1989) SPEC Benchmark Suite Release 1.0. October.Google Scholar
Ungar, D. M. (1986) The Design and Evaluation of a High Performance Smalltalk System. MIT Press, Cambridge, MA.Google Scholar
Wand, M. (1980) Continuation-based multiprocessing. In: Conf. Record of the 1980 Lisp Conf., pp. 1928. ACM Press.Google Scholar
Wilson, P. R. , Lam, M. S. and Moher, T. G. (1992) Caching considerations for generational garbage collection. In: ACM Conf. on Lisp and Functional Programming, pp. 3242. ACM Press.Google Scholar
Wilson, P. R. (1991) Some issues and strategies in heap management and memory hierarchies. SIGPLAN Notices, 26 (3): 4552.Google Scholar
Zorn, B. (1991) The effect of garbage collection on cache performance. Technical Report CU-CS-528-91, University of Colorado, Boulder, CO.Google Scholar
Submit a response

Discussions

No Discussions have been published for this article.