Top Banner
Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. McKinley Microsoft Research
27

Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

Dec 31, 2015

Download

Documents

Edgar Dennis
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

Fast Conservative Garbage Collection

Rifat ShahriyarStephen M. BlackburnAustralian National University

Kathryn S. McKinleyMicrosoft Research

Page 2: Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

GC is Ubiquitous

• GC implementations Exact Conservative

• High performance systems use exact GC• Conservative GC is popular

2

roots

roots

heap

heap

roots

heap

conservativeexact

Page 3: Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

3

BDW

Our g

oal0.0

0.2

0.4

0.6

0.8

1.0

1.2

1.4

1.6

1.16

1.00

Tim

e /

RC

Im

mix

Performance

16% slowdown a show-stopper in many situations

Page 4: Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

4

Root Conservative GC

roots

heap

int

Page 5: Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

5

Ambiguous References

• May be pointers– Retain referents, transitively– Excess retention

• May be values– Cannot change values – Pin referents

• May corrupt heap– Validate before updating per-object metadata

Page 6: Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

6

Why Conservative GC

Advantages✔ Disentangles GC from compiler✔ Avoids challenging engineering of stack maps✔ Enables more compiler optimizations

Disadvantages✘ Must handle ambiguous references✘ Performance

Our goal is high performance conservative GC for managed languages

Page 7: Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

7

High Performance Exact Garbage Collectors

Page 8: Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

8

Immix [Blackburn & McKinley 2008]

0

• Contiguous allocation into regions– 256B lines and 32KB blocks– Objects span lines but not blocks

• Simple mark phase– Mark objects and containing regions

• Free unmarked regions ✔Recycled allocation and defragmentation

block

line

recyclable linesobject mark line mark

linelineline

Page 9: Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

9

RC Immix [Shahriyar et al. 2013]

• Combines RC and Immix✔Object local collection✔Great mutator locality

• Exploit Immix’s opportunistic copy– New objects can be copied by first GC– Old objects can be copied by backup GC✔Copying with RC to eliminate fragmentation

0 01 3 1 2

11 3 2 1 2200

Page 10: Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

10

Conservative Garbage Collectors

Page 11: Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

11

Non-Moving Free list

• Designed for fully conservative settings • Problems

✘Poor performance✘Overly conservative design for many settings

roots

heap

Page 12: Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

12

Mostly-Copying Semi Space

• a.k.a. Bartlett-style, with many variants• Problems

✘Semi-space suffers from huge collection cost✘Poor performance

roots

heap

Page 13: Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

All exact 217

Unique exact 98 0.45x

All cons. 461 2.12x

Unique cons. 157 1.6x

13

44 KB 0.02%

Actual pinned 14 KB 0.05%

MCC pinned 462 KB 2.1%

MCC false pinned 282 KB

Immix pinned 36 KB 0.2%

Excess retention

Pinning

Roots

Cost of Conservatismaveraged over 20 Java benchmarks

The direct cost of conservatism is very low

Page 14: Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

14

Heap Organization is Key

SSM

CC MS

BDW

RC Imm

ix

Our g

oal0.0

0.2

0.4

0.6

0.8

1.0

1.2

1.4

1.6

1.33 1.45

1.11

1.12

0.97

Tim

e /

Gen

Im

mix

Page 15: Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

15

Outline

✔Real source of performance overhead is not conservatism but heap organization

• Design and implementation of– Conservative Immix collectors– Conservative reference counting

• Evaluation

Page 16: Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

16

Design

Page 17: Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

17

Filtering

• Object map filters ambiguous references– Bitmap records locations of all live objects – Allocator sets bit encoding object start address– Collector clears bit for dead objects

roots

heap

Page 18: Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

18

Cost of Filtering

Heap organization trumps object map overhead (2.7%)

Page 19: Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

19

Pinning

• Immix line pinning, opportunistic copying– Pin referents of ambiguous references– Logically pinned lines cannot be reused– Move other objects as space permits

roots

heap

Page 20: Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

20

Results

Page 21: Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

21

Methodology

• 20 benchmarks– DaCapo, SPECjvm98 and pjbb2005

• 20 invocations for each benchmark• Jikes RVM and MMTk– All garbage collectors are parallel

• Intel Core i7 4770, 8GB• Ubuntu 12.04.3 LTS

Page 22: Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

22

Cost of Conservatismnormalized to exact

Low performance penalty for conservative collectors

SSM

CC MSBDW RC RC

Imm

ix

Imm

ix

Sticky

Imm

ix

Sticky

Imm

ix

RC Imm

ix

RC Imm

ix0.8

0.9

1.0

1.1

1.2

9.3%

1% 2.3% 2.7% 2.6% 2.7%

Tim

e /

Exa

ct

cons

cons

cons

cons

Page 23: Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

23

cons

MCC

BDW

RC Imm

ix

RC Imm

ix0.0

0.2

0.4

0.6

0.8

1.0

1.2

1.4

1.6

1.45

1.12

0.97

0.99

Tim

e /

Gen

Im

mix

Total Time

RC Immixcons matches Gen Immix and RC Immix

Page 24: Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

24

Total Time v Heap Size

1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 60.98

1.08

1.18

1.28

1.38

1.48

Gen Immix RC Immix RC Immix BDW MCC

Heap Size / Minimum Heap

Tim

e /

Bes

t

RC Immixcons matches Gen Immix and RC Immix

cons

Page 25: Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

25

Wider Applicability

Page 26: Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

26

Conservatism and PinningAmenability of existing systems to conservative RC Immix

• Quantify ambiguous references in target applications– Conservative RC Immix tolerates 8x pinning

increase with only 3.4% overhead

• Modify heap organization to use lines and blocks

• Implement full-heap tracing Immix collector (5% improvement)– Depends on code quality

Page 27: Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.

27

Summary

• Conservative GC– Dominated by BDW and MCC– Significant overheads– Heap org. key to performance

• New designs– Low overhead object map– Immix line based pinning

• Conservative RC Immix– Matches fastest production

Questions?Available at: https://jira.codehaus.org/browse/RVM-1085