a real time garbage collector based on the lifetimes of objects l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
A Real-Time Garbage Collector Based on the Lifetimes of Objects PowerPoint Presentation
Download Presentation
A Real-Time Garbage Collector Based on the Lifetimes of Objects

Loading in 2 Seconds...

play fullscreen
1 / 28

A Real-Time Garbage Collector Based on the Lifetimes of Objects - PowerPoint PPT Presentation


  • 110 Views
  • Uploaded on

A Real-Time Garbage Collector Based on the Lifetimes of Objects. Henry Lieberman and Carl Hewitt (CACM, June 1983) Rudy Kaplan Depena CS395T: Memory Management February 2, 2009. Motivation: Internal Thinking. “Programs Do A Lot of Internal Thinking” - Lieberman and Hewitt

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'A Real-Time Garbage Collector Based on the Lifetimes of Objects' - jimbo


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
a real time garbage collector based on the lifetimes of objects

A Real-Time Garbage Collector Based on the Lifetimes of Objects

Henry Lieberman and Carl Hewitt

(CACM, June 1983)

Rudy Kaplan Depena

CS395T: Memory Management

February 2, 2009

motivation internal thinking
Motivation: Internal Thinking

“Programs Do A Lot of Internal Thinking”

- Lieberman and Hewitt

public void printAll(ArrayList list){

Iterator it = new list.iterator();

Object temp;

while( it.hasNext() ){

temp = it.next();

System.out.println( temp );

}

}

Code snippet from Mike Scott’s lecture on Iterators

