Abstract
We discuss a new optimisation for recursive functions yielding multiple results in tuples for lazy functional languages, like Clean and Haskell. This optimisation improves the execution time of such functions and also reduces the amount of memory allocated in the heap by these functions, which reduces garbage collection costs. In some cases execution time is improved by more than a factor of two and allocation costs by a factor of four. Furthermore, the space leak that is caused by selector nodes is removed.
This is achieved by reusing nodes allocated in the previous iteration of the recursion to create the nodes for the next iteration, by updating these nodes. Only the parts of the nodes that have changed are updated. Because of these updates, the code that is used to select an element of a tuple is not executed anymore for many selections, because the selector node was overwritten with a new selector node or the result before it is evaluated.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
van Groningen, J.H.G., Nöcker, E.G.J.M.H., Smetsers, J.E.W.: Efficient Heap Management in the Concrete ABC Machine. Proceedings of the Third International Workshop on the Implementation of Functional Languages on Parallel Architectures. Technical Report Series CSTR 91-07. University of Southampton. U.K. (1991)
Hughes, J.: The design and implementation of programming languages. PhD thesis. Oxford University, Programming Research Group, technical monograph PRG-40 (July 1983)
Nöcker, E.G.J.M.H.: Efficient Parallel Functional Programming - Some Case Studies. In: Proceedings of the Fifth International Workshop on Implementation of Functional Languages, Nijmegen, The Netherlands, pp. 51-68 (September 1993) Technical Report 93-21
Jones, S.L.P.: The implementation of Functional Programming Languages. Prentice-Hall, Englewood Cliffs (1987)
Sanders, P., Runciman, C.: LZW Text Compression in Haskell. In: Glasgow Workshop on Functional Programming, Ayr. Scotland, pp. 215–226 (1992)
Smetsers, J.E.W., Nöcker, E.G.J.M.H., van Groningen, J.H.G., Plasmeijer, M.J.: Generating Efficient Code for Lazy Functional Languages. In: Hughes, J. (ed.) FPCA 1991. LNCS, vol. 523, pp. 592–617. Springer, Heidelberg (1991)
Sparud, J.: Fixing Some Space Leaks without a Garbage Collector. In: FPCA 1993, Copenhagen, Denmark, pp. 117–122. ACM press, New York (1993)
Stoye, W.: The implementation of functional languages using custom hardware. PhD thesis. Cambridge University, Computing Laboratory, technical report 81 (December 1985)
Turner, D.: A proposal concerning the dragging problem, Burroughs ARC internal report (October 1985)
Wadler, P.: Fixing some space leaks with a garbage collector. Software Practice and Experience 18(9), 595–608 (1987)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2000 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
van Groningen, J.H.G. (2000). Optimising Recursive Functions Yielding Multiple Results in Tuples in a Lazy Functional Language. In: Koopman, P., Clack, C. (eds) Implementation of Functional Languages. IFL 1999. Lecture Notes in Computer Science, vol 1868. Springer, Berlin, Heidelberg. https://doi.org/10.1007/10722298_4
Download citation
DOI: https://doi.org/10.1007/10722298_4
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-67864-9
Online ISBN: 978-3-540-44658-3
eBook Packages: Springer Book Archive