SlideShare a Scribd company logo
Rethinking
Garbage Collection
Rifat Shahriyar
Who Am I?
•  Asst. Prof., Dept. of CSE, BUET
•  PhD from Australian National University
(ANU)
•  Dissertation title
–  High Performance Reference Counting and
Conservative Garbage Collection
•  Supervised by
–  Steve Blackburn (ANU)
–  Kathryn McKinley (MSR)
2
Java Virtual Machine
3
The Birth of GC (1960)
4
Today Garbage collection is
ubiquitous
•  GC algorithms
–  Tracing and Reference counting
•  GC implementations
–  Exact and Conservative
✔ Tracing and Exact in all highly engineered,
high performance systems
✘ Reference counting and conservative only
in non-performance critical settings
5
GC Fundamentals
Algorithmic Components
Allocation Reclamation
6
Identification
Bump Allocation
Free List
`
Tracing
(implicit)
Reference Counting
(explicit)
Sweep-to-Free
Compact
Evacuate
3 1
Mark-Compact [Styger 1967]
Bump allocation + trace + compact
GC Fundamentals
Canonical Garbage Collectors
7
`
Sweep-to-Free
Compact
Evacuate
Mark-Sweep [McCarthy 1960]
Free-list + trace + sweep-to-free
Semi-Space [Cheney 1970]
Bump allocation + trace + evacuate
Generational[Ungar 1984]
•  Most objects die young
8
Nursery space
Mature space
Immix [Blackburn and McKinley 2008]
•  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
9
block
line
recyclable linesobject mark line mark
Down for the Count?
Getting Reference Counting
Back in the Ring
ISMM’12
10
Tracing [McCarthy1960]
11
A
D
B
E
C
F
✗ ✗
Roots
Reference Counting [Collins 1960]
12
1
1
1
1 2
1
2
0
1
✗
Roots
Why Reference Counting?
Advantages
✔ Immediacy
✔ Object local
✔ Basic RC is easy
Disadvantages
✘  Cycles
✘  Performance
13
Problem
✔ One of the two fundamental GC algorithms
✔ Many advantages
✘ Neglected by performance-conscious VMs
So how much slower is it?
Can we get RC back in the ring?
14
30%
Optimizing RC
•  Limited bit count
–  Use just few bits, fix o/f with backup tracing
•  Elision of new object counts
–  Only do RC work if object survives the first GC
•  Born as dead
–  Avoid free-list work for short lived objects
15
16
New RC ≈ MS
Optimized RC vs. MS
-20%
0%
20%
40%
60%
80%
compress
jess
db
javac
mtrt
jack
avrora
bloat
eclipse
fop
hsqldb
luindex
pmd
sunflow
xalan
pjbb2005
geomean
faster←Time→slower
Old RC New RC
Summary
•  Old RC
–  30% slower than MS
–  40% slower than production
•  New RC
–  Limited bit count
–  Optimization for new objects
•  Performance
–  Matches MS
–  Still 10% slower than production
17
40%
10%
TotalTimevProduction
< 2012 2012
Taking Off the Gloves with
Reference Counting Immix
OOPSLA’13
18
Why So Slow?
10% 10%
-3%
TimevProduction
19
Total Mutator
GC
Looking a Little Deeper…
10% 9%
32%
7%
4%
28%
-2% -3% -2%-3% -3%
1%
MutatorvProduction
RC MS SS Immix
20
Time Instructions
Retired
L1 D
Cache Misses
Looking a Little Deeper…
10% 9%
32%
7%
4%
28%
-2% -3% -2%-3% -3%
1%
MutatorvProduction
RC MS SS Immix
21
Time Instructions
Retired
L1 D
Cache Misses
Free List
Bump Pointer
Goal & Challenge
•  Goal
–  Object-local collection
–  Excellent mutator locality
–  Copying to eliminate fragmentation
•  Immix provides opportunistic copying
✔ Same mutator locality as contiguous allocator
•  However, RC is inherently local
–  References to an object generally unknown
–  but copying must redirect all references
22
RC Immix
✔ Combines RC and Immix
✔ Line/block reclamation
✔ Line live object count with object reference count
✔ Exploit Immix’s opportunistic copy
✔ Observe new objects can be copied by first GC
✔ Observe old objects can be copied by backup GC
23
Total time
3% faster then Gen Immix, +6% worst case, -21% best case
24
-30%
-20%
-10%
0%
10%
20%
30%
40%
compress
jess
db
javac
mtrt
jack
avrora
bloat
eclipse
fop
hsqldb
jython
luindex
lusearchfix
pmd
sunflow
xalan
pjbb2005
geomean
faster←Time→slower
RC RC Immix
Summary
•  RC Immix
–  Object-local collection
–  Excellent mutator locality
–  Copying with RC
•  Great performance
–  Outperforms fastest production
•  Transforms RC
TotalTimevProduction
10%
RC 2013
RC Immix
-3%
25
Questions?

More Related Content

What's hot (8)

