Reference Object Processing in On-The-Fly Garbage Collection

Similar documents
Shenandoah: An ultra-low pause time garbage collector for OpenJDK. Christine Flood Roman Kennke Principal Software Engineers Red Hat

Garbage Collection Algorithms. Ganesh Bikshandi

Cycle Tracing. Presented by: Siddharth Tiwary

Garbage Collection. Hwansoo Han

G1 Garbage Collector Details and Tuning. Simone Bordet

Shenandoah: An ultra-low pause time garbage collector for OpenJDK. Christine Flood Principal Software Engineer Red Hat

Shenandoah An ultra-low pause time Garbage Collector for OpenJDK. Christine H. Flood Roman Kennke

Verifying a Concurrent Garbage Collector using a Rely-Guarantee Methodology

Write Barrier Elision for Concurrent Garbage Collectors

Replicating Real-Time Garbage Collector

The C4 Collector. Or: the Application memory wall will remain until compaction is solved. Gil Tene Balaji Iyengar Michael Wolf

Myths and Realities: The Performance Impact of Garbage Collection

Towards Parallel, Scalable VM Services

Implementation Garbage Collection

Hard Real-Time Garbage Collection in Java Virtual Machines

Performance of Non-Moving Garbage Collectors. Hans-J. Boehm HP Labs

Concurrent Garbage Collection

Concurrent Compaction using a Field Pinning Protocol

Incremental Parallel Garbage Collection

Pause-Less GC for Improving Java Responsiveness. Charlie Gracie IBM Senior Software charliegracie

Towards Garbage Collection Modeling

Contents. Created by: Raúl Castillo

Lecture 15 Garbage Collection

The Z Garbage Collector Low Latency GC for OpenJDK

Shenandoah GC...and how it looks like in September Aleksey

Tick: Concurrent GC in Apache Harmony

Toward Efficient Strong Memory Model Support for the Java Platform via Hybrid Synchronization

Garbage Collection (2) Advanced Operating Systems Lecture 9

A Trace-based Java JIT Compiler Retrofitted from a Method-based Compiler

Kotlin/Native concurrency model. nikolay

Garbage-First Garbage Collection by David Detlefs, Christine Flood, Steve Heller & Tony Printezis. Presented by Edward Raff

The Z Garbage Collector Scalable Low-Latency GC in JDK 11

Shenandoah: Theory and Practice. Christine Flood Roman Kennke Principal Software Engineers Red Hat

Managed runtimes & garbage collection. CSE 6341 Some slides by Kathryn McKinley

Lecture Notes on Advanced Garbage Collection

Managed runtimes & garbage collection

Acknowledgements These slides are based on Kathryn McKinley s slides on garbage collection as well as E Christopher Lewis s slides

Dynamic Vertical Memory Scalability for OpenJDK Cloud Applications

Hierarchical Real-time Garbage Collection

Boosting the Priority of Garbage: Scheduling Collection on Heterogeneous Multicore Processors

Continuous Object Access Profiling and Optimizations to Overcome the Memory Wall and Bloat

Garbage Collection Techniques

Runtime. The optimized program is ready to run What sorts of facilities are available at runtime

Boosting the Priority of Garbage: Scheduling Collection on Heterogeneous Multicore Processors

Adaptive Multi-Level Compilation in a Trace-based Java JIT Compiler

Garbage Collection. CS 351: Systems Programming Michael Saelee

Multicore OCaml. Stephen Dolan Leo White Anil Madhavapeddy. University of Cambridge. OCaml 2014 September 5, Multicore OCaml

Mark-Sweep and Mark-Compact GC

A Fully Concurrent Garbage Collector for Functional Programs on Multicore Processors

Garbage Collection (1)

Exploiting the Behavior of Generational Garbage Collector

An On-the-Fly Mark and Sweep Garbage Collector Based on Sliding Views

An Examination of Reference Counter Costs and Implementation Approaches

CS577 Modern Language Processors. Spring 2018 Lecture Garbage Collection

CS 4120 Lecture 37 Memory Management 28 November 2011 Lecturer: Andrew Myers

The Garbage-First Garbage Collector

Go GC: Prioritizing Low Latency and Simplicity

Identifying the Sources of Cache Misses in Java Programs Without Relying on Hardware Counters. Hiroshi Inoue and Toshio Nakatani IBM Research - Tokyo

Mostly Concurrent Garbage Collection Revisited

Real-Time Garbage Collection Panel JTRES 2007

Parallel Garbage Collection

Algorithms for Dynamic Memory Management (236780) Lecture 4. Lecturer: Erez Petrank

Run-Time Environments/Garbage Collection

Fundamentals of GC Tuning. Charlie Hunt JVM & Performance Junkie

Garbage Collection. Vyacheslav Egorov

Finally! Real Java for low latency and low jitter

Scheduling Hard Real-time Garbage Collection

Reducing Pause Time of Conservative Collectors