[http://www.cs.utexas.edu/~scottm/cs307/handouts/Slides/Topic15Iterators.pdf]

motivation reference counting

head

Node

Node

Node

next

next

next

refCount = 2

refCount = 1

refCount = 1

Motivation: Reference Counting

Reference Counting claims young objects quickly

Example from “Data Structures and Algorithms with Object-Oriented Design Patterns in Java”

[http://www.brpreiss.com/books/opus5/html/page423.html]

motivation ref counting w cycles

head

Node

Node

Node

next

next

next

refCount = 1

refCount = 1

refCount = 1

Motivation: Ref Counting w/ Cycles

Houston We Have A Problem!

Example from “Data Structures and Algorithms with Object-Oriented Design Patterns in Java”

[http://www.brpreiss.com/books/opus5/html/page423.html]

motivation cycles are needed
Motivation: Cycles Are Needed
  • But Circular Structures are important programming technique for ….
    • Graphics
    • Compilers
    • Other Problem Spaces

So What Do We Do???

real time gc baker s algorithm
Real Time GC [Baker’s Algorithm]

Graphics from Lieberman and Hewitt

[“A Real-Time Garbage Collector Based on the Lifetimes of Objects” - CACM June 1983]

what s wrong with baker
What’s Wrong With Baker?
  • Perhaps Too Slow?
  • Total Garbage Collection Time?
  • Not Space Efficient?
generational hypothesis
Generational Hypothesis
  • “Recently created regions contain high % of garbage” while older regions do not

- Lieberman and Hewitt

  • Improve Baker’s Algorithm
    • Optimize for scavenging short lived objects
    • Scavenge long-lived objects less frequently
  • Rental Cost
    • Storage management cost of an object is proportional to the time during which the object is used

Inspired by Maria Jump’s Presentation in Fall 2003 on Generational GC

[http://www.cs.utexas.edu/users/mckinley/395Tmm-2003/talks/LH83.pdf]

modify baker s algorithm
Modify Baker’s Algorithm
  • Address space broken up into generations
    • Small set of pages (relative to address space)
  • Parallels between Baker Algo and Generational GC
    • Evacuating <=> Condemning Region
    • fromspace <=> Obsolete Region
    • tospace <=> Non-Obsolete Region
    • Evacuating objects the same way

Inspired by Maria Jump’s Presentation in Fall 2003 on Generational GC

[http://www.cs.utexas.edu/users/mckinley/395Tmm-2003/talks/LH83.pdf]

in action
In Action

1960.0

Regions are tagged with generation and version number

From Maria Jump’s Presentation in Fall 2003 on Generational GC

[http://www.cs.utexas.edu/users/mckinley/395Tmm-2003/talks/LH83.pdf]

in action11
In Action

1960.0

Allocation occurs in creation region

From Maria Jump’s Presentation in Fall 2003 on Generational GC

[http://www.cs.utexas.edu/users/mckinley/395Tmm-2003/talks/LH83.pdf]

in action12
In Action

1960.0

… until the creation region is full

From Maria Jump’s Presentation in Fall 2003 on Generational GC

[http://www.cs.utexas.edu/users/mckinley/395Tmm-2003/talks/LH83.pdf]

in action13
In Action

1970.0

1960.0

  • CONS composes existing components into objects
    • creates a backward pointer

… the new creation region is created

From Maria Jump’s Presentation in Fall 2003 on Generational GC

[http://www.cs.utexas.edu/users/mckinley/395Tmm-2003/talks/LH83.pdf]

in action14
In Action

1970.0

1960.0

… and so on

From Maria Jump’s Presentation in Fall 2003 on Generational GC

[http://www.cs.utexas.edu/users/mckinley/395Tmm-2003/talks/LH83.pdf]

in action15
In Action

1970.0

1980.0

1960.0

… and so on

From Maria Jump’s Presentation in Fall 2003 on Generational GC

[http://www.cs.utexas.edu/users/mckinley/395Tmm-2003/talks/LH83.pdf]

in action16
In Action

1970.0

1980.0

1960.0

1970.1

GC is initiated by condemning a region (making it obsolete) and creating an evacuation region

From Maria Jump’s Presentation in Fall 2003 on Generational GC

[http://www.cs.utexas.edu/users/mckinley/395Tmm-2003/talks/LH83.pdf]

in action17
In Action

1970.0

1980.0

1960.0

1970.1

1980.1

This requires that younger generations also be condemned

WHY ?????

Modified from Maria Jump’s Presentation in Fall 2003 on Generational GC

[http://www.cs.utexas.edu/users/mckinley/395Tmm-2003/talks/LH83.pdf]

in action18
In Action

1970.0

1980.0

1960.0

1970.1

1980.1

Accessibile objects in condemned region(s) are incrementally evacuated using Baker’s Algorithm

From Maria Jump’s Presentation in Fall 2003 on Generational GC

[http://www.cs.utexas.edu/users/mckinley/395Tmm-2003/talks/LH83.pdf]

in action19
In Action

1960.0

1970.1

1980.1

… and the memory is recycled!

From Maria Jump’s Presentation in Fall 2003 on Generational GC

[http://www.cs.utexas.edu/users/mckinley/395Tmm-2003/talks/LH83.pdf]

varying gc rates
Varying GC Rates
  • Younger generations contain high percentages of garbage
    • They should be collected frequently
  • Older generation contains relatively permanent data
    • Older objects collected seldomly
  • Getting the most “Bang for your Buck”
    • Scavange where there is high proportion of inaccessible objects
  • Minimize amount of scavenging needed per inaccessible object
    • Why is this important?

Modified from Maria Jump’s Presentation in Fall 2003 on Generational GC

[http://www.cs.utexas.edu/users/mckinley/395Tmm-2003/talks/LH83.pdf]

scavanging is expensive
Scavanging is Expensive!
  • We must restrict the storage that has to be scanned to find and update obsolete references
  • We restrict pointers from older generations to newer generations
    • This means it will be faster to reclaim regions in recent generations since little storage needs to be scavenged

What happens when an attempt is made to create a pointer from older to younger generation????

entry tables
Entry Tables

1970.0

1980.0

1960.0

  • In Lisp, RPLACA can assign a new pointer as a component to an older object
    • creates a forward pointer
  • Add entry table to record forward pointers
  • Adds a level of indirection for some pointers
  • Won’t have to scan entire heap
  • GC uses entry table entries as roots to the region

From Maria Jump’s Presentation in Fall 2003 on Generational GC

[http://www.cs.utexas.edu/users/mckinley/395Tmm-2003/talks/LH83.pdf]

weak pointers
Weak Pointers
  • Weak pointers are …
    • Pointers in program which do not protect objects from being collected.
  • Small in Number
  • Use entry table
  • Weak Pointers => Forward Pointers
  • Forward Pointers > Weak Pointers
  • Weak Pointers are not persistently updated if object (i.e. - pointee) is garbage collected.
  • Forward Pointers (which are NOT weak pointers) are persistently updated after GC occurs
some bad news
Some Bad News
  • Fragmentation results from partially filled regions ….

How do we deal with this ???

  • Choose region sizes to minimize fragmentation
  • Coalesce older regions reducing the amount of wasted space
  • Perhaps use hybrid incremental collection sparingly
an optimization value cells stacks
An Optimization? -Value Cells & Stacks
  • Lisp implementations involve internal stacks
    • Holds state info and variables
  • Stack must be scavenged for pointers to non-user-accessible objects
  • Young objects lifetime correlated with pushing and popping the stack.
    • Suggests that good time to expect a lot of garbage when returning from function (remember printAll()?)
an optimization flavors of new
An Optimization?-Flavors of new
  • Providing different allocators for different regions?
    • Can users direct the flavor of allocation?
    • Can compiler analysis change flavor of allocation?
    • Can runtime information change flavor of allocation?

From Maria Jump’s Presentation in Fall 2003 on Generational GC

[http://www.cs.utexas.edu/users/mckinley/395Tmm-2003/talks/LH83.pdf]

aspects of program behavior
Aspects of Program Behavior
  • Rate of object creation
    • How fast are objects created?
  • Average lifetimes of objects
    • How fast do objects become inaccessible
  • Proportion of forward vs backward pointers
    • High % of pointing to old objects bodes well for this scheme
  • Average “length” of pointers
    • What’s the locality like?
    • Close locality would be nice :)

Modified from Maria Jump’s Presentation in Fall 2003 on Generational GC

[http://www.cs.utexas.edu/users/mckinley/395Tmm-2003/talks/LH83.pdf]