PDF
Coupling ecophysiological data with models_Whitley
TERN Australia
 
PPTX
1704.03414_cvrg&hustcv
敏 杜
 
PDF
IBM Cloud Community Summit 2018:「Kubernetes in Muiticloudで戦うCloud Native時代」 b...
capsmalt
 
PDF
スマホでDeepLearning実践入門(α版)
cocodrips
 
PDF
CourboSpark
Christophe Salperwyck
 
ZIP
Quick Wikipedia Mining using Elastic Map Reduce
ohkura
 
PDF
Ronan Kerr: Exploring the Debris Disk Around Beta Pictoris
JeremyHeyl
 
PPTX
How does one go from binary data to HDF files efficiently?
The HDF-EOS Tools and Information Center
 
Coupling ecophysiological data with models_Whitley
TERN Australia
 
1704.03414_cvrg&hustcv
敏 杜
 
IBM Cloud Community Summit 2018:「Kubernetes in Muiticloudで戦うCloud Native時代」 b...
capsmalt
 
スマホでDeepLearning実践入門(α版)
cocodrips
 
Quick Wikipedia Mining using Elastic Map Reduce
ohkura
 
Ronan Kerr: Exploring the Debris Disk Around Beta Pictoris
JeremyHeyl
 
How does one go from binary data to HDF files efficiently?
The HDF-EOS Tools and Information Center
 

Similar to Rethinking garbage collection (20)

ODP
Garbage Collection in Hotspot JVM
jaganmohanreddyk
 
ODP
Gc algorithms
Michał Warecki
 
PPTX
Garbage collection
Anand Srinivasan
 
PPTX
G1 Garbage Collector - Big Heaps and Low Pauses?
C2B2 Consulting
 
PDF
How long can you afford to Stop The World?
Java Usergroup Berlin-Brandenburg
 
PDF
Garbage Collection
Eelco Visser
 
PDF
Low latency Java apps
Simon Ritter
 
PDF
Six Myths and Paradoxes of Garbage Collection
Holly Cummins
 
PPTX
Memory Management in the Java Virtual Machine(Garbage collection)
Prashanth Kumar
 
PPT
Gc in android
Vikas Balikai
 
PDF
Demystifying Garbage Collection in Java
Igor Braga
 
PDF
Understanding Java Garbage Collection - And What You Can Do About It
Azul Systems Inc.
 
PDF
Java at Scale, Dallas JUG, October 2013
Azul Systems Inc.
 
PDF
A New Age of JVM Garbage Collectors (Clojure Conj 2019)
Alexander Yakushev
 
PDF
Introduction to Garbage Collection
Artur Mkrtchyan
 
PDF
Advancements ingc andc4overview_linkedin_oct2017
Azul Systems Inc.
 
PPT
Chapter 7 Run Time Environment
Radhakrishnan Chinnusamy
 
PDF
Sun jdk 1.6内存管理 -实现篇 -毕玄
锐 张
 
PPTX
Garbage collection algorithms
achinth
 
PPTX
A History of Modern Garbage Collection Techniques
Sasha Goldshtein
 
Garbage Collection in Hotspot JVM
jaganmohanreddyk
 
Gc algorithms
Michał Warecki
 
Garbage collection
Anand Srinivasan
 
G1 Garbage Collector - Big Heaps and Low Pauses?
C2B2 Consulting
 
How long can you afford to Stop The World?
Java Usergroup Berlin-Brandenburg
 
Garbage Collection
Eelco Visser
 
Low latency Java apps
Simon Ritter
 
Six Myths and Paradoxes of Garbage Collection
Holly Cummins
 
Memory Management in the Java Virtual Machine(Garbage collection)
Prashanth Kumar
 
Gc in android
Vikas Balikai
 
Demystifying Garbage Collection in Java
Igor Braga
 
Understanding Java Garbage Collection - And What You Can Do About It
Azul Systems Inc.
 
Java at Scale, Dallas JUG, October 2013
Azul Systems Inc.
 
A New Age of JVM Garbage Collectors (Clojure Conj 2019)
Alexander Yakushev
 
Introduction to Garbage Collection
Artur Mkrtchyan
 
Advancements ingc andc4overview_linkedin_oct2017
Azul Systems Inc.
 
Chapter 7 Run Time Environment
Radhakrishnan Chinnusamy
 
Sun jdk 1.6内存管理 -实现篇 -毕玄
锐 张
 
Garbage collection algorithms
achinth
 
A History of Modern Garbage Collection Techniques
Sasha Goldshtein
 
Ad

Recently uploaded (20)

PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PPTX
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PDF
Market Insight : ETH Dominance Returns
CIFDAQ
 
PDF
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PPTX
Simple and concise overview about Quantum computing..pptx
mughal641
 
