Configuring the Heap and Garbage Collector for Real- Time Programming.

Similar documents
Hard Real-Time Garbage Collection in Java Virtual Machines

JamaicaVM Java for Embedded Realtime Systems

Real-Time Garbage Collection Panel JTRES 2007

Garbage Collection Algorithms. Ganesh Bikshandi

Exploiting the Behavior of Generational Garbage Collector

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

CS577 Modern Language Processors. Spring 2018 Lecture Garbage Collection

A High Integrity Distributed Deterministic Java Environment. WORDS 2002 January 7, San Diego CA

NG2C: Pretenuring Garbage Collection with Dynamic Generations for HotSpot Big Data Applications

Garbage Collection. Hwansoo Han

Garbage Collection. Steven R. Bagley

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

Run-time Environments -Part 3

10/26/2017 Universal Java GC analysis tool - Java Garbage collection log analysis made easy

JVM Memory Model and GC

Garbage Collection. Akim D le, Etienne Renault, Roland Levillain. May 15, CCMP2 Garbage Collection May 15, / 35

Garbage Collection (2) Advanced Operating Systems Lecture 9

Garbage Collection (1)

Towards High Performance Processing in Modern Java-based Control Systems. Marek Misiowiec Wojciech Buczak, Mark Buttner CERN ICalepcs 2011

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

Schism: Fragmentation-Tolerant Real-Time Garbage Collection. Fil Pizlo *

Lecture 13: Garbage Collection

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

Managed runtimes & garbage collection

Lecture 15 Garbage Collection

CMSC 330: Organization of Programming Languages

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

Contents. 8-1 Copyright (c) N. Afshartous

Java Performance Tuning

Running class Timing on Java HotSpot VM, 1

Lecture Notes on Garbage Collection

Object-Oriented Programming. Topic 2: Fundamental Programming Structures in Java

Java Without the Jitter

Java Performance Tuning From A Garbage Collection Perspective. Nagendra Nagarajayya MDE

CA341 - Comparative Programming Languages

Programming Language Implementation

CMSC 330: Organization of Programming Languages

Memory Management: The Details

Habanero Extreme Scale Software Research Project

CS 345. Garbage Collection. Vitaly Shmatikov. slide 1

Java Garbage Collection Best Practices For Tuning GC

Automatic Memory Management

Eliminating External Fragmentation in a Non-Moving Garbage Collector for Java

Generational Garbage Collection Theory and Best Practices

How to keep capacity predictions on target and cut CPU usage by 5x

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

Compiler construction 2009

G1 Garbage Collector Details and Tuning. Simone Bordet

CMSC 330: Organization of Programming Languages. Memory Management and Garbage Collection

CS Computer Systems. Lecture 8: Free Memory Management

OS-caused Long JVM Pauses - Deep Dive and Solutions

The G1 GC in JDK 9. Erik Duveblad Senior Member of Technical Staf Oracle JVM GC Team October, 2017

INITIALISING POINTER VARIABLES; DYNAMIC VARIABLES; OPERATIONS ON POINTERS

Java Concurrency in practice

Robust Memory Management Schemes

MEMORY MANAGEMENT HEAP, STACK AND GARBAGE COLLECTION

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

Last week. Data on the stack is allocated automatically when we do a function call, and removed when we return

Real Time: Understanding the Trade-offs Between Determinism and Throughput

Memory management has always involved tradeoffs between numerous optimization possibilities: Schemes to manage problem fall into roughly two camps

CSE P 501 Compilers. Memory Management and Garbage Collec<on Hal Perkins Winter UW CSE P 501 Winter 2016 W-1

Java Memory Management. Märt Bakhoff Java Fundamentals

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

Java & Coherence Simon Cook - Sales Consultant, FMW for Financial Services

Run-time Environments - 3

Optimising Multicore JVMs. Khaled Alnowaiser

JVM Performance Study Comparing Java HotSpot to Azul Zing Using Red Hat JBoss Data Grid

Garbage Collection. CS 351: Systems Programming Michael Saelee

Motivation for Dynamic Memory. Dynamic Memory Allocation. Stack Organization. Stack Discussion. Questions answered in this lecture:

A JVM Does What? Eva Andreasson Product Manager, Azul Systems

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

20 Most Important Java Programming Interview Questions. Powered by

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

Attila Szegedi, Software

Space Exploration EECS /25

Implementation Garbage Collection

Introduction to Java

Advances in Programming Languages: Regions

Introduction to Java

Low latency & Mechanical Sympathy: Issues and solutions

Simple Garbage Collection and Fast Allocation Andrew W. Appel

CMSC 330: Organization of Programming Languages. Ownership, References, and Lifetimes in Rust

Memory. don t forget to take out the

Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc.

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

HBase Practice At Xiaomi.

Profiling & Optimization

Lecture Conservative Garbage Collection. 3.2 Precise Garbage Collectors. 3.3 Other Garbage Collection Techniques

Java Performance Tuning and Optimization Student Guide

CSE 12 Spring 2016 Week One, Lecture Two

Cycle Tracing. Presented by: Siddharth Tiwary