I J C S I E International Science Press

Java Performance Tuning

Kodewerk. Java Performance Services. The War on Latency. Reducing Dead Time Kirk Pepperdine Principle Kodewerk Ltd.

Glacier: A Garbage Collection Simulation System

Lecture 15 Advanced Garbage Collection

Freeing memory is a pain. Need to decide on a protocol (who frees what?) Pollutes interfaces Errors hard to track down

JVM Performance Tuning with respect to Garbage Collection(GC) policies for WebSphere Application Server V6.1 - Part 1

The Application Memory Wall

Quantifying the Performance of Garbage Collection vs. Explicit Memory Management

How s the Parallel Computing Revolution Going? Towards Parallel, Scalable VM Services

Limits of Parallel Marking Garbage Collection....how parallel can a GC become?

TECHNOLOGY WHITE PAPER. Azul Pauseless Garbage Collection. Providing continuous, pauseless operation for Java applications

Eventrons: A Safe Programming Construct for High-Frequency Hard Real-Time Applications

Efficient Context Sensitivity for Dynamic Analyses via Calling Context Uptrees and Customized Memory Management

Understanding the Connectivity of Heap Objects Technical Report: CU-CS

Azul Pauseless Garbage Collection

Enabling Java in Latency Sensitive Environments

A Hardware Accelerator for Tracing Garbage Collection

Sustainable Memory Use Allocation & (Implicit) Deallocation (mostly in Java)

Reference Counting. Reference counting: a way to know whether a record has other users

Compilers. 8. Run-time Support. Laszlo Böszörmenyi Compilers Run-time - 1

One-Slide Summary. Lecture Outine. Automatic Memory Management #1. Why Automatic Memory Management? Garbage Collection.

A STUDY OF THREAD-LOCAL GARBAGE COLLECTION FOR MULTI-CORE SYSTEMS

Evaluating and improving remembered sets in the HotSpot G1 garbage collector

Garbage Collection for General Graphs

MEMORY MANAGEMENT HEAP, STACK AND GARBAGE COLLECTION

Java without the Coffee Breaks: A Nonintrusive Multiprocessor Garbage Collector

MC 2 : High-Performance Garbage Collection for Memory-Constrained Environments

Scheduling Real-time Garbage Collection on Uni-Processors

An On-the-Fly Reference-Counting Garbage Collector for Java

Opera&ng Systems CMPSCI 377 Garbage Collec&on. Emery Berger and Mark Corner University of Massachuse9s Amherst

A NEW PLATFORM FOR A NEW ERA. Copyright 2014 Pivotal. All rights reserved.

Transcription:

Reference Object Processing in On-The-Fly Garbage Collection Tomoharu Ugawa, Kochi University of Technology Richard Jones, Carl Ritson, University of Kent

Weak Pointers Weak pointers are a mechanism to allow mutators to communicate with GC java.lang.ref.reference Specification requires us to process weak references atomically from the view point of mutators Fully concurrent (on-the-fly) GC never stops all mutators

stronger Java reference types Strong - usual references. Soft - used for caches that the GC can reclaim. Weak - used for canonicalize mappings (e.g., interned strings) that do not prevent GC from reclaiming their keys or values. Phantom - used for scheduling pre-mortem cleanup actions more flexibility than finalisers. weaker

stronger weaker Java reference types Strong - usual references. Soft - used for caches that the GC can reclaim. reduce to strong/weak references Weak - used for canonicalize mapping (e.g., interned strings) that do not prevent GC from reclaiming their keys or values. Phantom - used for scheduling pre-mortem cleanup actions more flexibility than finalisers. no interaction with mutators

Reachability strongly reachable root Strongly - can be reached without traversing any other references. Weakly - not strongly reachable but can be reached by traversing weak references. No formal specification Specification is written in English. There are errors in implementations We formalised the specification strong reference weak reference

GC actions strongly reachable root The GC finds all strongly reachable objects and reclaims others. The GC clears references whose referents are weakly reachable. Weak reference to Strongly - to be retained Weak reference to Weakly - to be cleared

Reference.get() strongly reachable root Reference object Normal object Reference.get() - returns a strong reference to its target or null if the GC has cleared. get() may make some objects that were weakly reachable strongly reachable.

Reference.get() strongly reachable root Reference object Normal object Reference.get() - returns a strong reference to its target or null if the GC has cleared. get() get() may make some objects that were weakly reachable strongly reachable.

A O Race B

A O Race B Collector clears weak reference A

A O Race get() B Collector clears weak reference A

Race get() A O B Collector clears weak reference A Mutator makes O strongly reachable by creating a strong reference to the upstream

from the OpenJDK mailing list I've been tuning a Java 7u5, Solaris 0, T4 system with 24G heap. My customer is not very happy with the remark pauses of up to 2 seconds. Thomas Viessmann It looks like the application is using a lot of Reference objects. The time spent in remark is dominated by reference processing. Bengt Rutisson

