THE TROUBLE WITH MEMORY

Similar documents
Attila Szegedi, Software

Do Your GC Logs Speak To You

Concurrent Garbage Collection

Garbage Collection. Hwansoo Han

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

CS 241 Honors Memory

Exploiting the Behavior of Generational Garbage Collector

JVM Memory Model and GC

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

G1 Garbage Collector Details and Tuning. Simone Bordet

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

Java Performance: The Definitive Guide

Garbage Collection (aka Automatic Memory Management) Douglas Q. Hawkins. Why?

Java Performance Tuning

Low latency & Mechanical Sympathy: Issues and solutions

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

Azul Systems, Inc.

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

Habanero Extreme Scale Software Research Project

New Java performance developments: compilation and garbage collection

High Performance Managed Languages. Martin Thompson

Lecture 13: Garbage Collection

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

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

Agenda. CSE P 501 Compilers. Java Implementation Overview. JVM Architecture. JVM Runtime Data Areas (1) JVM Data Types. CSE P 501 Su04 T-1

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

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

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

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

Java Garbage Collection Best Practices For Tuning GC

High Performance Managed Languages. Martin Thompson

Running class Timing on Java HotSpot VM, 1

Programming Language Implementation

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

Generational Garbage Collection Theory and Best Practices

The Fundamentals of JVM Tuning

JVM Troubleshooting MOOC: Troubleshooting Memory Issues in Java Applications

JAVA PERFORMANCE. PR SW2 S18 Dr. Prähofer DI Leopoldseder

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

Workload Characterization and Optimization of TPC-H Queries on Apache Spark

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

Java Memory Management. Märt Bakhoff Java Fundamentals

Lesson 2 Dissecting Memory Problems

A new Mono GC. Paolo Molaro October 25, 2006

Myths and Realities: The Performance Impact of Garbage Collection

MEMORY MANAGEMENT HEAP, STACK AND GARBAGE COLLECTION

Compiler construction 2009

Managed runtimes & garbage collection

CMSC 330: Organization of Programming Languages

Java performance - not so scary after all

Lecture 15 Garbage Collection

ECE 598 Advanced Operating Systems Lecture 10

WHO AM I.

SPECjAppServer2002 Statistics. Methodology. Agenda. Tuning Philosophy. More Hardware Tuning. Hardware Tuning.

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

High-Level Language VMs

Heap Off Memory WTF?? Reducing Heap memory stress

CS Computer Systems. Lecture 8: Free Memory Management

2011 Oracle Corporation and Affiliates. Do not re-distribute!

The Garbage-First Garbage Collector

CMSC 330: Organization of Programming Languages

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

Java Garbage Collection. Carol McDonald Java Architect Sun Microsystems, Inc.

Review. Partitioning: Divide heap, use different strategies per heap Generational GC: Partition by age Most objects die young

Garbage collection. The Old Way. Manual labor. JVM and other platforms. By: Timo Jantunen

Heap Compression for Memory-Constrained Java

Typical Issues with Middleware

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

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

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

CS 345. Garbage Collection. Vitaly Shmatikov. slide 1

SELF-AWARE APPLICATIONS AUTOMATIC PRODUCTION DIAGNOSIS DINA GOLDSHTEIN

HBase Practice At Xiaomi.

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

Garbage Collection (1)

CA341 - Comparative Programming Languages

JPDM, A Structured approach To Performance Tuning. Copyright 2017 Kirk Pepperdine. All rights reserved

A Tour to Spur for Non-VM Experts. Guille Polito, Christophe Demarey ESUG 2016, 22/08, Praha

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

Lecture 9 Dynamic Compilation

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

NUMA in High-Level Languages. Patrick Siegler Non-Uniform Memory Architectures Hasso-Plattner-Institut

OS-caused Long JVM Pauses - Deep Dive and Solutions

About BigMemory Go. Innovation Release. Version 4.3.5

CSE P 501 Compilers. Java Implementation JVMs, JITs &c Hal Perkins Winter /11/ Hal Perkins & UW CSE V-1

A Study Paper on Performance Degradation due to Excessive Garbage Collection in Java Based Applications using Profiler

Parallel GC. (Chapter 14) Eleanor Ainy December 16 th 2014

Implementation Garbage Collection

CS399 New Beginnings. Jonathan Walpole

Hard Real-Time Garbage Collection in Java Virtual Machines

Fundamentals of GC Tuning. Charlie Hunt JVM & Performance Junkie

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

Automatic Garbage Collection

ECE 598 Advanced Operating Systems Lecture 12

Exploiting Prolific Types for Memory Management and Optimizations

Dynamic Memory Management! Goals of this Lecture!

ANALYZING THE MOST COMMON PERFORMANCE AND MEMORY PROBLEMS IN JAVA. 18 October 2017

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

Computer Systems A Programmer s Perspective 1 (Beta Draft)

Dynamic Memory Management

Transcription:

THE TROUBLE WITH MEMORY

OUR MARKETING SLIDE Kirk Pepperdine Authors of jpdm, a performance diagnostic model Co-founded Building the smart generation of performance diagnostic tooling Bring predictability into the diagnostic process Co-founded JCrete The hotest unconference on the planet Java Champion(s)

