Skip to main content

Bytecode and Memoized Closure Performance

  • Conference paper
Trends in Functional Programming (TFP 2013)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 8322))

Included in the following conference series:

Abstract

This article describes a new project to study the memory performance of different closure-implementation strategies in terms of memory allocation and runtime performance. At the heart of the project are four new implementation strategies for closures: three bytecode closures and memoized flat closures. The project proposes to compare the new implementation strategies to the classical strategy that dynamically allocates flat closures as heap data structures. The new bytecode closure representations are based on dynamically creating specialized bytecode instead of allocating a data structure. The first new strategy creates specialized functions by inlining the bindings of free variables. The second uses memoization to reduce the number of dynamically created functions. The third dynamically creates memoized specialized functions that treat free variables as parameters at runtime. The fourth memoizes flat closures. Empirical results from a preliminary byetcode-closure case-study using three small benchmarks are presented as a proof-of-concept. The data suggests that dynamically created bytecode closures in conjunction with memoization can allocate significantly less memory, as much as three orders of magnitude less memory in the presented benchmarks, than a flat closure implementation. In addition to studying the memory footprint of the different closure representations, the project will also compare runtime efficiency of these new strategies with traditional flat closures and flat closures that are unpacked onto the stack.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 49.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Barendregt, H.P.: The Lambda Calculus: Its Syntax and Semantics, Revised edn. Studies in Logic and the Foundations of Mathematics. North-Holland (1984)

    Google Scholar 

  2. Biernacka, M., Danvy, O.: A Concrete Framework for Environment Machines. ACM Trans. Comput. Logic 9(1) (December 2007)

    Google Scholar 

  3. Cardelli, L.: Compiling a Functional Language. In: Proceedings of the 1984 ACM Conference on LISP and Functional Programming, pp. 208–217. ACM Press, New York (1984)

    Google Scholar 

  4. Consel, C., NoëL, F.: A General Approach for Run-time Specialization and its Application to C. In: 23rd Annual ACM SIGACT-SIGPLAN Symposium on the Principles of Programming Languages, pp. 145–156. ACM Press (1996)

    Google Scholar 

  5. Danvy, O., Schultz, U.P.: Lambda-Dropping: Transforming Recursive Equations into Programs with Block Structure. Theoretical Computer Science 248(1-2), 243–287 (2000)

    Article  MATH  Google Scholar 

  6. Feeley, M., Lapalme, G.: Closure Generation Based on Viewing Lambda as Epsilon Plus Compile. Journal of Computer Languages 17(4), 251–267 (1992)

    Article  Google Scholar 

  7. Matthew Flatt. Private Communication (May 2007)

    Google Scholar 

  8. Flatt, M.: PLT MzScheme: Language Manual. Technical Report PLT-TR2008-1-v4.1, PLT Scheme Inc. (2008), http://www.plt-scheme.org/techreports/

  9. Gabriel, R.P.: Performance and Evaluation of Lisp Systems. MIT Press, Cambridge (1985)

    Google Scholar 

  10. Grabmüller, M.: Implementing Closures Using Run-time Code Generation. Research report 2006-02 in Forschungsberichte Fakultät IV – Elektrotechnik und Informatik, Technische Universität Berlin (February 2006)

    Google Scholar 

  11. Henderson, P.: Functional Programming: Application and Implementation. Prentice-Hall International, Englewood (1980)

    MATH  Google Scholar 

  12. Johnsson, T.: Lambda Lifting: Transforming Programs to Recursive Equations. In: Proc. of a Conf. on Functional Prog. Lang. and Comp. Arch., pp. 190–203. Springer-Verlag New York, Inc. (1985)

    Google Scholar 

  13. Cardelli, L.: The Functional Abstract Machine. Technical Report No.107, Bell Laboratories (April 1983)

    Google Scholar 

  14. Minamide, Y., Morrisett, G., Harper, R.: Typed Closure Conversion. In: Proc. of he 23rd ACM Symp. on Principles of Progr. Lang., pp. 271–283. ACM Press (1996)

    Google Scholar 

  15. Morazán, M.T., Schultz, U.P.: Optimal Lambda Lifting in Quadratic Time. In: Chitil, O., Horváth, Z., Zsók, V. (eds.) IFL 2007. LNCS, vol. 5083, pp. 37–56. Springer, Heidelberg (2008)

    Chapter  Google Scholar 

  16. Morazán, M.T., Troeger, D.R.: The MT Architecture and Allocation Algorithm. In: Michaelson, G., Trinder, P., Loidl, H.-W. (eds.) Trends in Functional Programming, Bristol, UK, vol. 1, pp. 97–104. Intellect (2000)

    Google Scholar 

  17. Norvig, P.: Techniques for Automatic Memoization with Applications to Context-Free Parsing. Comput. Linguist. 17(1), 91–98 (1991)

    Google Scholar 

  18. Oiwa, Y., Masuhara, H., Yonezawa, A.: DynJava: Type Safe Dynamic Code Generation in Java. In: Third JSSST Work. on Progr. and Progr. Lang. (March 2001)

    Google Scholar 

  19. Landin, P.J.: The Mechanical Evaluation of Expressions. The Computer Journal 6(4), 308–320 (1964)

    Article  MATH  Google Scholar 

  20. Lee, P., Leone, M.: Optimizing ML with Run-Time Code Generation. In: Proc. of the ACM SIGPLAN Conf. on Progr. Lang. Design and Impl., pp. 137–148. ACM Press (May 1996)

    Google Scholar 

  21. PLT Scheme Inc. Guide: PLT Scheme (2008), http://docs.plt-scheme.org/guide/index.html

  22. Poletto, M., Hsieh, W.C., Engler, D.R., Kaashoek, M.F.: ‘C and tcc: A Language and Compiler for Dynamic Code Generation. ACM Transactions on Programming Languages and Systems 21(2), 324–369 (1999)

    Article  Google Scholar 

  23. Kent Dybvig, R.: The Development of Chez Scheme. In: Proc. of the Eleventh ACM SIGPLAN Int. Conf. on Funct. Prog., pp. 1–12 (September 2006)

    Google Scholar 

  24. Reynolds, J.C.: The Dicoveries of Continuations. Lisp and Symbolic Computation 6(3/4) (1993)

    Google Scholar 

  25. Shao, Z., Appel, A.W.: Space Efficient Closure Representations. In: Proc. of the 1994 ACM Conf. on LISP and Funct. Prog., pp. 150–161. ACM Press, New York (1994) ISBN 0-89791-643-3

    Google Scholar 

  26. Strachey, C., Wadsworth, C.P.: Continuations: A Mathematical Semantics for Handling Full Jumps. Higher-Order and Symbolic Computation 13(1/2) (2000)

    Google Scholar 

  27. Sussman, G.J., Steele Jr., G.L.: Scheme: An Interpreter for Extended Lambda Calculus. In: MEMO 349, MIT AI LAB (1975)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2014 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Morazán, M.T. (2014). Bytecode and Memoized Closure Performance. In: McCarthy, J. (eds) Trends in Functional Programming. TFP 2013. Lecture Notes in Computer Science, vol 8322. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-45340-3_4

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-45340-3_4

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-45339-7

  • Online ISBN: 978-3-642-45340-3

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics