age-oriented concurrent garbage collection harel paz, erez petrank – technion, israel steve...

29
Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

Post on 21-Dec-2015

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

Age-Oriented Concurrent Garbage Collection

Harel Paz, Erez Petrank – Technion, IsraelSteve Blackburn – ANU, Australia

April 05 Compiler Construction Scotland

Page 2: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

2Compiler Construction, April 2005Age-Oriented GC

Garbage Collection • User allocates space dynamically, the garbage

collector automatically frees the space when it no longer reachable by a path of pointers from program local references (roots).

• Programmer does not have to decide when to free an object. (Memory leaks, dangling pointers.)

• Built into Java, C#.

Page 3: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

3Compiler Construction, April 2005Age-Oriented GC

Garbage Collection Today

• Today’s advanced environments:– multiprocessors + large memories

Dealing with multiprocessors

Single-threaded stop the world

Page 4: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

4Compiler Construction, April 2005Age-Oriented GC

Garbage Collection Today

• Today’s advanced environments:– multiprocessors + large memories

Dealing with multiprocessors

Concurrent collectionParallel collection

High throughput

Short pauses

Page 5: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

5Compiler Construction, April 2005Age-Oriented GC

Outline • Garbage collection and modern platforms Properties of classical algorithms• Generational garbage collection• Age-oriented collection• Implementation, measurements• Conclusion

Page 6: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

6Compiler Construction, April 2005Age-Oriented GC

Garbage Collection

Two Classical Approaches

Reference counting [Collins 1960]: keep a reference count for each object, reclaim objects with count 0.

Tracing [McCarthy 1960]: trace reachable objects, reclaim objects not traced.

Complexity: - traversal of live objects- (sweep is typically fast)

Complexity: - tracking pointer modific’s- traversal of dead objects

Page 7: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

7Compiler Construction, April 2005Age-Oriented GC

Choosing a Collector

Reference counting Best when most objects alive, and low “activity”.

Tracing: Best when most objects dead.

When are objects typically dead?

The generational hypothesis: most objects die young.

Page 8: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

8Compiler Construction, April 2005Age-Oriented GC

Generational Garbage Collection [Lieberman-Hewitt 83, Ungar 84]:

• Segregate objects by age into generations.• Objects allocated in the young generation,

promoted into the old generation if they survive long enough.

• Frequently collect the young generation• Collect full heap when needed.

Most pauses are short (for young generation GC).

Collection effort concentrated where garbage is.

Old

Young

Page 9: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

9Compiler Construction, April 2005Age-Oriented GC

Note Interesting Characteristics• Young generation: most objects die & high

activity. Tracing is best when most objects die.

• Old generation: most objects alive and slow activity.Reference counting is best.

• Conclusion: use RC for old & tracing for young.

• Already done by [Azatchi-Petrank CC’03][Blackburn-Mckinley OOPSLA’03]

Page 10: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

10Compiler Construction, April 2005Age-Oriented GC

Size of Young Generation

• small young generation (mostly) short pauses large young generation high efficiency

• Appel’s collector uses a large young generation and obtains highest efficiency.

Page 11: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

11Compiler Construction, April 2005Age-Oriented GC

Observation 1

large young generation high efficiency but long pauses

concurrent collector short pauses

Observation 1: we want the largest possible young generation.

Page 12: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

12Compiler Construction, April 2005Age-Oriented GC

Observation 2

Delaying collection of the old generation is fundamentally tracing-oriented.

Complexity of tracing is fixed: delay it. Complexity of RC accumulates (update counters, traverse the unreachable) no use in delaying it.

Page 13: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

13Compiler Construction, April 2005Age-Oriented GC

Observation 2

Delaying collection of the old generation is fundamentally tracing-oriented.

We use RC for old generation

Observation 2: No use in delaying collection of old objects.

Page 14: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

14Compiler Construction, April 2005Age-Oriented GC

Conclusion

Observation 1: we want the largest possible young generation.

Observation 2: no use in delaying collection of old objects.

Conclusion (age-oriented collection): collect entire heap with each collection

Page 15: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

15Compiler Construction, April 2005Age-Oriented GC

Age-Oriented vs. Generational

Age-Oriented

• Always collect entire heap

• Collect each generation differently

Generational

• Frequently collect young generation

• Collect young generation and full heap differently

Page 16: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

16Compiler Construction, April 2005Age-Oriented GC

Generational vs. Age-Oriented

Old

Young

Old

Young

Old

Young Young

Young

Age-Oriented:

Old

Young

Old

Young

Old

Young

Old

Young

Old

Young

Old

Young

Old

Young

Standard:

time

Page 17: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

17Compiler Construction, April 2005Age-Oriented GC

Age-Oriented Properties

Advantages:• Largest possible young generation. • No frequent young collections.• Each generation is treated according to its

characteristics (like generational collectors). • Potentially easier to obtain inter-generat’l ptr’s.

Young Generation

Old GenerationAB

Page 18: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

18Compiler Construction, April 2005Age-Oriented GC

Age-Oriented Properties

Advantages:• Largest possible young generation. • No frequent young collections.• Each generation is treated according to its

characteristics (like generational collectors). • Potentially easier to obtain inter-generat’l ptr’s.

Disadvantages:• Longer pauses (if we don’t use concurrent GC.) • May have a throughput penalty if tracing the old

generation (not an issue for RC).

Page 19: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

19Compiler Construction, April 2005Age-Oriented GC

Age-Oriented Collection

Age-Oriented

• Always collect entire heap

• Collect each generation differently

A general framework: instantiated by picking collectors for the old and young generations and combining them.

Page 20: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

20Compiler Construction, April 2005Age-Oriented GC

Our Instantiation

• Building blocks: the sliding views collectors [Levanoni-Petrank 01, Azatchi et al. 03]– Old generation: concurrent RC.– Young generation: concurrent tracing.

• Technicalities: – Joining the two collectors– Inter-generational pointers

Page 21: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

21Compiler Construction, April 2005Age-Oriented GC

Implementation

• Implementation for Java on the Jikes Research JVM

• Compared collectors: – RC with no generation.– Generational: tracing for young & RC for full.

• Benchmarks:– SPECjbb2000: simulates business-like trans’s. – SPECjvm98: client benchmarks suite.

• Platform: a 4-Way Netfinity.

Page 22: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

22Compiler Construction, April 2005Age-Oriented GC

Pause Times vs. STW

0

100

200

300

400

500

600

700

age-oriented 1 1.7 1.1 2.1 1.4 1.2 1.1 1.4 1.9

Jikes parallel 195 261 188 643 225 376 322 417 511

compress

jess db javac mtrt jack jbb-1 jbb-2 jbb-3

Page 23: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

23Compiler Construction, April 2005Age-Oriented GC

SPECjbb Throughput (Age-Oriented vs. RC)

SPECjbb Throughput: AO/RC

0.7

0.8

0.9

1

1.1

1.2

1.3

1.4

1.5

256 320 384 448 512 576 640 704

Heap Size

jbb1

jbb2

jbb3

jbb4

jbb5

jbb6

jbb7

jbb8

Page 24: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

24Compiler Construction, April 2005Age-Oriented GC

SPECjbb Throughput (Generational vs. RC)

SPECjbb Throughput: Generational /RC

0.7

0.8

0.9

1

1.1

1.2

1.3

256 320 384 448 512 576 640 704

Heap Size

jbb1

jbb2

jbb3

jbb4

jbb5

jbb6

jbb7

jbb8

Page 25: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

25Compiler Construction, April 2005Age-Oriented GC

SPECjvm98 Throughput (Age-Oriented vs. RC)

jvm98 - ao/lp

0.7

0.8

0.9

1

1.1

1.2

1.3

24 32 40 48 56 64 72 80 88 96

heap size

rati

o

jess

db

javac

mtrt

jack

Page 26: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

26Compiler Construction, April 2005Age-Oriented GC

Throughput versus Parallel Tracing

age-oriented / jikes parallel m&s

0.8

0.85

0.9

0.95

1

1.05

256 320 384 448 512 576 640 704

jbb1

jbb2

jbb3

jbb4

jbb5

jbb6

jbb7

jbb8

Page 27: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

27Compiler Construction, April 2005Age-Oriented GC

Related Work

• [Azatzhi-Petrank CC’03] Concurrent generations with RC for full and tracing for young. (Very short pauses.)

• [Blackburn-Mckinley OOPSLA’03] Generations with RC for old and tracing for young. Non concurrent but controlled pauses.

• [Paz et al. CC’05] (coming soon…)Cycle Collection --- better do it only for old objects, via age-oriented collection.

• RC: some recent breakthrough, still work needed to get RC “right” for modern platforms.

Page 28: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

28Compiler Construction, April 2005Age-Oriented GC

Concurrent & Generational GC

• A general question for concurrent collectors: – Concurrent collectors already have short pauses, should we

also use generations ?

• First experiment [Domani et al. PLDI’00]:– Beneficial, but unsteady improvements (-8% -- 25%). – Base was production JVM with mark & sweep.

• Second experiment: [Azatchi-Petrank, CC’03]:– Beneficial, 10-20% improvement. – Base was Jikes RVM with RC.

• Third try: Mostly Concurrent [ISMM’00, PLDI’02, OOPSLA’03]: – SUN: yes, no measurements.– IBM: no, (and no measurements).

• Fourth experiment: this work…

Page 29: Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland

29Compiler Construction, April 2005Age-Oriented GC

Conclusion • The Age-Oriented collector improves efficiency

of generational collectors– Especially with RC on old.– Especially with concurrent collectors.

• It is a framework, we tried an instantiation with:– Concurrent RC for old, concurrent tracing for young.

• The age-oriented collector was non-obtrusive (due to concurrency) and efficient (due to age-oriented) collector.

• An excellent way to employ RC.