170 likes | 352 Views
An Efficient Machine-Independent Procedure for Garbage Collection in Various List Structures , Schorr and Waite CACM August 1967, pp 501-506. Curtis Dunham CS 395T Memory Management, Spring 2011. Mark-Sweep Garbage Collection. Technique not called “Mark-Sweep” in this work
E N D
An Efficient Machine-Independent Procedure for Garbage Collection in Various List Structures, Schorr and Waite CACM August 1967, pp 501-506 Curtis Dunham CS 395T Memory Management, Spring 2011 Mark-Sweep Garbage Collection
Technique not called “Mark-Sweep” in this work • SCHEME-79 paper (Holloway, Steele, Sussman, and Bell) the first to use this label • The verbs “trace” and “mark” are used however Some interesting notes (1)
Credit for the idea given to John McCarthy(Lisp, 1960) • Section 4c of his Recursive Functions of Symbolic Expressions and Their Computation by Machine, Part I describes the same process of using the sign bit to mark memory cells, then scanning the heap Some interesting notes (2)
Algorithm independently discovered by L Peter Deutsch Some interesting notes (3)
Words in memory called “registers” • IBM 7094 • 215 36-bit words; 144 KB • 0.5 MHz, or more charitably, 500 KHz Historical Background
Three options for reclaiming memory: Programmer does it manually Reference Counting “Garbage collection”, like McCarthy suggested Memory Management, in their words
McCarthy pretty much solved this, right? • Three problems, our authors claim: • Algorithms for “tracing the lists” (today, traversing the directed graph) at that time were expensive in either time or space • Signed numbers, or,Hey, I was using that sign bit • Heap objects occupying multiple words So What’s The Big Deal, Anyway?
3 bits of the 36-bit words in a 7094 are for a prefix field • Use one of those bits to indicate what is actually stored in that word • the number of words that make up the heap object, or • the heap object itself Large (Multiple Word) Heap Objects A word 3 data data Another word
Use a large heap object,then the “interior” words have usable sign bits Signed Numbers
Must run in fixed space • No queue for breadth-first • No stack growth for recursive techniques, e.g. depth-first • Must trace efficiently • Bounded visits per object • Must handle circular lists The Algorithm - Constraints 3 words 2 visits That, too.
Mutator and collector do not run concurrently • Heap can be arbitrarily modified, so long as it is correct when the mutator resumes • In a depth-first recursive scheme, the stack provides “breadcrumbs” that allow us to find our way back • Reverse pointers as they are traversed • Easy to do, easy to undo, provides “breadcrumbs” for free (in terms of space) The Algorithm – The Trick
Visualization Trace through (follow) Tail elements (again), Only this time, traversal is reversed. Reverse Pointers (again) Check Head fields for pointers.If any are found, recursively apply this procedure. Mark (sign bit) Depth (prefix bit) Head (car) Tail (cdr) Trace through (follow) Tail elements: Reverse Pointers Set Mark Bits
This technique will mark everything on the heap that is reachable. A sweep of the entire heap is necessary to find all the unmarked words, which are returned to the free list. This algorithm solves “one-way list” tracing. With modification, it can trace others (see section 7 of paper) Finally…
Testbed: pathological 5-list, 20K-element depth-12 “mess” • 1.85s for this work • 2.75s for Wilkes • 0.448s for breadth-first with 48 element queue • Authors’ opinion • Space is available: use the breadth-first approach • Otherwise: this approach takes essentially no space; use it instead Experimental Results Cannot handle circular lists
The authors mention a concern for portability • The final sweep through the heap is machine-dependent, but with just 6 special functions,the tracer/marking algorithm can be written in the higher level language (Wisp) • Analogous to MMTk’s Java GC in Java Higher Thinking, Please
(other than this paper, cited on title slide) http://en.wikipedia.org/wiki/IBM_7090 http://www-03.ibm.com/ibm/history/exhibits/mainframe/mainframe_PP7094.html Gries, David. The Schorr-Waite graph marking algorithm. 1979. http://dx.doi.org/10.1007/BF00289068 McCarthy, John. Recursive functions of symbolic expressions and their computation by machine, Part I. CACM April 1960 http://dx.doi.org/10.1145/367177.367199 Holloway, Jack; Steel, Guy Lewis, Jr.; Sussman, Gerald Jay; Bell, Alan. The SCHEME-79 Chip. 1980. http://hdl.handle.net/1721.1/6334 Previous slides by SowmiyaChocka Narayanan References/Resources/Acknowledgements
Experimental methodology • Performance of pointer reversals • Performance • Human-noticable delay in stop-the-world design • Motivation for incrementality, not waiting for heap to fill up, etc.? • Significance of “no-space” design today Discussion