Generational Generational Garbage Collection Garbage Collection - - PowerPoint PPT Presentation

generational generational garbage collection garbage
SMART_READER_LITE
LIVE PREVIEW

Generational Generational Garbage Collection Garbage Collection - - PowerPoint PPT Presentation

Generational Generational Garbage Collection Garbage Collection Mirko Jerrentrup, Jerrentrup@interactive-software.de Overview Overview motivation at a glance issues problems and limitations conclusion Motivation


slide-1
SLIDE 1

Generational Generational Garbage Collection Garbage Collection

Mirko Jerrentrup, Jerrentrup@interactive-software.de

slide-2
SLIDE 2

Overview Overview

  • motivation
  • at a glance
  • issues
  • problems and limitations
  • conclusion
slide-3
SLIDE 3

Motivation Motivation

„classical“, e.g. copying GC:

  • repeated handling of long-lived objects
  • no improvement of locality
slide-4
SLIDE 4

The weak generational hypothesis The weak generational hypothesis

  • partition objects into generations
  • special handling of young objects:

→ reduced pause times → better collection efficiency

  • partition objects into generations
  • special handling of young objects:

→ reduced pause times → better collection efficiency

„Most objects die young.“

[Ungar, 1984]

slide-5
SLIDE 5

Generational garbage collection Generational garbage collection

  • objects partitioned into multiple generations
  • old generation seldomly collected

(major collection)

  • surviving young objects promoted into old generation
  • young generation frequently collected

(minor collection)

slide-6
SLIDE 6

Example Example: : minor minor collection collection

  • ld generation

young generation root set root set

  • ld generation

young generation

root set for minor collection root set for minor collection

live nodes „garbage“ nodes

Inter-generational pointer Inter-generational pointer

slide-7
SLIDE 7

Issues Issues in in generational garbage collection generational garbage collection

promotion promotion heap organization heap organization scheduling scheduling inter-generational pointers inter-generational pointers

generational garbage collection generational garbage collection

slide-8
SLIDE 8

promotion promotion

heap organization heap organization scheduling scheduling inter-generational pointers inter-generational pointers

generational garbage collection generational garbage collection

slide-9
SLIDE 9

Promotion Promotion

late promotion early promotion

long-living objects

better worse

short-living objects

better worse

time

slide-10
SLIDE 10

Promotion Promotion policies policies

fixed fixed adaptive adaptive

Promotion policies Promotion policies

Appel‘s collector for SML/NJ demographic feedback- mediated tenuring

slide-11
SLIDE 11

Appel Appel‘s ‘s collector for collector for SML/NJ (1) SML/NJ (1)

  • two generations,

very large young generation

  • major collections only if old objects
  • ccupy half size of heap

[Appel, 1989]

Idea: manage promotion rates by fixing heap occupancy of young objects

  • precondition: contigious heap
slide-12
SLIDE 12

Appel Appel‘s ‘s collector for collector for SML/NJ (2) SML/NJ (2)

equal size

  • ld

free reserve

  • ld

new reserve free reserve

  • ld

svr free

  • ld´

svr free reserve

  • ld

free

equal size

free

  • ld

svr

half heap size

slide-13
SLIDE 13

Demographic Demographic feedback feedback-

  • mediated tenuring

mediated tenuring (1) (1)

  • only promote if pause time will be acceptable

[Ungar, Jackson 1992]

Idea: promote only when necessary to hold maximum pause time

  • promote only as many objects to make

pause time acceptable

  • generate space-age table
slide-14
SLIDE 14

free

Demographic Demographic feedback feedback-

  • mediated tenuring

mediated tenuring (2) (2)

[Ungar, Jackson 1992] free

No promotion at next collection

survivors survivors

promotion of 150 bytes „oldest“ objects 150 bytes

age size of age group 1 2 3 300 bytes 200 bytes 100 bytes

number of survived collections number of survived collections size of objects in age group size of objects in age group

young generation

maximum acceptable pause time

slide-15
SLIDE 15

promotion promotion

heap organization heap organization

scheduling scheduling inter-generational pointers inter-generational pointers

generational garbage collection generational garbage collection

slide-16
SLIDE 16

Heap organization Heap organization Determination of object‘s generation

  • copying collectors: subheaps for generation

contigious heaps → object adress non-contigious heaps → header field or page-table

  • non-copying collectors → header field
slide-17
SLIDE 17

Heap organization schemes Heap organization schemes

creation space creation space „high water mark“ bucket system „high water mark“ bucket system

heap organization schemes heap organization schemes

slide-18
SLIDE 18

Creation Creation space space (1) (1) Organization of a generation:

  • (small) aging area in two semi-spaces
  • (large) new object area in one creation space

[Ungar, 1984]

Goals:

  • no large semi-spaces
  • improve locality
slide-19
SLIDE 19

gc pause

Creation Creation space space (2) (2)

[Ungar, 1984]

time generation

  • ccupancy

creation space aging semi- spaces

slide-20
SLIDE 20

„High „High water mark water mark“ “ bucket bucket system (1) system (1)

[Wilson, Moher 1989]

Goals:

  • avoid age field in object header
  • adaptive promotion threshold
  • two buckets per generation
  • creation space partly holds first bucket
  • high water mark seperates buckets
  • creation and aging spaces per generation

Organization of generations:

slide-21
SLIDE 21

„High „High water mark water mark“ “ bucket bucket system (2) system (2)

[Wilson, Moher 1989]

time heap

  • ccupancy

younger generation next generation bucket 1 bucket 2 high water mark

slide-22
SLIDE 22

„High „High water mark water mark“ “ bucket bucket system ( system (3 3) )

