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.
Access provided by Autonomous University of Puebla. Download to read the full chapter text
Chapter PDF
Similar content being viewed by others
Keywords
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.
References
Barendregt, H.P.: The Lambda Calculus: Its Syntax and Semantics, Revised edn. Studies in Logic and the Foundations of Mathematics. North-Holland (1984)
Biernacka, M., Danvy, O.: A Concrete Framework for Environment Machines. ACM Trans. Comput. Logic 9(1) (December 2007)
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)
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)
Danvy, O., Schultz, U.P.: Lambda-Dropping: Transforming Recursive Equations into Programs with Block Structure. Theoretical Computer Science 248(1-2), 243–287 (2000)
Feeley, M., Lapalme, G.: Closure Generation Based on Viewing Lambda as Epsilon Plus Compile. Journal of Computer Languages 17(4), 251–267 (1992)
Matthew Flatt. Private Communication (May 2007)
Flatt, M.: PLT MzScheme: Language Manual. Technical Report PLT-TR2008-1-v4.1, PLT Scheme Inc. (2008), http://www.plt-scheme.org/techreports/
Gabriel, R.P.: Performance and Evaluation of Lisp Systems. MIT Press, Cambridge (1985)
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)
Henderson, P.: Functional Programming: Application and Implementation. Prentice-Hall International, Englewood (1980)
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)
Cardelli, L.: The Functional Abstract Machine. Technical Report No.107, Bell Laboratories (April 1983)
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)
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)
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)
Norvig, P.: Techniques for Automatic Memoization with Applications to Context-Free Parsing. Comput. Linguist. 17(1), 91–98 (1991)
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)
Landin, P.J.: The Mechanical Evaluation of Expressions. The Computer Journal 6(4), 308–320 (1964)
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)
PLT Scheme Inc. Guide: PLT Scheme (2008), http://docs.plt-scheme.org/guide/index.html
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)
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)
Reynolds, J.C.: The Dicoveries of Continuations. Lisp and Symbolic Computation 6(3/4) (1993)
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
Strachey, C., Wadsworth, C.P.: Continuations: A Mathematical Semantics for Handling Full Jumps. Higher-Order and Symbolic Computation 13(1/2) (2000)
Sussman, G.J., Steele Jr., G.L.: Scheme: An Interpreter for Extended Lambda Calculus. In: MEMO 349, MIT AI LAB (1975)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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)