home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / cplus / 12512 < prev    next >
Encoding:
Text File  |  1992-08-18  |  3.4 KB  |  73 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!decwrl!parc!boehm
  3. From: boehm@parc.xerox.com (Hans Boehm)
  4. Subject: Re: Garbage Collection for C++
  5. Message-ID: <boehm.714158406@siria>
  6. Sender: news@parc.xerox.com
  7. Organization: Xerox PARC
  8. References: <1992Aug6.014619.2111@ucc.su.OZ.AU>     <DAVEG.92Aug13025629@synaptx.synaptics.com>     <TMB.92Aug16164940@arolla.idiap.ch>     <1992Aug18.021453.24394@news.mentorg.com> <DAVEG.92Aug17224359@synaptx.synaptics.com>
  9. Date: 18 Aug 92 17:20:06 GMT
  10. Lines: 61
  11.  
  12. Some technical points:
  13.  
  14. daveg@synaptics.com (Dave Gillespie) writes:
  15. >Also:  The trickiest part of a conservative GC like KCL's is checking
  16. >whether a given word really is a valid pointer.  While this can be done
  17. >fairly efficiently, it's still not lightning-fast; KCL has to do a
  18. >modulo operation each time, for example.
  19.  
  20. >But the test for whether or not a pointer points *somewhere* in the
  21. >GC-able zone of memory is trivial.  So if 90% of a program's allocation
  22. >can use manual deletion, we can do that allocation in a different memory
  23. >space and let the garbage collector do a trivial reject on 90% of
  24. >the pointers (more or less).
  25.  
  26. This is highly system dependent.  In the latest versions of our collectors,
  27. things may well be the other way around.  You generally can't assume
  28. contiguity of the garbage collected heap.  You also don't really
  29. want any bookkeeping information on the pages of the garbage collected
  30. heap.  That way a page containing pointerfree objects is never touched
  31. during a collection.  Neither is an entirely empty page.  Thus we find out
  32. whether a page is in a GC-able zone by a lookup in a two-level tree.
  33.  
  34. Determining whether a pointer points to the beginning of a small object
  35. doesn't really require a mod operation.  (We stopped doing that when
  36. we moved to machines with a really slow mod operation.)  There are typically
  37. a small number of distinct small object sizes.  You simply precompute
  38. a layout map for pages for each size.  Thus the pointer validity check is
  39. basically a single table lookup, once you have the page descriptor
  40. form the two level tree.
  41.  
  42. In general, aside from anomalies like slow mod operations, I conjecture that
  43. an important complexity measure for all of these algorithms is the number
  44. of cache misses.  The amount of memory you have to read seems to matter
  45. more than anything else.  (Ben Zorn's measurements suggest something
  46. like this, but I have no conclusive evidence that the above is true.)
  47.  
  48. >>|>  (3) Even in a system with (conservative) GC, you can still return
  49. >>|>      memory to the system using some form of unsafe "free" or "delete"
  50. >>|>      (e.g., as provided by Boehm's collector).
  51.  
  52. >> Agreed, but there has to be some point in doing so. I see two possible reasons
  53. >> for having an explicit delete:
  54. >> ...
  55. >> Any others?
  56.  
  57. >The best one (IMHO):
  58.  
  59. >Significant reduction in the number of GC's!  Again let's suppose 90%
  60. >of our allocation can be deleted manually.  That means that, without
  61. >doing any GC's, the amount of junk in memory grows only 10% as fast
  62. >as with no deletion at all.  So, with GC's, it takes ten times as long
  63. >to accumulate enough junk to cause another GC.
  64.  
  65. Presumably you're really worried about pause times, and frequency of pauses.
  66. That's usually a valid concern, but in the presence of concurrent or
  67. incremental collection, things become less clear.  Even in the presence
  68. of generational collection, it may not buy you much if the short-lived
  69. objects are the ones that are being handled manually.
  70.  
  71. Hans-J. Boehm
  72. (boehm@parc.xerox.com)
  73.