[Wilson, Moher 1989]

  • objects from bucket 1 are stored in bucket 2
  • objects from bucket 2 are promoted into older generation

„high water mark” effect:

  • „high water mark“ position determines promotion threshold
  • promotion threshold between 1 and 2
slide-23
SLIDE 23

promotion promotion heap organization heap organization

scheduling scheduling

inter-generational pointers inter-generational pointers

generational garbage collection generational garbage collection

slide-24
SLIDE 24

Perform collection when :

  • pause is not interruptive

hide collection from user hide collection from user efficent collection efficent collection

Collection scheduling Collection scheduling

  • large amount of garbage

can be expected

slide-25
SLIDE 25

Efficient collections Efficient collections

  • objects whose „death“ produces

much garbage (root of a large tree etc.)

[Hayes 1991]

  • exclude key objects from generational scheme
  • store key objects „descendants“ in

special large object area

  • reclaiming of key objects trigger collection in key area

Key (large) objects :

slide-26
SLIDE 26

[Hayes 1991]

Efficient collections Efficient collections – – key objects key objects (1) (1)

young generation root set

key object key object

slide-27
SLIDE 27

[Hayes 1991]

Efficient collections Efficient collections – – key objects key objects (2) (2)

young generation root set key objects keyed area

slide-28
SLIDE 28

promotion promotion heap organization heap organization scheduling scheduling

inter-generational pointers inter-generational pointers

generational garbage collection generational garbage collection

slide-29
SLIDE 29

Inter Inter-

  • generational pointers

generational pointers

Issues:

  • detecting creation
  • including into root set upon collection
  • cost of detection / inclusion
  • ld generation

young generation root set

root set for young generation root set for young generation

Inter-generational pointer Inter-generational pointer

slide-30
SLIDE 30

Inter Inter-

  • generational pointer handling

generational pointer handling

detecting individual pointers detecting individual pointers marking pointer- containing areas marking pointer- containing areas

  • pointer indirection
  • remembered sets

page / word / card marking detection / storing of inter- generational pointers detection / storing of inter- generational pointers

inter-generational pointer handling inter-generational pointer handling

slide-31
SLIDE 31

Detection Detection Detection of inter-generational pointers:

  • trapping pointer stores
  • only necessary to check objects in old generation(s)
  • generally: only non-initializing stores

write-barrier write-barrier

slide-32
SLIDE 32

Individual pointers Individual pointers – – entry entry table table Idea: indirect pointers through an entry table

[Liebermann, Hewitt 1983] generation 2 generation 1 generation 0

slide-33
SLIDE 33

Individual pointers Individual pointers – – entry entry table table Idea: indirect pointers through an entry table

[Liebermann, Hewitt 1983] trapping stores (by mutator) inter-generationalpointer- handling at collection time small constant for every store O(#stores), small constant O(#stores)

N/A

time space

all pointers in the entry table are added to the root set

generation 2 generation 1 generation 0 entry table entry table

slide-34
SLIDE 34

Individual pointers Individual pointers – – remembered set remembered set Idea: remember objects with old-young pointers

[Ungar 1984] trapping stores (by mutator) inter-generationalpointer- handling at collection time time space small constant for every store

N/A

pointer- containers O(# ) pointer- containers O(# )

no duplicate entries in set due to bit in object header Objects are scanned for pointers: O(size of objects)

  • ld generation

young generation

slide-35
SLIDE 35

Pointer Pointer areas areas – – page marking page marking Idea: mark (virtual) memory pages containing

  • bjects with inter-generational pointers
  • hardware / virtual memory management support
  • only slight overhead for write barrier
  • problems intercepting VM signals
  • large pages → high collection cost

[Shaw 1988] [Moon 1984] trapping stores (by mutator) inter-generationalpointer- handling at collection time time space

N/A

# i.g.p. • size of page O( )

N/A

small constant for every store

pages are scanned for pointers

slide-36
SLIDE 36

Pointer Pointer areas areas – – card marking card marking Idea: don´t mark to-large pages

  • r to-small words

[Wilson, Moher 1989]

  • divide adress space into cards (∼128 bytes)
  • lower collection cost if card size is near object size
  • very low cost for write barrier: 2-3 instructions

[Sobalvarro 1988] trapping stores (by mutator) inter-generationalpointer- handling at collection time time space small constant for every store

N/A

small portion

  • f heap

cards are scanned for pointers

# i.g.p. • size of card O( )

slide-37
SLIDE 37

Remembered sets Remembered sets vs.

  • vs. card marking

card marking remembered sets (with sequential store buffers):

  • small overhead for write barrier (2-3 instructions)
  • no scanning upon collection
  • duplicates in sequential store buffers
  • collection overhead O(#pointer stores)
slide-38
SLIDE 38

Remembered sets Remembered sets vs.

  • vs. card marking

card marking card marking

  • scanning upon collection
  • collection overhead O(#inter-gen. pointers)
  • long-lived object´s cards must be scanned repeatedly
  • small overhead for write barrier (2-3 instructions)
slide-39
SLIDE 39

Remembered sets Remembered sets vs.

  • vs. card marking

card marking

[Hosking, Hudson 1993]

hybrid card marking / remembered set GC

  • write barrier like card-marking
  • after collection, old-young-pointers

are added to remembered set

slide-40
SLIDE 40

Problems and limitations Problems and limitations heuristic failure:

  • cluster of long-lived objects

„pig in the snake“

  • small heap-allocated objects
  • large root sets
slide-41
SLIDE 41

Conclusion Conclusion

  • improvement, if assumptions hold
  • highly variable
slide-42
SLIDE 42

Thank you Thank you ! !