comp.lang.ada
 help / color / mirror / Atom feed
From: eachus@spectre.mitre.org (Robert I. Eachus)
Subject: Re: Garbage Collection in Ada
Date: 1996/10/24
Date: 1996-10-24T00:00:00+00:00	[thread overview]
Message-ID: <EACHUS.96Oct24182610@spectre.mitre.org> (raw)
In-Reply-To: 01bbb910$f1e73f60$829d6482@joy.ericsson.se



  (This post started yesterday, and I added a section replying to
Richard A. O'Keefe's comments on the Interlisp-D compiler at the end.)

  > In article <199610181934142408603@dialup101-3-15.swipnet.se>,
  > Lars Farm <lars.farm@ite.mh.se> wrote:
  > >- How large is the probability that this occurs?

  > (Where "this" = "conservative GC fails to collect some garbage".)

  > I don't see any way of assigning a numeric probability to it.  That's
  > the main thing that makes *me* nervous about it.  I mean, there's
  > nothing under the programmer's control that can let you know if or when
  > this sort of bug might happen.

    We can make some average case assumptions and see that the
probability of trouble in even moderate sized programs is pretty high.
The probability a block is marked as uncollectable is the probability
that any space already in the uncollectable set has something that
will be seen as a pointer to that block.  Assuming (BIG assumption)
that all bit patterns are equally likely, and 32-bit pointers, the
probability that any word is seen as locking a block is
1/2**32/(addresses per block).  If we use R to indicate the number of
words in the required (uncollectable) space not used for real
pointers, C as the number of addresses in the collectable space and B
as the (average) number of addresses per block, then the birthday
effect takes over when R*C*B approaches 2**32.  Basically this means
that conservative GCs become useless when available memory times
required memory times block size is of the same order as the number of
different pointers.

    To take it one step further, if your program requires 16K of
non-pointer "random" data space on a 32-bit addressable machine, even
with small allocated objects, a "conservative" collector is so much
junk.  (Uncollected garbage will on average lock down more uncollected
garbage, and the amount of uncollected garbage will grow without
bound.)

    What about 64-bit machines?  Now another factor jumps out to bite
you.  Bit patterns in memory are not random.  In particular, low
numbers are favored, and are more likely to correspond to actual
memory locations.  On a machine with a 64-bit address space, my guess
is that a conservative collector is useful up to a megabyte of
non-pointer live data.

    Now lets go with an absolute best case scenario for long lived
systems.  The application has exactly one word of non-pointer storage
that is non-garbage, points to a valid heap address, and doesn't
change.  Each dyanamically allocated object also contains one
non-pointer word and a pointer that is sometimes non-null.  It is easy
to prove that over time more and more of the store will not be
available, and eventually you will run out of storage.  So
"conservative" collectors are of no use in applications where you want
to do your best to keep the application running.  If you don't
believe the above, write the program--I'll make sure you have a good
enough RNG--and run it.  Memory consumption (you measure it after GC
runs of course) will stay low initially, but eventually you will lock
in some garbage, then memory consumption rises rapidly.  You probably
turn the program off before it crashes because you are spending most
of your time in garbage collection.

   This lesson was learned and learned well in the early days of LISP
implementations.  Systems attempting to use conservative collectors
eventually died.  I remember one incident on a PDP-1 at MIT where this
happened in under an hour.  (The machine had 16K of 18-bit memory, and
a large--for 1964--drum that could be directly addressed.  The LISP
implementation stored all objects on the drum, using if I remember
correctly 22-bit pointers, but the drum had less than a million
words.)

In article <54mrhq$bqn$1@goanna.cs.rmit.EDU.AU> ok@goanna.cs.rmit.EDU.AU (Richard A. O'Keefe) writes:

  > A conserative garbage collector was an intrinsic part of
  > Interlisp-D.  All references from the heap were precise, but the
  > stack was scanned conservatively (in order to make the processing
  > of unboxed floats cheap).  The Quintus Prolog garbage collector
  > had a similar problem with floats, and took the conservative
  > route.

   This does not have the same abysmal characteristics.  As long as
the heap and stack are treated differently, the worst case behavior is
that you expect the amount of junk locked to depend on the number of
non-pointer values on the stack (and the size of heap structures), not
how long the program has been running.

   This particular "semi-conservative" GC style fell out of favor
becuase you had to munge records copied from the stack to the heap,
and vice-versa and special case offsets on where the object was
currently located.

   The better solution was to always store and GC) records and arrays
