comp.lang.ada
 help / color / mirror / Atom feed
From: boehm@parc.xerox.com (Hans Boehm)
Subject: Re: Reference Counting (was Re: Searching Method for Incremental Garbage Collection)
Date: 2 Dec 1994 21:37:47 GMT
Date: 1994-12-02T21:37:47+00:00	[thread overview]
Message-ID: <3bo43b$61v@news.parc.xerox.com> (raw)
In-Reply-To: 3bjfep$9ss@gamma.ois.com

beckwb@ois.com (R. William Beckwith) writes:

>Hans Boehm (boehm@parc.xerox.com) wrote:
>: You do need at least a write barrier on the heap for incremental collection.
>:...

>Hmmm.  The code that gets executed on processing the write barrier seems
>like it would take alot longer than incr/decr the reference count.  I've
>never seen the code, so I just going on hunch here.

The cost of the write barrier clearly depends on the algorithm.  But in
a number of cases all you need to do is to remember that a write to that
location occurred.  This may require a very small number of instructions
(I vaguely remember 4 or 5 from some talks on software write barriers)
or none (in the case of VM support).  Of course the cheaper implementations
may have other costs.

>: The crucial issue in my mind is whether you can safely avoid counting
>: pointers from the stack.

>You and Henry (et al) are the wizzards here.  Do the stack based
>references really cause most of the incr/decr operations?

The details obviously depend on the application.  But that's certainly
what I would expect for the vast majority of applications.  (I intended
to include register assignments with stack assignments.)  Heap assignments
tend to be rare in most code.  But things like list traversals are very
common, and usually involve many updates to a local variable.

Manual or compiler optimizations can significantly improve matters.
But those are generally risky or not possible with smart pointer
style implementations.

As was mentioned earlier, there are several fast RC implementations
(various older Xerox systems and DEC Modula-2+) that explicitly
avoided counting stack references and instead used a conservative
stack scan.

>: It also doesn't help with local variables that are updated.

>Updating local (stack) variables doesn't modify the object graph,
>but doesn't it change to roots?  Don't non-conservative GC'tion
>mechanisms have to update some root symbol list?

Maintaining an explicit list of stack resident roots is
expensive.  I would guess that most such schemes are comparable to
reference counting.  One alternative is to conservatively
scan the stack.  (This is done by many systems other than ours,
e.g. the above reference counted systems, SRC Modula-3, gcl or AKCL,
Bartlett's C++ and Scheme collectors, scm, and probably others.)
Another alternative is to generate stack frame descriptors, and
to have the collector walk the stack, mapping return addresses
to pointer locations.  This involves no overhead outside the collector,
but substantial compiler support.  A third alternative, commonly used in
dynamically typed languages, is to use some combination of a
register usage convention and tagged pointers.  That's probably
cheaper than explicit root lists, but has some overhead and some other
problems.

Hans-J. Boehm
(boehm@parc.xerox.com)
Standard disclaimer ...



  parent reply	other threads:[~1994-12-02 21:37 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CzHCvp.9rM@rheged.dircon.co.uk>
     [not found] ` <TFB.94Nov21091959@burns.cogsci.ed.ac.uk>
     [not found]   ` <RFB.94Nov27213114@cfdevx1.lehman.com>
     [not found]     ` <3be0mh$1p7@gamma.ois.com>
     [not found]       ` <3bfprn$okr@scipio.cyberstore.ca>
1994-11-29 21:27         ` Reference Counting (was Re: Searching Method for Incremental Garbage Collection) R. William Beckwith
1994-11-30  2:27           ` Henry G. Baker
1994-11-30 18:59           ` Hans Boehm
1994-12-01  3:20             ` R. William Beckwith
1994-12-01  3:51               ` R. William Beckwith
1994-12-01 13:59               ` Henry G. Baker
1994-12-02  4:26                 ` R. William Beckwith
1994-12-02 21:37               ` Hans Boehm [this message]
1994-12-03 15:17                 ` Henry G. Baker
1994-12-09 22:07                   ` Bob Duff
1994-12-11 23:59                     ` Gary McKee
1994-12-12  5:04                       ` Henry G. Baker
1994-12-12 12:46                         ` R. William Beckwith
1994-12-16 19:35                         ` Bob Duff
1994-12-17 20:36                           ` Robert Dewar
1994-12-20  5:24                           ` Henry G. Baker
1994-12-12  9:36                     ` Robb Nebbe
1994-12-13 16:12                     ` Henry G. Baker
     [not found]           ` <DAG.94Nov30090717@bellman.control.lth.se>
1994-11-30 16:39             ` David Weller
1994-11-30 17:58               ` Erik Naggum
1994-11-30 23:14                 ` Michael Feldman
1994-12-09 14:19                 ` Ada 95 is the name Tucker Taft
1994-12-09 22:33                   ` Pat Rogers
1994-12-11 18:59                     ` Jean D. Ichbiah
1994-12-11 20:05                       ` Pat Rogers
1994-12-16  1:01                         ` Bob Duff
1994-12-12 14:50                       ` Garlington KE
1994-12-13 21:48                         ` Tucker Taft
1994-12-14 12:44                         ` Gentle
1994-12-14 17:34                         ` Jean D. Ichbiah
1994-12-10 10:10                   ` Marc Wachowitz
1994-12-11 21:37                     ` Bob Duff
1994-12-02 23:41             ` Reference Counting (was Re: Searching Method for Incremental Garbage Collection) Bob Duff
1994-12-03  8:16               ` Bill Birch
     [not found]     ` <3be0mh$1p7@ga <3bii2g$kn2@news.parc.xerox.com>
1994-12-01  4:58       ` Kevin Warne
1994-12-02 21:58         ` Hans Boehm
     [not found] <D06r8x.JBy@inmet.camb.inmet.com>
1994-12-02 17:32 ` Henry G. Baker
1994-12-05 20:59   ` Robert Firth
1994-12-06 14:15     ` Robert Dewar
1994-12-04  1:06 ` Rick Busdiecker
1994-12-04 18:57   ` R. William Beckwith
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox