JDK 9/10/11 and Garbage Collection

Similar documents
Java in a World of Containers

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

Java in a World of Containers

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

CON Java in a World of Containers

Ahead of Time (AOT) Compilation

New Java performance developments: compilation and garbage collection

The Z Garbage Collector An Introduction

The Z Garbage Collector Low Latency GC for OpenJDK

Shaping the future of Java, Faster

What a Year! Java 10 and 10 Big Java Milestones

Introduction to Java. Lecture 1 COP 3252 Summer May 16, 2017

JDK 9, 10, 11 and Beyond: Delivering New Features in the JDK

JVM Memory Model and GC

Scaling the OpenJDK. Claes Redestad Java SE Performance Team Oracle. Copyright 2017, Oracle and/or its afliates. All rights reserved.

MODULE 1 JAVA PLATFORMS. Identifying Java Technology Product Groups

Introduction to Java Programming

Java Performance Tuning and Optimization Student Guide

Certified Core Java Developer VS-1036

Highlights from Java 10, 11 and 12 and Future of Java Javaland by Vadym Kazulkin, ip.labs GmbH

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

Lesson 2 Dissecting Memory Problems

JVM Troubleshooting MOOC: Troubleshooting Memory Issues in Java Applications

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

Copyright 2014 Oracle and/or its affiliates. All rights reserved.

Java Without the Jitter

Welcome to the session...

OS-caused Long JVM Pauses - Deep Dive and Solutions

JamaicaVM Java for Embedded Realtime Systems

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

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

Mission Possible - Near zero overhead profiling. Klara Ward Principal Software Developer Java Mission Control team, Oracle February 6, 2018

Using the Singularity Research Development Kit

Java Performance Tuning

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

Optimising Multicore JVMs. Khaled Alnowaiser

Another difference is that the kernel includes only the suspend to memory mechanism, and not the suspend to hard disk, which is used on PCs.

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

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

Java Performance: The Definitive Guide

COMP Computer Basics. Yi Hong May 13, 2015

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

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

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

An Introduction to Software Engineering. David Greenstein Monta Vista High School

Core Java JDK 9 Overview Angelika Langer & Klaus Kreft

Java On Steroids: Sun s High-Performance Java Implementation. History

Dynamic Vertical Memory Scalability for OpenJDK Cloud Applications

Fundamentals of GC Tuning. Charlie Hunt JVM & Performance Junkie

Runtime Application Self-Protection (RASP) Performance Metrics

Cords and gumballs. Mike Hearn.

G1 Garbage Collector Details and Tuning. Simone Bordet

Truffle A language implementation framework

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

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

Six New Trends in the JVM

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

Java Puzzle Ball Nick Ristuccia

1. Introduction. Java. Fall 2009 Instructor: Dr. Masoud Yaghini

Advanced Object-Oriented Programming Introduction to OOP and Java

Managed runtimes & garbage collection

TRASH DAY: COORDINATING GARBAGE COLLECTION IN DISTRIBUTED SYSTEMS

Oracle Real Application Clusters (RAC) 12c Release 2 What s Next?

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

2 Introduction to Java. Introduction to Programming 1 1

Fiji VM Safety Critical Java

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

Mark Falco Oracle Coherence Development

Application Container Cloud

Notes of the course - Advanced Programming. Barbara Russo

Unleash the power of Essbase Custom Defined Functions

Automating Information Lifecycle Management with

55 New Features In JDK 9

Oracle JRockit. Performance Tuning Guide Release R28 E

Java Platform, Standard Edition Java Virtual Machine Guide. Release 9

IBM Developer Kit and Runtime Environment, Java Technology Edition Version 6. IBM SDK Java Technology Edition Version 6 Supplement

High Performance Managed Languages. Martin Thompson

The Impact of a Real-Time JVM on Middleware Performance: Lessons Learned from Implementing DDS on IBM s J9

Best Practices for Developing & Deploying Java Applications with Docker

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview

CS260 Intro to Java & Android 02.Java Technology

Wednesday, May 30, 12

High-Level Language VMs

IBM s statements regarding its plans, directions, and intent are subject to change or withdrawal without notice at IBM s sole discretion.

Elastic Data. Harvey Raja Principal Member Technical Staff Oracle Coherence

Building A Better Test Platform:

Jaguar: Enabling Efficient Communication and I/O in Java

IBM Cognos ReportNet and the Java Heap

Unified JVM Logging in JDK 9

Garbage Collection. Steven R. Bagley

Heap Compression for Memory-Constrained Java

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

Index. Decomposability, 13 Deep reflection, 136 Dependency hell, 19 --describe-module, 39

Wednesday, November 16, 11

Server Monitoring. AppDynamics Pro Documentation. Version 4.1.x. Page 1

INFO Object-Oriented Programming

Java Leaders Summit Java SE

<Insert Picture Here> Get on the Grid. JVM Language Summit Getting Started Guide. Cameron Purdy, VP of Development, Oracle

Hierarchical Real-time Garbage Collection

DNS Level 100. Rohit Rahi November Copyright 2018, Oracle and/or its affiliates. All rights reserved.

Transcription:

JDK 9/10/11 and Garbage Collection Thomas Schatzl Senior Member of Technical Staf Oracle JVM Team May, 2018 thomas.schatzl@oracle.com Copyright 2017, Oracle and/or its afliates. All rights reserved. 1

Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle s products remains at the sole discretion of Oracle. 2

Agenda 1 The JDK and the JVM 2 Garbage Collector 3 Runtime 4 Compiler 5 Future 3

Agenda 1 The JDK and the JVM 2 Garbage Collector 3 Runtime 4 Compiler 5 Future 4

The Java Development Kit (JDK) Specifcction Tools Runtime Java Language javac JVM Java Virtual Machine jshell Java Class Library Java Platform jar jlink 5

The Java Development Kit (JDK) Specifcction Tools Runtime Jcvc Lcngucge javac JVM Java Virtual Machine jshell Java Class Library Java Platform jar jlink 6

The Java Development Kit (JDK) Specifcction Tools Runtime Java Language javac JVM Java Virtual Machine jshell Java Class Library Jcvc Plctform jar jlink 7

The Java Development Kit (JDK) Specifcction Tools Runtime Java Language javac JVM Java Virtual Machine jshell Java Class Library Java Platform jar jlink 8

The Java Development Kit (JDK) Specifcction Tools Runtime Java Language javac JVM Java Virtual Machine jshell Java Class Library Java Platform jar jlink 9

The Java Development Kit (JDK) Specifcction Tools Runtime Java Language javac JVM Java Virtual Machine jshell Java Class Library Java Platform jar jlink 10

The Java Virtual Machine (JVM) *.jar *.class App 11

The Java Virtual Machine (JVM) *.jar *.class Library Library *.jar App Library Library 12

The Java Virtual Machine (JVM) *.jar *.class Library Library *.jar App Library Library Java Class Library *.jmod 13

The Java Virtual Machine (JVM) *.jar *.class Library Library *.jar App Library Library Java Class Library *.jmod Java Virtual Machine libjvm.so 14

The Java Virtual Machine (JVM) *.jar *.class Library Library *.jar App Library Library Java Class Library *.jmod Java Virtual Machine libjvm.so GC Runtime Compiler 15

The Java Virtual Machine (JVM) *.jar *.class Library Library *.jar App Library Library Java Class Library *.jmod Java Virtual Machine libjvm.so GC Runtime Compiler 16

The Java Virtual Machine (JVM) Components Garbage collector Responsible for allocating memory and reclaiming unused memory Runtime Responsible for loading classes, operating system interaction and much more Compiler Responsible for compiling Java bytecode into highly efective machine code 17

Agenda 1 The JDK and the JVM 2 Garbage Collector 3 Runtime 4 Compiler 5 Future 18

Garbage Collector Responsible for allocating memory class Person { private String name; public Person(String name) { this.name = name; } } var p = new Person( John Doe ); 19

Garbage Collector Responsible for allocating memory class Person { private String name; public Person(String name) { this.name = name; } P e r s o n n a m e S t r i n g v a l u e 0 0 a r r a y 8 J o h n D o e } var p = new Person( John Doe ); Heap 20

Garbage Collector The heap is often very large 1 256 GB (even 1 TB) The heap contain billions of objects of diferent sizes of diferent types What happens when the heap is full? 21

Garbage Collector 1. Find live objects 22

Garbage Collector 1. Find live objects 2. Compact live objects 23

Garbage Collector Compaction can take a long time when the heap is very large the heap contain billions of live objects A Java application is often stopped during compaction Your application can be stopped for many seconds! not good for servers and GUI programs 24

Garbage Collector The G1 Garbage Collector G1 is the new default memory management algorithm since JDK 9 frst introduced in 6u14 Supported since 7u4 The goal: throughput and low latency The default pause goal for G1 is 200 milliseconds Higher pause goal more throughput, higher latency Lower pause goal less throughput, lower latency 25

Garbage Collector The G1 Garbage Collector G1 divides the heap into multiple regions 26

Garbage Collector The G1 Garbage Collector G1 divides the heap into multiple regions G1 fnds all live objects concurrently the Java application is not stopped 27

Garbage Collector The G1 Garbage Collector G1 divides the heap into multiple regions G1 fnds all live objects concurrently the Java application is not stopped 28

Garbage Collector The G1 Garbage Collector G1 divides the heap into multiple regions G1 fnds all live objects concurrently the Java application is not stopped 29

Garbage Collector The G1 Garbage Collector G1 divides the heap into multiple regions G1 fnds all live objects concurrently the Java application is not stopped G1 keeps track of pointers between regions 30

Garbage Collector The G1 Garbage Collector G1 divides the heap into multiple regions G1 fnds all live objects concurrently the Java application is not stopped G1 keeps track of pointers between regions G1 can therefore collect a few regions at a time fewer objects to collect shorter pauses more information more control over pauses 31

Garbage Collector The G1 Garbage Collector What happens if the heap becomes full before G1 fnds all live objects? frst, since JDK9 G1 tries to determine when to start this phase automatically so that the heap is not full fall back to secondary algorithm: full collection The full collection used to be single threaded can take a very long time on large heaps Solved in JDK 10! 32

Garbage Collector The G1 Garbage Collector JEP 307: Parallel Full GC For G1 http://openjdk.java.net/jeps/307 Parallel mark-sweep-compact algorithm Signifcantly improves G1 s worst case pause times Enabled by default Available in JDK 10 33

Garbage Collector The G1 Garbage Collector G1 in JDK 10 also features enhanced heap scanning Results in shorter pause times for young and mixed collections Results in less concurrent CPU usage Enabled by default Available in JDK 10 34

Agenda 1 The JDK and the JVM 2 Garbage Collector 3 Runtime 4 Compiler 5 Future 35

Runtime The runtime is responsibly for many parts: Loading Java classes Interacting with the operating system Concurrency primitives (threads, monitors, etc.) Logging Diagnostics Serviceability 36

Runtime The runtime is responsibly for many parts: Loading Java classes Interacting with the operating system Concurrency primitives (threads, monitors, etc.) Logging Diagnostics Serviceability 37

Runtime Loading Java classes DefineClass() javac App.java (text flee App.class (binary flee Klass* (in-memory objecte 38

Runtime Loading Java classes Loading a Java class from a.class fle takes time must load.class content from disk must verify class fle must create JVM in-memory representation must resolve and link references Many times you re-start the same Java program all this work must be repeated every time the JVM starts Can this be optimized? 39

Runtime Loading Java classes JDK 1.5 shipped with Class-Data Sharing (CDS) CDS stores already loaded and verifed classes to a shared archive fle can be quickly loaded by the JVM at startup can also be shared by multiple JVMs Limitations only for the client JVM only for the Serial garbage collector only works with system classes 40

Runtime Loading Java classes JDK 9 shipped with enhanced Class-Data Sharing works with the G1, Parallel and Serial garbage collectors works with both client and server JVMs works with shared strings (only with the G1 GC) Limitations still only applicable to system classes 41

Runtime Loading Java classes JDK 9 also shipped Application Class Data Sharing (AppCDS) enables application classes to also be stored to in the shared archive fle, e.g. Person Commercial feature Only available in Oracle JDK 9 42

Runtime Loading Java classes AppCDS was open sourced for JDK 10! JEP 310: Application Class-Data Sharing http://openjdk.java.net/jeps/310 Results in even faster startup times great for spinning up new JVMs on demand quickly 43

Runtime Loading Java classes 1) Find out which classes to share: $ java -Xshare:off -XX:+UseAppCDS -XX:DumpLoadedClassList=app.lst \ -cp lib.jar App 2) Create the shared archive fle: $ java -Xshare:dump -XX:+UseAppCDS \ -XX:SharedClassListFile=app.lst \ -XX:SharedArchiveFile=app.jsa \ -cp lib.jar 3) Use the shared archive fle: $ java -Xshare:auto -XX:+UseAppCDS -XX:SharedArchiveFile=app.jsa \ -cp lib.jar App 44

Runtime Interacting with the operating system The runtime queries the operating system (OS) for determining active CPUs how much memory is available other resource limits Important to use the right APIs in a world of containers do not query the CPU directly must be aware of Linux namespaces 45

Runtime Interacting with the operating system The JVM in JDK 10 uses the correct OS interfaces Uses cgroups to fnd memory limits Default heap size will no longer be way too big Uses cpuset to limit number of cores Default number of GC and compiler threads will be correct Uses the pid namespace for the attach API JDK tools such as container jmap can connect to a JVM running in a 46

Runtime Interacting with the operating system New more intuitive fags for setting heap sizing -XX:MinRAMPercentage -XX:InitialRAMPercentage -XX:MaxRAMPercentage Works great in combination with containers no need to update JVM fags when changing container memory limits 47

Runtime Interacting with the operating system JDK 10 now much better supports containers AppCDS enables faster startup Using the correct OS interfaces enables better defaults better tooling New fags enables more intuitive heap sizing Make sure to upgrade to JDK 10 if you are using Docker! 48

Agenda 1 The JDK and the JVM 2 Garbage Collector 3 Runtime 4 Compiler 5 Future 49

Compiler Bytecode Interpreter C1 C2 JIT JIT 50

Compiler Improved ahead of time compiler JDK 9 introduced the ahead-of-time (AOT) compiler jaotc javac Java source code (texte jaotc Java.class fles (binarye Shared library (machine codee 51

Compiler Improved ahead of time compiler JDK 9 introduced the ahead-of-time (AOT) compiler jaotc Shared library (machine codee C1 C2 JIT JIT 52

Compiler Improved ahead of time compiler JDK 9 introduced the ahead-of-time (AOT) compiler jaotc Limitations did not support all bytecodes only worked on Linux experimental support 53

Compiler Improved ahead of time compiler JDK 10 features an enhanced AOT compiler now supports the invokedynamic bytecode works on Linux, macos and Windows Still experimental support Use with $ jaotc --output libapp.so App.class 54

Compiler Experimental Java-Based JIT Compiler JDK 10 also ships with a new JIT compiler: Graal C1 Bytecode Interpreter JIT Graal (JITe 55

Compiler Experimental Java-Based JIT Compiler JDK 10 also ships with a new JIT compiler: Graal Only support for Linux Only experimental support May or may not make your application faster Use with $ java -XX:+UnlockExperimentalVMOptions \ -XX:+UseJVMCICompiler 56

Agenda 1 The JDK and the JVM 2 Garbage Collector 3 Runtime 4 Compiler 5 Future 57

Future JDK 11 JDK 11 scheduled for release in September, 2018 Dynamic Class-File Constants (JEP 309) Local Variable Syntax for Lambda Parameters (JEP 323) Flight Recorder (JEP 328) Runtime: Improved Metaspace allocation Compiler: Build Graal on Windows and Mac 58

Future JDK 11 JDK 11 scheduled for release in September, 2018 G1 GC Dynamic Number of Thread Sizing Reduced Native Memory Footprint Signifcantly Lower Pause Times Improved Throughput 59

Future JDK 11 http://jdk.java.net/11 Now is the right time to provide feedback! 60

Future Projects Many exciting ongoing projects ZGC Portola Valhalla Loom Panama See http://openjdk.java.net for more projects and information 61

Future Projects Many exciting ongoing projects ZGC Portolc Valhalla Loom Panama See http://openjdk.java.net for more projects and information 62

Future Project ZGC ZGC is a new scalable low latency garbage collector pause times below 10 ms pause times do not increase with heap size (nor live-set size) built for heaps from a few gigabytes to multiple terabytes in size Finds all live objects concurrently Compacts live objects concurrently 63

Future Project ZGC http://jdk.java.net/zgc https://wiki.openjdk.java.net/display/zgc/main 64

Future Project Portola Port of OpenJDK to Alpine Linux Alpine Linux is a small and lightweight Linux distribution Uses the musl C standard library Size of Alpine Linux when used as Docker base image: 4 MB compare to Ubuntu: 120MB Use jlink to produce a small Java Runtime Environment (JRE) a Docker image for java.base and Alpine Linux is 40 MB 65

Future Project Portola http://jdk.java.net/11 http://openjdk.java.net/projects/portola/ 66

Agenda 1 The Java Virtual Machine 2 Garbage Collector 3 Runtime 4 Compiler 5 Future 67

Summary JDK 9+ contain great improvements to the JVM G1 as default collector Parallel Full GC Reduced Pause times Improved Throughput AppCDS Better container support Improved AOT Experimental Graal support 68

Summary http://jdk.java.net/10 http://jdk.java.net/11 Please report issues to: https://bugreport.java.com/ GC experience reports/troubleshooting e-mail hotspot_gc_use@openjdk.java.net 69

Questions? 70

Thanks go to... Erik Duveblad For a large amount of the slides >100 Developers from many companies that contribute to OpenJDK You for supporting and improving our work with your feedback 72