Sunday, September 28, 2014

Tuesday, September 16, 2014

Chapters 9-12

9-12

9-12

Chapter 9: Generational Garbage Collection

Prologue

Tracing collectors have best case when heap is mostly garbage, but long-lived objects tend to exhibit pathologically bad behavior for copying and mark-sweep

  • Ex: Mark-sweep has dense prefix near bottom of heap, copying moves data unnecessarily

Solution: Segment the heap into generations and collect the youngest generation(nursery) most frequently. Tenure into older generations after surviving a number of sweeps.

  • Most of the time use copying
  • Has good mark/cons ratio, so should be faster for young generation
  • Can tune pause times / frequency of pauses by altering nursery size

Only improves average-case time. Worst case still needs to sweep whole heap.

Tuesday, September 9, 2014

Racket GC Tests.

To anyone doing the racket garbage collector exercises, this is the assignment page for a class doing the exact exercise. It specifies tests that must pass as well; I found this link while trying to think up tests in the face of a lack of working libraries(equals?, map, filter, fold) and a suspicion of a lack of tail call recursion.

http://www.eecs.northwestern.edu/~robby/courses/321-2014-winter/hw7.html

I recommend the assignment as it imposes upon the student how elementary mark-sweep really is.

Monday, September 1, 2014

Notes on Chapters 5-8 of Garbage Collection Handbook

Chapter 5: Reference Counting
- Invariant: An object is alive iff the number of references to it are greater than 0
- Each object has a reference count
- When references mutated, we increment or decrement the reference count. When it reaches 0, it is freed.
- Required write barrier. 
- Mutator uses barriers to keep state of object graph consistent when changes can be non-atomic to the GC

1.1 Advantages + Disadvantages:
Advantages:
- Costs are spread throughout computation time
- Operates well without much headroom
- Potentially free memory immediately
- Locality may be not worse than actual program since only actively used or modified objects referenced
- Does not need runtime assistance, doesn’t need to know roots
- Heavily used today
- Available in C++ through “smart pointers” or pointers with special logic