What is your performance trouble spot

> 70% of all applications are bottlenecked on memory

and no, Garbage Collection is not a fault!!!!

DO YOU USE

DO YOU USE Spring Boot

DO YOU USE Cassandra

DO YOU USE Cassandra or any big nosql solution

DO YOU USE Apache Spark

DO YOU USE Apache Spark or any big data framework

DO YOU USE Log4J

DO YOU USE Log4J or any Java logging framework

DO YOU USE JSON

DO YOU USE JSON With almost any Marshalling protocol

DO YOU USE ECom caching products

DO YOU USE ECom caching products Hibernate

DO YOU USE ECom caching products Hibernate and so on

DO YOU USE ECom caching products Hibernate and so on and so on

DO YOU USE ECom caching products Hibernate and so on and so on and so on

then you are very likely in this 70%

PROBLEMS High memory churn rates many temporary objects Large live data set size inflated live data set size loitering Unstable live data set size memory leak

WAR STORIES Reduced allocation rates from 1.8gb/sec to 0 tps jumped from 400,000 to 25,000,000!!! Stripped all logging our of a transactional engine Throughput jumped by a factor of 4x Wrapped 2 logging statements in a web socket framework Memory churn reduced by a factor of 2

ALLOCATION SITE Foo foo = new Foo(); forms an allocation site 0: new #2 // class java/lang/object 2: dup 4: invokespecial #1 // Method java/lang/object."<init>":()v Allocation will (mostly) occur in Java heap fast path slow path small objects maybe optimized to an on-stack allocation

JAVA HEAP Eden Survivor (to) Tenured Java Heap Java Heap is made of; Eden - nursery Survivor - intermediate pool designed to delay promotion Tenured - to hold long lived data Each space contributes to a different set of problems All affect GC overhead

EDEN ALLOCATIONS top of heap pointer

OBJECT ALLOCATION top of heap pointer Foo foo = new Foo(); Bar bar = new Bar(); byte[] array = new byte[n];

Foo top of heap pointer Foo foo = new Foo(); Bar bar = new Bar(); byte[] array = new byte[n]; OBJECT ALLOCATION

Foo Bar top of heap pointer Foo foo = new Foo(); Bar bar = new Bar(); byte[] array = new byte[n]; OBJECT ALLOCATION

Foo Bar OBJECT ALLOCATION byte[] top of heap pointer Foo foo = new Foo(); Bar bar = new Bar(); byte[] array = new byte[n];

Foo Bar OBJECT ALLOCATION byte[] top of heap pointer In multi-threaded apps, top of heap pointer must be surrounded by barriers single threads allocation hot memory address solved by stripping (Thread local allocation blocks)

TLAB ALLOCATION TLAB TLAB TLAB pointer TLAB pointer top of heap pointer Assume 2 threads each thread will have it s own (set of) TLAB(s)

Foo TLAB TLAB ALLOCATIONS TLAB Bar TLAB pointer byte[] TLAB pointer top of heap pointer Thread 1 -> Foo foo = new Foo(); byte[] array = new byte[n]; byte[] doesn t fit in a TLAB Thread 2 -> Bar bar = new Bar();

TLAB WASTE % Foo Foo Foo Foo Foo Foo Foo Foo Allocation failure to prevent buffer overflow waste up to 1% of a TLAB

TLAB WASTE % Foo Foo Foo Foo Foo Foo Foo Foo Foo Allocation failure to prevent buffer overflow waste up to 1% of a TLAB

TENURED SPACE Free List Bar Bar Foo Foo Allocations in tenured make use of a free list free list allocation is ~10x the cost of bump and run Data in tenured tends to be long lived amount of data in tenured do affect GC pause times

PROBLEMS High memory churn rates many temporary objects

PROBLEMS High memory churn rates many temporary objects Quickly fill Eden frequent young gc cycles speeds up aging premature promotion more frequent tenured cycles increased copy costs increased heap fragmentation Allocation is quick quick * large number = slow

REDUCING ALLOCATIONS > 1gb/sec size of gain < 300mb/sec

PROBLEMS High memory churn rates many temporary objects Large live data set size inflated live data set size loitering

PROBLEMS High memory churn rates many temporary objects Large live data set size inflated live data set size loitering inflated scan for root times reduced page locality Inflated compaction times increase copy costs likely less space to copy too

PAUSE VS OCCUPANCY

PROBLEMS High memory churn rates many temporary objects Large live data set size inflated live data set size loitering Unstable live data set size memory leak

PROBLEMS High memory churn rates many temporary objects Large live data set size inflated live data set size loitering Eventually you run out of heap space each app thread throws an OutOfMemoryError and terminates JVM will shutdown with all nondaemon threads terminate Unstable live data set size memory leak

Escape Analysis

Demo time

TEXT TITLE TEXT Body Level One Body Level Two Body Level Three Body Level Four Body Level Five Send us a Java 11 GC log or tweet about @jclarity #QConSF and #censum and get a free Censum License Ask out my Java Performance Tuning Workshop