From: daveg@synaptics.com (Dave Gillespie)
Newsgroups: comp.lang.c++
Subject: Re: Garbage Collection for C++
Date: 20 Aug 92 09:25:59 GMT
	<DAVEG.92Aug13025629@synaptx.synaptics.com>
	<TMB.92Aug16164940@arolla.idiap.ch>
	<1992Aug18.021453.24394@news.mentorg.com>
	<DAVEG.92Aug17224359@synaptx.synaptics.com> <boehm.714158406@siria>
Organization: Synaptics, Inc., San Jose, CA
In-reply-to: boehm@parc.xerox.com's message of 18 Aug 92 17:20:06 GMT

In article <boehm.714158406@siria> boehm@parc.xerox.com (Hans Boehm) writes:
>> But the test for whether or not a pointer points *somewhere* in the
>> GC-able zone of memory is trivial.

> This is highly system dependent.  In the latest versions of our collectors,
> things may well be the other way around.  You generally can't assume
> contiguity of the garbage collected heap.  You also don't really
> want any bookkeeping information on the pages of the garbage collected
> heap.  That way a page containing pointerfree objects is never touched
> during a collection.  Neither is an entirely empty page.  Thus we find out
> whether a page is in a GC-able zone by a lookup in a two-level tree.

I was actually thinking of this as within the bounds of "trivial,"
in the sense that one or maybe two fast memory lookups per pointer
validation is probably fast enough not to both anyone, especially
if, as you point out, the lookups are in a single table somewhere
rather than spread all throughout virtual memory.

> Determining whether a pointer points to the beginning of a small object
> doesn't really require a mod operation.  (We stopped doing that when
> we moved to machines with a really slow mod operation.)  There are typically
> a small number of distinct small object sizes.  You simply precompute
> a layout map for pages for each size.  [...]

Of course that's the way to do it; I should have put a little more
thought into it before posting.

You could also just round object sizes like 12 up to 16, and then
use bitwise operations.

> In general, aside from anomalies like slow mod operations, I conjecture that
> an important complexity measure for all of these algorithms is the number
> of cache misses.  [...]

All these page tables and layout maps would wind up in cache, which
is a big plus.

>>> [questioning why one would ever need to do explicit deletes]

>> Significant reduction in the number of GC's!  [Manually deleting
>> some objects means GC-inducing junk accumulates more slowly.]

> Presumably you're really worried about pause times, and frequency of pauses.
> That's usually a valid concern, but in the presence of concurrent or
> incremental collection, things become less clear.  Even in the presence
> of generational collection, it may not buy you much if the short-lived
> objects are the ones that are being handled manually.

Do you really think incremental or generational collectors are
feasible in C++?  I've never looked in the guts of one of these
collectors, but as I understand it they tend to depend on the
ability to move data around, and other things that a C++ collector
might not be able to get away with.  (C++'s use of pointers is so
unrestricted that it's a minor miracle it's possible to do garbage
collection at all...)

I would love to be proved wrong in this guess!

								-- Dave
--
Dave Gillespie
  daveg@synaptics.com, uunet!synaptx!daveg
  or: daveg@csvax.cs.caltech.edu
Newsgroups: comp.lang.c++