PDF
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PPTX
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PDF
Build with AI and GDG Cloud Bydgoszcz- ADK .pdf
jaroslawgajewski1
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PDF
Per Axbom: The spectacular lies of maps
Nexer Digital
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
Market Insight : ETH Dominance Returns
CIFDAQ
 
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Simple and concise overview about Quantum computing..pptx
mughal641
 
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
Build with AI and GDG Cloud Bydgoszcz- ADK .pdf
jaroslawgajewski1
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
Per Axbom: The spectacular lies of maps
Nexer Digital
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
Ad

Rethinking garbage collection

  • 2. Who Am I? •  Asst. Prof., Dept. of CSE, BUET •  PhD from Australian National University (ANU) •  Dissertation title –  High Performance Reference Counting and Conservative Garbage Collection •  Supervised by –  Steve Blackburn (ANU) –  Kathryn McKinley (MSR) 2
  • 4. The Birth of GC (1960) 4
  • 5. Today Garbage collection is ubiquitous •  GC algorithms –  Tracing and Reference counting •  GC implementations –  Exact and Conservative ✔ Tracing and Exact in all highly engineered, high performance systems ✘ Reference counting and conservative only in non-performance critical settings 5
  • 6. GC Fundamentals Algorithmic Components Allocation Reclamation 6 Identification Bump Allocation Free List ` Tracing (implicit) Reference Counting (explicit) Sweep-to-Free Compact Evacuate 3 1
  • 7. Mark-Compact [Styger 1967] Bump allocation + trace + compact GC Fundamentals Canonical Garbage Collectors 7 ` Sweep-to-Free Compact Evacuate Mark-Sweep [McCarthy 1960] Free-list + trace + sweep-to-free Semi-Space [Cheney 1970] Bump allocation + trace + evacuate
  • 8. Generational[Ungar 1984] •  Most objects die young 8 Nursery space Mature space
  • 9. Immix [Blackburn and McKinley 2008] •  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 9 block line recyclable linesobject mark line mark
  • 10. Down for the Count? Getting Reference Counting Back in the Ring ISMM’12 10
  • 12. Reference Counting [Collins 1960] 12 1 1 1 1 2 1 2 0 1 ✗ Roots
  • 13. Why Reference Counting? Advantages ✔ Immediacy ✔ Object local ✔ Basic RC is easy Disadvantages ✘  Cycles ✘  Performance 13
  • 14. Problem ✔ One of the two fundamental GC algorithms ✔ Many advantages ✘ Neglected by performance-conscious VMs So how much slower is it? Can we get RC back in the ring? 14 30%
  • 15. Optimizing RC •  Limited bit count –  Use just few bits, fix o/f with backup tracing •  Elision of new object counts –  Only do RC work if object survives the first GC •  Born as dead –  Avoid free-list work for short lived objects 15
  • 16. 16 New RC ≈ MS Optimized RC vs. MS -20% 0% 20% 40% 60% 80% compress jess db javac mtrt jack avrora bloat eclipse fop hsqldb luindex pmd sunflow xalan pjbb2005 geomean faster←Time→slower Old RC New RC
  • 17. Summary •  Old RC –  30% slower than MS –  40% slower than production •  New RC –  Limited bit count –  Optimization for new objects •  Performance –  Matches MS –  Still 10% slower than production 17 40% 10% TotalTimevProduction < 2012 2012
  • 18. Taking Off the Gloves with Reference Counting Immix OOPSLA’13 18
  • 19. Why So Slow? 10% 10% -3% TimevProduction 19 Total Mutator GC
  • 20. Looking a Little Deeper… 10% 9% 32% 7% 4% 28% -2% -3% -2%-3% -3% 1% MutatorvProduction RC MS SS Immix 20 Time Instructions Retired L1 D Cache Misses
  • 21. Looking a Little Deeper… 10% 9% 32% 7% 4% 28% -2% -3% -2%-3% -3% 1% MutatorvProduction RC MS SS Immix 21 Time Instructions Retired L1 D Cache Misses Free List Bump Pointer
  • 22. Goal & Challenge •  Goal –  Object-local collection –  Excellent mutator locality –  Copying to eliminate fragmentation •  Immix provides opportunistic copying ✔ Same mutator locality as contiguous allocator •  However, RC is inherently local –  References to an object generally unknown –  but copying must redirect all references 22
  • 23. RC Immix ✔ Combines RC and Immix ✔ Line/block reclamation ✔ Line live object count with object reference count ✔ Exploit Immix’s opportunistic copy ✔ Observe new objects can be copied by first GC ✔ Observe old objects can be copied by backup GC 23
  • 24. Total time 3% faster then Gen Immix, +6% worst case, -21% best case 24 -30% -20% -10% 0% 10% 20% 30% 40% compress jess db javac mtrt jack avrora bloat eclipse fop hsqldb jython luindex lusearchfix pmd sunflow xalan pjbb2005 geomean faster←Time→slower RC RC Immix
  • 25. Summary •  RC Immix –  Object-local collection –  Excellent mutator locality –  Copying with RC •  Great performance –  Outperforms fastest production •  Transforms RC TotalTimevProduction 10% RC 2013 RC Immix -3% 25 Questions?