New GC collectors in Java 11 Epsilon ZGC

  • Slides: 29
Download presentation
New GC collectors in Java 11 Epsilon + ZGC 116. Wroclaw. JUG Java 11

New GC collectors in Java 11 Epsilon + ZGC 116. Wroclaw. JUG Java 11 Lightning talks

whoami? Robert Podsiadły: • I have been working in IT since 86. • 1986

whoami? Robert Podsiadły: • I have been working in IT since 86. • 1986 -1999: Assemblers, C, C++ • 1999 -2014: Not a programming position. • From 2015: Java • Currently at Tieto as Software Engineer • Next mountain: Scala + functional programming • After work: long distance trail running + sky running 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 2

Why do we talk about it? 2018 -11 -22 116. Wroclaw. JUG Java 11

Why do we talk about it? 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 3

Memory model 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 4

Memory model 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 4

Memory model 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 5

Memory model 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 5

Memory model 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 6

Memory model 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 6

Memory model 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 7

Memory model 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 7

Generations The age of the object in memory Generational Hypothesis 2018 -11 -22 116.

Generations The age of the object in memory Generational Hypothesis 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 8

Dead objects searching algorithm • Scalar algorithm 0 1 2 1 0 1 1

Dead objects searching algorithm • Scalar algorithm 0 1 2 1 0 1 1 1 1 2 • Vector algorithm 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 9

Memory cleaning algorithms • Serial STW • Paraller STW • CMS (Concurrent Mark-Sweep) •

Memory cleaning algorithms • Serial STW • Paraller STW • CMS (Concurrent Mark-Sweep) • Garbage First (G 1) 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 10

Young generation collectors • Copy (enabled with -XX: +Use. Serial. GC) • PS Scavenge

Young generation collectors • Copy (enabled with -XX: +Use. Serial. GC) • PS Scavenge (enabled with -XX: +Use. Parallel. GC) • Par. New (enabled with -XX: +Use. Par. New. GC) • G 1 Young Generation (enabled with -XX: +Use. G 1 GC) (http: //www. fasterj. com/articles/oraclecollectors 1. shtml) 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 11

Old generation collectors • Mark. Sweep. Compact (enabled with -XX: +Use. Serial. GC) •

Old generation collectors • Mark. Sweep. Compact (enabled with -XX: +Use. Serial. GC) • PS Mark. Sweep (enabled with -XX: +Use. Parallel. Old. GC) • Concurrent. Mark. Sweep (enabled with -XX: +Use. Conc. Mark. Sweep. GC) • G 1 Mixed Generation (enabled with -XX: +Use. G 1 GC) (http: //www. fasterj. com/articles/oraclecollectors 1. shtml) 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 12

What's new after Java 8 • JEP 248: Make G 1 the Default Garbage

What's new after Java 8 • JEP 248: Make G 1 the Default Garbage Collector – Java 9 • JEP 304: Garbage Collector Interface - Java 10 • JEP 318: Epsilon: A No-Op Garbage Collector (Experimental) – Java 11 https: //openjdk. java. net/jeps/318 • JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental) – Java 11 http: //openjdk. java. net/jeps/333 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 13

JEP 318: Epsilon: A No-Op Garbage Collector – Goals Provide a completely passive GC

JEP 318: Epsilon: A No-Op Garbage Collector – Goals Provide a completely passive GC implementation with a bounded allocation limit and the lowest latency overhead possible, at the expense of memory footprint and memory throughput. A successful implementation is an isolated code change, does not touch other GCs, and makes minimal changes in the rest of JVM. 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 14

JEP 318: Epsilon: A No-Op Garbage Collector – Non-Goals It is not a goal

JEP 318: Epsilon: A No-Op Garbage Collector – Non-Goals It is not a goal to introduce manual memory management features to Java language and/or JVM. It is not a goal to introduce new APIs to manage Java heap. It is not a goal to change or cleanup internal JVM interfaces to fit this GC. 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 15

JEP 318: Epsilon: A No-Op Garbage Collector – Motivation • Performance testing. • Memory

JEP 318: Epsilon: A No-Op Garbage Collector – Motivation • Performance testing. • Memory pressure testing. • VM interface testing. • Extremely short lived jobs. • Last-drop latency improvements. • Last-drop throughput improvements. 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 16

JEP 318: Epsilon: Description Epsilon GC looks and feels like any other Open. JDK

JEP 318: Epsilon: Description Epsilon GC looks and feels like any other Open. JDK GC, enabled with -XX: +Unlock. Experimental. VMOptions -XX: +Use. Epsilon. GC Once the Java heap is exhausted: • Throw an Out. Of. Memory. Error with a descriptive message. • Perform a heap dump (enabled, as usual, with XX: +Heap. Dump. On. Out. Of. Memory. Error) • Fail the JVM hard and optionally perform an external action (through the usual -XX: On. Out. Of. Memory. Error=. . . ), e. g. , starting a debugger or notifying an external monitoring system about the failure. 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 17

JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental) - Goals http: //cr. openjdk.

JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental) - Goals http: //cr. openjdk. java. net/~pliden/slides/ZGC-FOSDEM-2018. pdf 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 18

