The Implementer’s Dilemma: A Mathematical Model of Compile Time Garbage Collection
Optimization by compile time garbage collection is one possible weapon in the functional language implementer’s armoury for combatting the excessive memory allocation usually exhibited by functional programs. It is an interesting idea, but the practical question of whether it yields benefits in practice has still not been answered convincingly one way or the other.
In this short paper we present a mathematical model of the performance of straightforward versions of mark-scan and copying garbage collectors with programs optimized for explicit deallocation. A mark-scan heap manager has a free list, whereas a copying heap manager does not — herein lies the dilemma, since a copying garbage collector is usually considered to be faster than a mark-scan, but it cannot take advantage of this important optimization.
For tract ability we consider only heaps with fixed cells. The results reported show that the garbage collection scheme of choice depends quite strongly on the heap occupancy ratio: the proportion of the total heap occupied by accessible data structures averaged over the execution of the program. We do not know what typical heap occupancy ratios are, and so are unable to make specific recommendations, but the results may be of use in tailoring applications and heap management schemes, or in controlling schemes where the heap size varies dynamically.
An important result arising from the work reported here is that when optimizing for explicit deallocation, a very large proportion of cell releases must be optimized before very much performance benefit is obtained.
Unable to display preview. Download preview PDF.
- J. Heyman. A comprehensive analytical model for garbage collection algorithms. ACM SIGPLAN Notices, 26(8), August 1991.Google Scholar
- S.B. Jones and D. Le Métayer. Compile-time garbage collection by sharing analysis. In Proceedings of the Fourth International Conference on Functional Programming Languages and Computer Architecture, pages 54–74, 1989.Google Scholar
- P. Sansom. Combining copying and compacting garbage collection. In R. Heldal, C.K. Hoist, and P. Wadler, editors, 1991 Glasgow Workshop on Functional Programming. Springer-Verlag, Workshops in Computing, August 1991.Google Scholar
- A.S. Tyas. An investigation into the optimization of garbage collection within functional languages. Final Year Dissertation, Department of Computing Science and Mathematics, University of Stirling, April 1993.Google Scholar