Skip to main content Accessibility help
×
×
Home

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

  • Andrew W. Appel (a1) and Zhong Shao (a1)
Abstract

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.

Copyright
References
Hide All
Allen, M. S. and Becker, M. C. (1993) Multiprocessing aspects of the PowerPC 601. In: IEEE COMPCON, pp. 117126, February. IEEE Press.
Appel, A. W. (1987) Garbage collection can be faster than stack allocation. Infor. Process. Lett., 25(4): 275279.
Appel, A. W. (1989) Simple generational garbage collection and fast allocation. Software—Practice and Experience, 19(2): 171183.
Appel, A. W. (1992) Compiling with Continuations. Cambridge University Press.
Appel, A. W. (1994) Emulating write-allocate on a no-write-allocate cache. Technical Report CS-TR-459-94. Princeton University.
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.
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.
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.
Appel, A. W. and Shao, Z. (1992) Callee-save registers in continuation-passing style. Lisp and Symbolic Computation, 5: 189219.
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).
Augustsson, L. (1989) Garbage collection in the < v, g >-machine. Technical Report PMG memo 73 Department of Computer Sciences, Chalmers University of Technology.
Baker, H. G. (1976) The buried binding and stale binding problems of LISP 1.5. Unpublished paper.
Cardelli, L. (1984) Compiling a functional language. In: Symposium on LISP and Functional Programming, pp. 208217. ACM Press.
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.
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.
Danvy, O. (1987) Memory allocation and higher-order functions. In: Proc. SIGPLAN'87 Symp. on Interpreters and Interpretive Techniques, pp. 241252. ACM Press.
Digital Equipment Corp. (1992) DECchip(tm) 21064-AA Microprocessor Hardware Reference Manual. First edition. DEC, Maynard, MA.
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.
Doligez, D. and Gonthier, G. (1994) Re: stack scanning for generational g.c. Email message <9403041606.AA07877@lix.polytechnique.fr>.
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.
Hanson, D. R. (1980) A portable storage management system for the Icon programming language. Software—Practice and Experience, 10: 489500.
Hanson, C. (1990) Efficient stack allocation for tail-recursive languages. In: ACM Conf. on Lisp and Fucntional Programming, pp. 106118. ACM Press.
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.
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.
Hill, M. D. (1988) A case for direct-mapped caches. IEEE Computer, 21(12): 2540.
Jones, R. (1992) Tail recursion without space leaks. J. Functional Programming, 2(1): 7379.
Jouppi, N. P. (1993) Cache write policies and performance. In: Proc. 20th Ann. Int. Symposium on Computer Architecture, pp. 191201. ACM Press.
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.
Kranz, D. (1987) ORBIT: An optimizing compiler for Scheme. PhD thesis, Yale University.
Leroy, X. (1992) Unboxed objects and polymorphic typing. In: 19th Ann. ACM Symp. on Principles of Programming Languages, pp. 177188. ACM Press.
Rees, J. and Clinger, W. (1986) Revised report on the algorithmic language Scheme. SIGPLAN Notices, 21(12): 3779.
Reinhold, M. B. (1994) Cache performance of garbage-collected programs. In: Proc. SIGPLAN Symp. on Programming Language Design and Implementation, pp. 206217. ACM Press.
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.
Reppy, J. H. (1993) A high-performance garbage collector for Standard ML. Technical memorandum, AT&T Bell Laboratories, Murray Hill, NJ.
Runciman, C. and Wakeling, D. (1993)Heap profiling of lazy functional programs. J. Functional Programming, 3(2): 217246.
Shao, Z. and Appel, A. W. (1994) Space-efficient closure representations. In: Proc. ACM Conf. on Lisp and Functional Programming, pp. 150161. ACM Press.
Steele, G. L. (1978) Rabbit: a compiler for Scheme. Technical Report AI-TR-474, MIT, Cambridge, MA.
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.
System Performance Evaluation Corp. (1989) SPEC Benchmark Suite Release 1.0. October.
Ungar, D. M. (1986) The Design and Evaluation of a High Performance Smalltalk System. MIT Press, Cambridge, MA.
Wand, M. (1980) Continuation-based multiprocessing. In: Conf. Record of the 1980 Lisp Conf., pp. 1928. ACM Press.
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.
Wilson, P. R. (1991) Some issues and strategies in heap management and memory hierarchies. SIGPLAN Notices, 26 (3): 4552.
Zorn, B. (1991) The effect of garbage collection on cache performance. Technical Report CU-CS-528-91, University of Colorado, Boulder, CO.
Recommend this journal

Email your librarian or administrator to recommend adding this journal to your organisation's collection.

Journal of Functional Programming
  • ISSN: 0956-7968
  • EISSN: 1469-7653
  • URL: /core/journals/journal-of-functional-programming
Please enter your name
Please enter a valid email address
Who would you like to send this to? *
×

Metrics

Full text views

Total number of HTML views: 0
Total number of PDF views: 0 *
Loading metrics...

Abstract views

Total abstract views: 0 *
Loading metrics...

* Views captured on Cambridge Core between <date>. This data will be updated every 24 hours.

Usage data cannot currently be displayed

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

  • Andrew W. Appel (a1) and Zhong Shao (a1)
Submit a response

Discussions

No Discussions have been published for this article.

×

Reply to: Submit a response


Your details


Conflicting interests

Do you have any conflicting interests? *