JEP 333: ZGC: - Non Goals no rose without thorns It is not a

JEP 333: ZGC: - Non Goals no rose without thorns It is not a goal to provide working implementations for platforms other than Linux/x 64. Support for additional platforms can be added later, if there is enough demand. „We have strong ambitions to meet these goals for a large set of relevant workloads. At the same time, we want to acknowledge that we don't see these goals as hard requirements for every conceivable workload. ” 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 19

ZGC at a Glance Concurent Tracing Compacting Single generation 2018 -11 -22 Region-based NUMA-aware

ZGC at a Glance Concurent Tracing Compacting Single generation 2018 -11 -22 Region-based NUMA-aware Load barriers Colored pointers 116. Wroclaw. JUG Java 11 Lightning talks 20

ZGC at a Glance ZGC pause Times do not increase with the heap or

ZGC at a Glance ZGC pause Times do not increase with the heap or liveset size ZGC pause Times do increase with the root-set size 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 21

JEP 333: ZGC - Performance ZGC max-j. OPS: 100. 0% critical-j. OPS: 76. 1%

JEP 333: ZGC - Performance ZGC max-j. OPS: 100. 0% critical-j. OPS: 76. 1% 2018 -11 -22 vs. G 1 max-j. OPS: 91. 2% critical-j. OPS: 54. 7% 116. Wroclaw. JUG Java 11 Lightning talks 22

JEP 333: ZGC - Latency ZGC avg: 1. 091 ms (+/-0. 215 ms) 95

JEP 333: ZGC - Latency ZGC avg: 1. 091 ms (+/-0. 215 ms) 95 th percentile: 1. 380 ms 99 th percentile: 1. 512 ms 99. 9 th percentile: 1. 663 ms 99. 99 th percentile: 1. 681 ms max: 1. 681 ms 2018 -11 -22 G 1 vs. avg: 156. 806 ms (+/-71. 126 ms) 95 th percentile: 316. 672 ms 99 th percentile: 428. 095 ms 99. 9 th percentile: 543. 846 ms 99. 99 th percentile: 543. 846 ms max: 116. Wroclaw. JUG Java 11 Lightning talks 543. 846 ms 23

Using ZGC • Enable: -XX: +Unlock. Experimental. VMOptions -XX: +Use. ZGC • Tuning: Set

Using ZGC • Enable: -XX: +Unlock. Experimental. VMOptions -XX: +Use. ZGC • Tuning: Set Max Heap Size: -Xmx<size> Set Number of Concurrent GC Threads -XX: Conc. CGThreads=<number> 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 24

Sources of knowledge: • • https: //docs. oracle. com/en/javase/11/ https: //docs. oracle. com/javase/specs/jvms/se 8/html/index.

Sources of knowledge: • • https: //docs. oracle. com/en/javase/11/ https: //docs. oracle. com/javase/specs/jvms/se 8/html/index. html http: //www. fasterj. com/articles/oraclecollectors 1. shtml http: //cr. openjdk. java. net/~pliden/slides/ZGC-FOSDEM-2018. pdf http: //openjdk. java. net/projects/zgc/ https: //youtu. be/LCr 3 Xy. Hda. Zk - WJUG #167 - Garbage Collector w pigułce - JK https: //youtu. be/k. F_r 3 GE 3 z. Oo - ZGC: A Scalable Low-Latency Garbage Collector • https: //www. oracle. com/technetwork/tutorials-1876574. html 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 25

ZGC Project – Sources Code • Latest Stable: http: //hg. openjdk. java. net/jdk •

ZGC Project – Sources Code • Latest Stable: http: //hg. openjdk. java. net/jdk • Bleeding Edge: http: //hg. openjdk. java. net/zgc 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 26

Conclusions • From Java 9, the default GC algorithm is Garbage First • Two

Conclusions • From Java 9, the default GC algorithm is Garbage First • Two experimental GC Epsilon and ZGC were added in Java 11 • ZGC announces the acceleration of works on Garbage Collectors algorithms. 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 27

Bonus: this can be measured : ) Flight. Recorder + JMC https: //github. com/Robert.

Bonus: this can be measured : ) Flight. Recorder + JMC https: //github. com/Robert. Pod/Java 11 GC 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 28

Dziękuję! Robert Podsiadły • Email: robert@podsiadly. eu • Twitter: @robert 59 p • Blog:

Dziękuję! Robert Podsiadły • Email: robert@podsiadly. eu • Twitter: @robert 59 p • Blog: https: //226. pl • https: //github. com/Robert. Pod 2018 -11 -22 116. Wroclaw. JUG Java 11 Lightning talks 29