JVM Troubleshooting MOOC: Troubleshooting Memory Issues in Java Applications

Dynamic Memory Management! Goals of this Lecture!

Run-Time Environments/Garbage Collection

Memory Allocation. Static Allocation. Dynamic Allocation. Dynamic Storage Allocation. CS 414: Operating Systems Spring 2008

CS 241 Honors Memory

Garbage Collection. Weiyuan Li

the gamedesigninitiative at cornell university Lecture 9 Memory Management

Lecture 15 Advanced Garbage Collection

Operating Systems CMPSCI 377, Lec 2 Intro to C/C++ Prashant Shenoy University of Massachusetts Amherst

Transcription:

Configuring the Heap and Garbage Collector for Real- Time Programming.... A user s perspective to garbage collection Fridtjof Siebert, IPD, University of Karlsruhe 1 Jamaica Systems Structure What is the purpose of a garbage collector What knobs are there to turn? Different GCs: Blocking, Generational, Concurrent, Conservative, Mixed GCs that couple work with allocation Example Conclusion 2 Jamaica Systems

What is the purpose of GC? An automatic mechanism for memory management, to take the burden of memory reclamation memory defragmentation dangling references memory leaks / forgotten free()s from the user. 3 Jamaica Systems GC as a black box The user does not understand what is happening inside the GC algorithm! But: The user might configure the behaviour of the GC. We have a black box with knobs to turn! To be able to configure the GC seen as a black box, the user needs guidance and tools to make a good decision. Else he will make bad decisions! 4 Jamaica Systems

What are these knobs? Heap size (min/initial, max,...) Object count Amount of GC work GC priority GC threshold GC scanning rate GC CPU-percentage... Control GC Algorithm Select a GC implementation 5 Jamaica Systems In a blocking garbage collector Effect of changing heap size h: GC pause time p changes, ex. p h GC pause frequency f changes, ex. f 1/h Application behaviour changes: Runs fine for h >= h min crashes for h < h min What is the value of h min? 6 Jamaica Systems

In a generational GC Heap: GCed area Effect of changing heap size h: old area Age: young old Same behaviour as blocking GC, but Shorter pause time p young and higher frequency f young for collecting young Pause time p old for collecting old as long as for blocking GC. Application dependency: lower frequency f old of collections of old area? 7 Jamaica Systems Concurrent Garbage Collector GC running e.g. as a separate thread. Values to be adjusted heap size h GC threshold t (when does GC start?) GC rate r / priority / etc. f block r min Minumum GC rate r min depends on application. We need a tool to determine this value! r 8 Jamaica Systems

Conservative Garbage Collector Change of configuration or of input data has unpredictable effects on GC performance and effectiveness! useless for nearly any serious application! 9 Jamaica Systems Mixed approaches Example: HotSpot offering choice between --or-- Generational GC + Blocking for old area Generational GC + Incremental for old What guides the user by his choice? If one choice does not work, just try the other one and hope? 10 Jamaica Systems

GC coupled with allocation Values to be adjusted by user heap size h static GC work w stat on allocation Heap: max. used h max (eg. 60%) GC1 GC2 wcet alloc set w stat to 5 (= 2/(1-h max )) Requires tool to determine h max and w stat. w stat 11 Jamaica Systems GC work determined dynamically Values to be adjusted by user heap size h GC determines w dyn as function of amount of free memory. wcet alloc h min Tool to select h and determine wcet alloc needed. h 12 Jamaica Systems

Example public class HelloWorld { public static void main(string[] args) { int n,s,c; s = 0; c = 14; for(int i=0; i<30; i++) { String s1 = " ".substring(s+14); String s2 = " ".substring(s/2+7); System.out.println(s1+"Hello "+s2+"world!"); s = s + c / 4; c = c - s / 4; } } } 13 Jamaica Systems Example > jamaica -analyse 5 HelloWorld > HelloWorld Hello World! Hello World! [...] ### Application used at most 117224 bytes for Java heap ### ### heapsize wcet dynamic wcet static ### 337k 7 3 ### 226k 7 4 ### 189k 10 5 ### 170k 14 6 ### 162k 16 7 ### 152k 21 8 ### 143k 28 10 ### 134k 40 14 ### 121k 138 40 ### 118k 286 80 14 Jamaica Systems

Example Determination of worst-case execution time of new StringBuffer() Determine number of blocks: > numblocks java.lang.stringbuffer 1 Worst-case execution time: wcet = numblocks max gc_unit wcet gc_unit wcet 152k = 1 21 2µs = 42µs wcet 226k = 1 7 2µs = 14µs 15 Jamaica Systems Comparison GC Algorithm Knobs Effects on Blocking h pause times p Generational h,... pause freq. f Concurrent h, r,... blocking freq. f GC overhead Static on alloc h, w s wcet alloc Dynamic on alloc h wcet alloc 16 Jamaica Systems

Conclusion The user can not be burdened with understanding the GC mechanism used by an implementation. Current implementations lack tools that guide the user in making a good choice for GC configuration Fewer knobs are better! A value that can t be changed can t be set wrong. 17 Jamaica Systems