Solutions Stop the world - Pauseless GC [Click et al., 2005], Staccato [McCloskey et al., 2008] Stop all mutators and process references Lock - On-the-fly GC [Domani et al., 2000] Block any mutator that calls get() On-the-fly - Metronome-TS [Auerbach et al., 2008] Implementation technique is not public

Global GC State GC and mutator race in TRACING GC want to finish tracing and then start clearing Mutator force GC to do more work GC traces strongly reachable objects

TRACING State GC traverses strong references to colour strongly reachable objects black Write barrier insertion barrier [Dijkstra] deletion barrier (a.k.a. snapshot) [Yuasa] Read barrier for Reference.get() REPEAT NORMAL TRACING CLEARING

TRACING State GC traverses strong references to colour strongly reachable objects black Write barrier insertion barrier [Dijkstra] deletion barrier (a.k.a. snapshot) [Yuasa] Read barrier for Reference.get() REPEAT NORMAL TRACING CLEARING

Insertion Barrier INVARIANT: Root is grey (allows root to refer to white objects) GC repeat tracing until it finds root black REPEAT Reference.get() changes the state to REPEAT to notify the GC that the root may not be NORMAL TRACING CLEARING black root get()

Deletion Barrier INVARIANT: Root is black --- root is never rescanned Reference.get() colours target grey REPEAT Reference.get() changes the state to REPEAT to notify the GC that the root may not be black NORMAL TRACING CLEARING root get()

CLEARING Once GC enters CLEARING state no more objects become strongly reachable Reference.get() returns null if its target is white GC clears weak references whose targets are white REPEAT NORMAL TRACING CLEARING get() returns null

Evaluation Jikes RVM Sapphire on-the-fly copying collector Trigger GC immediately after the previous GC completes Configuration GB heap Core i7-4770 (4-core, 3.4 GHz) 2 collector threads

Pause Time distribution Stop-the-world GC, or Block mutator.get() with lock 00 0 STW lock ins lock del 00 0 STW lock ins lock del 00 0 STW lock ins lock del Frequency (%) 0. 0. 0. 0 6 2 8 24 30 0 6 2 8 24 30 0 6 2 8 24 30 00 0 3ms buckets jython2006 STW lock ins lock del 00 0 Note logarithmic scale avrora2009 STW lock ins lock del 00 0 lusearch2009 STW lock ins lock del pmd2009 sunflow2009 xalan2009 0. 0. 0. 0 6 2 8 24 30 0 6 2 8 24 30 0 6 2 8 24 30 Pause times (ms)

Pause Time distribution 00 0 STW lock ins lock del xalan2009 0. 0 6 2 8 24 30 Pause time

Reference Processing Phase Time Mutators blocked Mutators running 00 0 STW lock ins lock del 00 0 OTF ins OTF del avrora2009 0. 0 6 2 8 24 30 0. 0 6 2 8 24 30 00 0 STW lock ins lock del 00 0 OTF ins OTF del lusearch2009 0. 0 30 60 90 20 50 80 20 240 270 300 0. 0 30 60 90 20 50 80 20 240 270 300 00 0 STW lock ins lock del 00 0 OTF ins OTF del xalan2009 0. 0 6 2 8 24 30 0. 0 6 2 8 24 30

Conclusion Reference types are frequently used in a significant number of programs. On-the-fly GC must not ignore reference types. Formalised the definition of reference types. On-the-fly reference processing. Model checked with SPIN. Implemented in Jikes RVM. On-the-fly reference processing phases are longer in the worst case, but with deletion barrier, not by much. Overall execution time is not increased significantly by processing references on-the-fly, and is often reduced. http://github.com/perlfu/sapphire

2 T = 3790ms 2 T = 4480ms 2 T = 3005ms Calls to get() per msec x 0 3 0 2 T = 439ms 0 2 T = 3639 ms 0 2 T = 265ms 0 2 T = 52ms 0 x-axis: Normalised execution time 0 0

Model Checking Model checked with SPIN Correctness: appears to mutators to be processed by GC atomically Terminates only with deletion barrier r 0 r r 2 x o 0 o o 2

Properties No dangling pointer is created If a variable is not null, its target has not been reclaimed P ((x NULL) = (mark[x] RECLAIMED)) P2 returns its target Once get() of a Reference returns null, it will never P P2 (RETNULL i = (x = i)) (i =, 2, 3) r 0 r r 2 x o 0 o o 2

Race Mutator makes an object strongly reachable Collector clears weak reference not cleared weak reference cleared target object strongly not strongly reachable reachable get() GC

Answer Handshake ensure that GC changes to TRACING after the get() that change the state to REPEAT returned Second handshake ensures all mutators acknowledge GC is in TRACING CAS tells which thread won the race CAS=> REPEAT CAS=>fail ack handshake- handshake-2 req TRACING CAS=>CLEARING