[comp.lang.smalltalk] reference counting vs. garbage collection

psrc@pegasus.ATT.COM (Paul S. R. Chisholm) (09/07/89)

In article <14149@polyslo.CalPoly.EDU>, ttwang@polyslo.CalPoly.EDU
(Thomas Wang) quotes Bertrand Meyer's book OBJECT-ORIENTED SOFTWARE
CONSTRUCTION:
> [Reference counting] is wasteful of both time and space:  every
> operation on a reference, including simple assignment, now involve
> some arithmetic and tests; and an extra integer field must be added
> to each object.
and asks which is faster, reference counting or garbage collection.

He hit every OO group except the one with the answer!  Start with the
Smalltalk "green book", SMALLTALK-80:  BITS OF HISTORY, WORDS OF ADVICE
by Glenn Krasner, 1983, ISBN 0-201-11669-3.  There are several articles
about measuring performance, and in Smalltalk-80, memory management is
critical!  Probably the most interesting article is "Berkeley
Smalltalk:  Who Knows Where the Time Goes?" by Ungar and Patterson.
Eleven to twelve percent of the *total* execution time is spent in
reference counting, and five to six percent of the time allocating and
freeing memory (p. 190, Table 11.1).

Then turn to "SOAR:  Smalltalk Without Bytecodes" by Samples, Ungar,
and Hilfinger in the OOPSLA '86 CONFERENCE PROCEDINGS (SIGPLAN Notices,
November, 1986; ACM order number 548861).  They claim (p. 112) that
"Generation Scavenging, a new garbage collection technique . . . limits
pause times to a fraction of a second, meshes well with virtual memory,
reclaims circular structures, and uses only 3% of the CPU time on SOAR.
This is less than a third of the time of deferred reference counting,
the next best algorithm."

Dave Ungar's Ph.D. thesis is in part about generation scavenging.  THE
DESIGN AND EVALUATION OF A HIGH PERFORMANCE SMALLTALK SYSTEM is
available as an ACM Distinguished Dissertation from MIT Press.

>  -Thomas Wang, ttwang@polyslo.calpoly.edu

Paul S. R. Chisholm, AT&T Bell Laboratories
att!pegasus!psrc, psrc@pegasus.att.com, AT&T Mail !psrchisholm
I'm not speaking for the company, I'm just speaking my mind.