the same way no matter where they are located (usually starting with a
one-word pointer to a GC thunk), add a counter to the stack frame and
put all pointers at the head of the data section.  The GC code turns
out to be very simple, you can compact if you wish, and all you lose
is one word per heap object and two words per complex object on the
stack.

					Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...
--

					Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...




  parent reply	other threads:[~1996-10-24  0:00 UTC|newest]

Thread overview: 126+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-10-13  0:00 Garbage Collection in Ada Jonas Nygren
1996-10-13  0:00 ` Lars Farm
1996-10-13  0:00   ` Larry Kilgallen
1996-10-13  0:00   ` Robert Dewar
     [not found]     ` <19961014115513529729@dialup105-2-16.swipnet.se>
1996-10-16  0:00       ` Robert Dewar
1996-10-16  0:00         ` Hans-Juergen Boehm
1996-10-16  0:00           ` Robert Dewar
1996-10-16  0:00             ` Hans-Juergen Boehm
1996-10-17  0:00               ` Robert Dewar
1996-10-17  0:00                 ` Hans-Juergen Boehm
1996-10-17  0:00                   ` Robert Dewar
1996-10-16  0:00         ` Lars Farm
1996-10-16  0:00           ` Robert Dewar
1996-10-16  0:00             ` Hans-Juergen Boehm
1996-10-17  0:00               ` Robert A Duff
1996-10-17  0:00                 ` Hans-Juergen Boehm
1996-10-17  0:00                 ` Larry Kilgallen
1996-10-17  0:00               ` Robert Dewar
1996-10-17  0:00                 ` Hans-Juergen Boehm
1996-10-17  0:00             ` Lars Farm
1996-10-23  0:00               ` Robert Dewar
1996-10-14  0:00   ` John Howard
1996-10-15  0:00     ` Lars Farm
1996-10-15  0:00       ` Robert Dewar
1996-10-15  0:00         ` Lars Farm
1996-10-15  0:00         ` Hans-Juergen Boehm
1996-10-17  0:00         ` Thomas Kendelbacher
1996-10-17  0:00           ` Robert Dewar
1996-10-23  0:00         ` Richard A. O'Keefe
1996-10-23  0:00           ` Larry Kilgallen
1996-10-15  0:00       ` Robert A Duff
1996-10-14  0:00   ` Robert A Duff
1996-10-14  0:00     ` Lars Farm
1996-10-15  0:00       ` Robert A Duff
1996-10-16  0:00         ` Lars Farm
1996-10-16  0:00           ` Robert Dewar
1996-10-17  0:00             ` Robert A Duff
1996-10-19  0:00               ` Richard Kenner
1996-10-19  0:00               ` Robert Dewar
1996-10-19  0:00                 ` Lars Farm
1996-10-20  0:00                   ` Robert Dewar
1996-10-20  0:00                     ` Robert A Duff
1996-10-20  0:00                       ` Robert Dewar
1996-10-21  0:00                     ` Geert Bosch
1996-10-21  0:00                       ` Hans-Juergen Boehm
1996-10-21  0:00                     ` Lars Farm
1996-10-21  0:00                       ` Robert Dewar
1996-10-21  0:00                         ` Lars Farm
1996-10-23  0:00                     ` Fergus Henderson
1996-10-24  0:00                     ` Richard A. O'Keefe
1996-10-20  0:00                 ` Robert A Duff
1996-10-20  0:00                   ` Robert Dewar
1996-10-21  0:00                     ` Hans-Juergen Boehm
1996-10-21  0:00                       ` Robert Dewar
1996-10-15  0:00     ` Hans-Juergen Boehm
1996-10-15  0:00   ` Keith Thompson
1996-10-13  0:00 ` Robert Dewar
1996-10-14  0:00 ` Jon S Anthony
1996-10-15  0:00   ` Robert Dewar
1996-10-15  0:00 ` Hannes Haug
1996-10-15  0:00 ` Robert I. Eachus
1996-10-15  0:00   ` Robert Dewar
1996-10-16  0:00   ` whiting_ms@corning.com (Matt Whiting)
1996-10-16  0:00     ` Robert Dewar
1996-10-17  0:00   ` John Howard
1996-10-17  0:00     ` Robert Dewar
1996-10-18  0:00       ` Hans-Juergen Boehm
1996-10-18  0:00       ` Lars Farm
1996-10-20  0:00         ` Robert A Duff
1996-10-18  0:00       ` Lars Farm
1996-10-19  0:00         ` Robert Dewar
1996-10-20  0:00           ` Lars Farm
1996-10-21  0:00             ` Nicolay Belofastow
1996-10-21  0:00               ` Robert Dewar
1996-10-21  0:00             ` Robert Dewar
1996-10-22  0:00               ` Lars Farm
1996-10-20  0:00         ` Robert A Duff
1996-10-20  0:00           ` Robert Dewar
1996-10-22  0:00         ` Mitch Gart
1996-10-23  0:00           ` Fergus Henderson
1996-10-23  0:00           ` Hans-Juergen Boehm
1996-10-27  0:00             ` Richard Riehle
1996-10-29  0:00         ` Jon S Anthony
1996-10-30  0:00         ` Brian Rogoff
1996-10-30  0:00         ` Jonas Nygren
1996-10-30  0:00         ` Jon S Anthony
1996-10-30  0:00         ` James Rogers
1996-10-16  0:00 ` Jon S Anthony
1996-10-16  0:00 ` Jon S Anthony
1996-10-16  0:00 ` Jon S Anthony
1996-10-17  0:00   ` Robert Dewar
1996-10-16  0:00 ` Jon S Anthony
1996-10-16  0:00 ` Ole-Hjalmar Kristensen FOU.TD/DELAB
1996-10-16  0:00   ` Robert Dewar
1996-10-17  0:00 ` Hans-Juergen Boehm
1996-10-17  0:00 ` Rick Hudson
1996-10-17  0:00 ` Robert I. Eachus
1996-10-17  0:00   ` Robert Dewar
1996-10-17  0:00     ` Richard Kenner
1996-10-18  0:00 ` Rick Hudson
1996-10-18  0:00 ` Jon S Anthony
1996-10-18  0:00   ` Robert Dewar
1996-10-18  0:00 ` Jon S Anthony
1996-10-23  0:00   ` Robert Dewar
1996-10-21  0:00 ` Laurent Pautet
1996-10-21  0:00 ` Jon S Anthony
1996-10-22  0:00 ` Tapani Rundgren
1996-10-22  0:00 ` Jon S Anthony
1996-10-23  0:00 ` Jon S Anthony
1996-10-24  0:00   ` Mitch Gart
1996-10-24  0:00 ` Hans-Juergen Boehm
1996-10-24  0:00 ` Robert I. Eachus [this message]
1996-10-25  0:00 ` Jon S Anthony
1996-10-28  0:00 ` Robert I. Eachus
1996-10-29  0:00 ` Hans-Juergen Boehm
     [not found] <01bbc6a3$4cf03480$829d6482@joy.ericsson.se>
1996-10-31  0:00 ` Mitch Gart
1996-10-31  0:00   ` Jonas Nygren
1996-11-03  0:00   ` Matthew Heaney
1996-11-06  0:00     ` Robert A Duff
1996-11-06  0:00       ` Norman H. Cohen
1996-11-01  0:00 ` Jon S Anthony
1996-11-06  0:00 ` Brian Rogoff
1996-11-07  0:00   ` Tucker Taft
  -- strict thread matches above, loose matches on Subject: below --
1996-11-02  0:00 Jon S Anthony
1996-10-22  0:00 Brian Rogoff
1996-10-11  0:00 C++ Standardization (was: Once again, Ada absent from DoD SBIR solicitation) Dave Wood
1996-10-17  0:00 ` Garbage Collection in Ada Thomas Kendelbacher
replies disabled

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