Using the Boehm-Demers-Weiser conservative GC

Contents

1. Introduction
2. Installation
3. Configuration and build
4. Use
5. Performance measurements

1. Introduction

Larceny can be configured to use the Boehm-Demers-Weiser conservative garbage collector (in the following called "the collector"). The collector is covered by the following copyright notice:

Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
Copyright (c) 1991-1996 by Xerox Corporation. All rights reserved.
Copyright (c) 1996-1998 by Silicon Graphics. All rights reserved.

THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK.

Permission is hereby granted to use or copy this program for any purpose, provided the above notices are retained on all copies. Permission to modify the code and to distribute modified code is granted, provided the above notices are retained, and a notice that the code was modified is included with the above copyright notice.

2. Installation

I have tested version 4.14 of the collector with Larceny. Integration is straightforward, although you must build a separate version of larceny (called bdwlarceny) that uses the collector - you can't build a Grand Unified executable that lets you select the conservative collector with a command line switch.

The collector is not part of the Larceny distribution file - you must get it and install it separately.

Download the collector from Hans Boehm's web site at http://www.hpl.hp.com/personal/Hans_Boehm/gc/, and give it a name; I usually call it something like bdw-gc-4.14.tar.gz. Whatever you call it, you should have a .tar.gz file, and you should place it in the directory $LARCENY (cf. the setup instructions). Edit the file $LARCENY/Makefile so that the value of the variable BDW_DIST corresponds to the name of the archive that holds the collector.

When in $LARCENY, type

    make bdw_unpack
and the archive will be unpacked and moved to the correct location, which is the directory $LARCENY/Rts/bdw-gc.

3. Configuration and build

3.1. Setup

The file Rts/bdw-gc/Makefile as distributed by Boehm defines the C compiler to be 'cc'. You may want to change this to be the compiler you use to compile Larceny, which, on SunOS systems, will most certainly not be the standard 'cc'. I've been using gcc without problems.

In the definition of CFLAGS near the top of the Makefile:

3.2. Installing hooks

(This is optional, but recommended.)

The collector does not itself provide a mechanism whereby user code can be called at the beginning and end of garbage collections, so I've created one. It requires some trivial code modification.

Add the line

    #include "../Sys/bdw.h"
to the file Rts/bdw-gc/alloc.c, following the other include files. This header file redefines two macros used by the collector, STOP_WORLD and START_WORLD, and makes them call the procedures bdw_before_gc and bdw_after_gc, respectively. (Those are defined in Rts/Sys/bdw-collector.c.)

Performing this step is recommended because it enables performance measurements, detection of in-line allocation, and clearing of the unused portion of the stack before each collection. Even so, not all GC time is accounted for, in particular any time spent in lazy sweeping is not recorded.

3.3. Build

The collector will now be built when you build bdwlarceny: go to $LARCENY and type

    make bdwlarceny

3.4. Using newer versions of the collector

It is probable that any newer version of the collector can be subsitituted for version 4.14. If you do use a newer version, check the collector's config.h file to make sure that the symbol ALIGN_DOUBLE is defined for the SPARC architecture (on line 477 in version 4.14).

4. Use

You may not run Scheme code that has been compiled with in-line allocation. In its default configuration, and if the hooks have been installed as explained above, the run-time system will detect such attempts (after the fact, but in a reliable manner), and abort the program. While it would be possible for the system to recover from such attempts, the performance of the resulting programs would most likely be very poor, and I'm not going to bother.

It is in your best interest to use split heaps, as explained in the manual (Reorganizing a heap image), but this is not required.

5. Performance measurements and statistics

Larceny's interface to the collector is not yet full-fledged; many run-time statistics are not gathered because the collector does not provide the necessary hooks. In an effort to make it possible to learn at least something about performance, the previously mentioned hooks have been provided.

The collector uses lazy sweeping, so the time measurements you get are at best a lower bound on GC time, and probably not an accurate statistic. It's better than nothing. It is also reasonably straightforward to account for the time spent in lazy sweeping, but outside the scope of this release.


$Id: bdw.html,v 1.3 2000/09/12 21:23:07 lth Exp $
larceny@ccs.neu.edu