Hostname: page-component-89b8bd64d-ktprf Total loading time: 0 Render date: 2026-05-13T23:15:47.704Z Has data issue: false hasContentIssue false

Safe fusion of functional expressions II: Further improvements

Published online by Cambridge University Press:  07 November 2008

Wei-Ngan Chin
Affiliation:
Department of Information Systems and Computer Science, National University of Singapore, Singapore 0511 (Email: chinwn@iscs.nus.sg)
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.

Large functional programs are often constructed by decomposing each big task into smaller tasks which can be performed by simpler functions. This hierarchical style of developing programs has been found to improve programmers' productivity because smaller functions are easier to construct and reuse. However, programs written in this way tend to be less efficient. Unnecessary intermediate data structures may be created. More function invocations may be required.

To reduce such performance penalties, Phil Wadler proposed a transformation algorithm, called deforestation, which could automatically fuse certain composed expressions together to eliminate intermediate tree-like data structures. However, his technique is currently safe (terminates with no loss of efficiency) for only a subset of first-order expressions.

This paper will generalise the deforestation technique to make it safe for all first-order and higher-order functional programs. Our generalisation is explained using a model for safe fusion which views each function as a producer and its parameters as consumers. Through this model, syntactic program properties are proposed to classify producers and consumers as either safe or unsafe. This classification is used to identify sub-terms that can be safely fused/eliminated. We present the generalised transformation algorithm, illustrate it with examples and provide a termination proof for the transformation algorithm of first-order programs. This paper also contains a suite of additional techniques to further improve the basic safe fusion method. These improvements could be viewed as enhancements to compensate for some inadequacies of the syntactic analyses used.

Information

Type
Articles
Copyright
Copyright © Cambridge University Press 1994
Submit a response

Discussions

No Discussions have been published for this article.