New Java performance developments: compilation and garbage ... · New Java performance...

83
New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17

Transcript of New Java performance developments: compilation and garbage ... · New Java performance...

Page 1: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

New Java performance developments:

compilation and garbage collection

Jeroen Borgers

@jborgers

#jfall17

Page 2: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com2

Part 1: New in Java compilation

Part 2: New in Java garbage collection

Page 3: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com3

Part 1New in Java compilation

Page 4: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

New in Java compilation•Compilation basics for the JVM

•AOT-compilation added

•Advantages of AOT-compilation

•Examples using AOT

•Current limitations

•Conclusions4

Page 5: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

Java compilation basics

interpretation and JIT-compilation in the JVM

Page 6: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Interpretation versus compilation

6

.php file

interpreter

compiler

OSHardware

each line

.pl file

.cpp file

native code

executable file

Page 7: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Interpretation versus compilation

7

.php file

interpreter

compiler

OSHardware

each line

.pl file

.cpp file

native code

executable file

• exe non-portable • optimizations • faster execution

• portable source code

Page 8: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

JVM: Interpretation and JIT-compilation

8

.java file .class file

JVM

javac

interpreter JIT-compiler

OSHardware

native code

byte code: portable

Page 9: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com9

.java file .class file

JVM

javac

interpreter JIT-compiler

OSHardware

code cache

each line method

native code

byte code

JVM: Interpretation and JIT-compilation

Page 10: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Profile guided JIT-compilation

10

.java file .class file

JVM

javac

interpreter JIT-compiler

OSHardware

code cache

hot

native code

byte code

profilingmethod

Page 11: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Profile guided JIT-compilation with adaptive optimizations

11

.class file

JVM

interpreter JIT-compiler

OSHardware

code cache

hot

native code

byte code

profilingmethod

• focus on hot code: • speculatively optimize • method inlining • branch prediction • loop unrolling • de-optimization

Page 12: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

C1: client or C2: server compiler

12

.class file

JVM

interpreter client - C1

code cache

byte code

server - C2

hotprofiling

hot: > C1:1500 > C2:10.000 invocations + iterations

C1: quick startupC2: best performance eventually by more optimizations

Page 13: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Tiered compilation: Best of C1 and C2 default in Java 8

13

JVM

interpreter client - C1

code cache

server - C2

hotprofiling

hotter

profiling

.class file

byte code

C1: quick startupC2: best performance eventually by more optimizations

Page 14: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

interpretation versus compilation flags

•-Xint

•-Xcomp

•-Xmixed•JIT-compilation

•default14

Page 15: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Java 9 test code: HelloJUG

15

Page 16: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

HelloJUG Which is quickest?

16

java HelloJUGjava -Xcomp HelloJUGjava -Xint HelloJUG

Page 17: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

HelloJUG Real times, average of 5 runs

17

java HelloJUG 252 ms

java -Xcomp … 2272 ms

java -Xint … 214 ms

Page 18: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Tiered compilation levels

18

Interpreter C2no profiling profilingprofiling

C1 C1

Level 0common

no profiling

code speed 1 10 7 14

Level 3 Level 4

Level 0stop at L1 Level 1

hot hotter

hot

Page 19: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

HelloJUG Real times, average of 5 runs

19

java HelloJUG 252 ms

java -Xcomp … 2272 ms

java -Xint … 214 ms

java -XX:TieredStopAtLevel=1… 244 ms

Page 20: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

AOT-compilation added

20

.class filebyte code

JVM interpreter JIT-compiler

native code

Page 21: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

AOT-compilation added

21

JVM

native code

.class filebyte code

jaotc

libY.so file

-XX:AOTLibrary=

Graal libelf

native code non-portable

interpreter JIT-compiler

Page 22: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

AOT in 2 flavors: tiered (with JIT) and non-tiered (no JIT)

22

.class filebyte code

jaotc

libY.so file

-XX:AOTLibrary=

Graal libelf

native code

JVM AOT code

native code

JIT-compiler

Page 23: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Non-tiered AOT-compilation: no JIT

23

.class filebyte code

jaotc

libY.so file

-XX:AOTLibrary=

Graal libelf

native code

JVM AOT code

native code

JIT-compiler

Page 24: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Non-tiered compilation with AOT

24

AOT C2no profiling profilingno profiling

C1 C1

aotcommon

no profilingcode speed 10 7 14

•footprint more important than peak performance

•no JIT-code cache, no compiler threads

•more predictable behavior

•constant speed of code, no JIT-compilation taking CPU

9

Page 25: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

HelloJUG Real times, average of 5 runs

25

java HelloJUG 252 ms

java -Xcomp … 2272 ms

java -Xint … 214 ms

java -XX:TieredStopAtLevel=1… 244 ms

java -XX:AOTLibrary=lib..nont.so… 214 ms

Page 26: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Tiered AOT-compilation

26

.class file

JVMclient - C1

byte code

server - C2

hot

hotter

profiling

jaotclibY.so file

-XX:AOTLibrary=

Graal libelf

native code

AOT code

profilingcode cache

Page 27: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Tiered compilation levels with AOT

27

AOT C2no profiling profilingprofiling

C1 C1

AOTcommon

no profiling

code speed 10 7 14

Level 3 Level 4

9

hot hotter

Page 28: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Why AOT-compilation?•Faster startup time

•compiled/optimized methods immediately available

•JIT optional, for best peak-performance

•Reach peak-performance quicker

•Potentially less memory usage•Class data sharing (CDS)

•No JIT-compiler overhead

•Less CPU usage• less interpreting, profiling, compiling

28

Page 29: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

AOT-compiling HelloJUG

•jaotc

29

Page 30: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Run HelloJUG using AOT with -XX:AOTLibrary=

30

Page 31: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Run HelloJUG using AOT with -XX:AOTLibrary and -XX:PrintAOT

31

Page 32: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

CreateCalendars micro-benchmark Average of 5 runs, 2 CPU’s

32

non-AOT

tiered AOT

non-tiered AOT

-Xint

0 0,5 1 1,5 2 2,5 3real run time (s)C1 timeC2 time

Shorter is better

—> 29 s.

Page 33: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Current limitations

•For JDK 9 only supported on Linux x64•JDK 10 (18.3) also on MacOS and Windows

•No use of profiling data during AOT (yet)

•Only supported for G1 GC and Parallel GC

33

Page 34: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

AOT-compilation conclusions

•Promising technique for quicker startup times

•Most noticeable when user waiting for startup / execution•Short run: non-tiered - without JIT-compiler

•Small devices with little resources

• IDE’s, unit tests, code generation, coding checks, ..

•Can be 10% to 2x better for short execution or startup

•AOT-compile and bundle only touched methods of java.base etc. should help more

• training run in future versions

34

Page 35: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com35

Part 1: New in Java compilation

Part 2: New in Java garbage collection

Page 36: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

Part 2: New garbage collectors

Shenandoah and Epsilon GC

Page 37: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

New garbage collectors•GC basics

•Serial, Parallel, Concurrent GC

•Region based: G1 GC

•Shenandoah GC

•Epsilon GC

•Conclusions37

Page 38: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

Garbage collection basics

Mark&Sweep, Compaction and Mark&Copy

Page 39: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.comwww.jpinpoint.com

Mark and Sweep

39

OOPs

GC-roots (stacks..)

© jPinpoint

Page 40: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.comwww.jpinpoint.com

Mark

40

OOPs

© jPinpoint

GC-roots (stacks..)

Page 41: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.comwww.jpinpoint.com

Sweep

41

OOPs

GC-roots

© jPinpoint

Page 42: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.comwww.jpinpoint.com

Mark-Sweep: Fragmentation

•After compaction:

•Compaction is expensive42

© jPinpoint

Page 43: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Mark-Copy: no fragmentation

43

Page 44: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Generational GC: Young and Old

44

Survivor 1 Old spaceSurvi

vor 2Eden

Mark Sweep - Compact

Mark Copy

Page 45: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Serial GC: stop-the-world pauzes

45

GC thread eg. 7 s.

Page 46: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Serial vs Parallel GC

46

GC thread eg. 7 s.

GC threads eg. 2 s.

Page 47: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Concurrent Mark Sweep GC - mostly concurrent to app

47

GC threads eg. 2x100 ms. STW 10 s. concurrent

Page 48: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

GC threads eg. 2x100 ms. STW 10 s. concurrent

GC threads eg. 2 s.

Parallel GC vs CMS throughput vs responsiveness

48

Page 49: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

GC threads 2x100 ms. STW 10 s. concurrent

GC threads 2 s.

Parallel GC vs CMS Young and Old

49

GC threads 300 ms.

GC threads 300 ms.

Page 50: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

GC threads 2x100 ms. STW 10 s. concurrent

CMS problem 1: failures

50

GC threads 300 ms.

GC thread 7 s.

Concurrent failure

Page 51: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

4 GB heap

16 GB heap

GC threads 2x400 ms. STW 40 s. concurrent

GC threads 1200 ms.

GC thread 28 s.

Concurrent failure

GC GC

GC

Conc

CMS problem 2: not scalable

51

x4

Page 52: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Solution: regionalize

52

Survivor 1 Old spaceSurvi

vor 2Eden

Mark Sweep - Compact

Mark Copy

Page 53: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

G1: Garbage first: young + old with most garbage

53

80%

90% 40%

90%

20% 15% 50%

% %-live objects

Page 54: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

G1: Garbage first: young + old regions with most garbage

80%

90% 40%

90%

20% 15% 50%

•Concurrent mark in Old

•Mark-copy: no fragmentation

•Limit copy #regions to meet-XX:MaxPauseTimeMillis

•Solves scalability and failures

•Still stw pauses54

Page 55: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

RSet

CSet

G1 stw-pauses: Mark young + Copy Y&O

55

Page 56: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.comCSet

RSet

G1 stw-pauses: Mark young + Copy Y&O + Update refs

56

Page 57: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.comCSet

G1 pauses: Mark young + Copy Y&O + Update refs

57

RSet

Page 58: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

Shenandoah GCUltra low pause times

Page 59: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Stw-pause times in G1 how to beat them?

•Mark Young

•Copy Young & Old

•Update refs

59

Page 60: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

pause times in G1 vs Shenandoah

•Mark Young

•Copy Young & Old

•Update refs

60

Page 61: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

removed pause times in Shenandoah

•Mark Young

•Copy Young & Old concurrent

•Update refs concurrent

61

Page 62: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

How to copy Old and update refs concurrently?

62CSet

RSet

Page 63: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

How to copy Old and update refs concurrently?

63CSet

RSet

add

Page 64: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17 All problems in computer science can be solved

by…?Jim Coplien - David Wheeler

Page 65: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Another level of indirection

•forwarding pointer

65

Page 66: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Copy Old and update refs concurrently by fwd pointer

66CSet

Page 67: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Application thread can write objects being evacuated

67CSet

add

Page 68: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Application thread writes to new copy of object

68CSet

add

Page 69: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Concurrent update refs

69CSet

Page 70: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Concurrent cleanup

70CSet

Page 71: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Shenandoah pause times•4 short stw pauses

• init mark, final mark, init UR, final UR

71

GC(3) Pause Init Mark 0.771ms

GC(3) Concurrent marking 76480M->77212M(102400M) 633.213ms

GC(3) Pause Final Mark 1.821ms

GC(3) Concurrent cleanup 77224M->66592M(102400M) 3.112ms

GC(3) Concurrent evacuation 66592M->75640M(102400M) 405.312ms

GC(3) Pause Init Update Refs 0.084ms

GC(3) Concurrent update references 75700M->76424M(102400M) 354.341ms

GC(3) Pause Final Update Refs 0.409ms

GC(3) Concurrent cleanup 76244M->56620M(102400M) 12.242ms

Page 72: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Shenandoah pause times•4 short stw pauses

• init mark, final mark, init UR, final UR

72

GC(3) Pause Init Mark 0.771ms

GC(3) Concurrent marking 76480M->77212M(102400M) 633.213ms

GC(3) Pause Final Mark 1.821ms

GC(3) Concurrent cleanup 77224M->66592M(102400M) 3.112ms

GC(3) Concurrent evacuation 66592M->75640M(102400M) 405.312ms

GC(3) Pause Init Update Refs 0.084ms

GC(3) Concurrent update references 75700M->76424M(102400M) 354.341ms

GC(3) Pause Final Update Refs 0.409ms

GC(3) Concurrent cleanup 76244M->56620M(102400M) 12.242ms

Page 73: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Elastic search benchmark (Oct 2, 2017)

73

Run time (x100 s)

Total pause time (s)

Average (x10 ms)

Max (x100 ms)

0 1 2 3 4 5 6 7 8 9

G1 ShenandoahShorter is better

Page 74: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Parallel GC: max = 161 ms

74

Page 75: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

G1 GC: max = 38 ms

75

Page 76: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Shenandoah GC: max = 5,9 ms

76

Page 77: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

G1 with -XX:MaxGCPauseTimeMillis=6: 29 ms

77

Page 78: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Epsilon GC

•JEP Draft (by Aleksey Shipilev)

•stw pauzes = 0.0 ms!

•How?

78

Page 79: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Epsilon GC

•Garbage non-collector

•JVM shutdown when heap exhausted

•java -XX:+UnlockExperimentalVMOptions XX:+UseEpsilonGC

•Binary builds of patched JDK10 available79

Page 80: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

No-op GC use cases•Performance testing

• compare with real garbage collectors

•Minimize overhead• garbage free apps

• short-lived apps

• active failover before heap exhausted80

Page 81: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Conclusions new GC’s•Shenandoah GC clearly beats G1 for short pauses

•Likely to replace G1 as default after JDK9•Can try it out now on JDK8+!

•Epsilon GC eliminates all GC-overhead (and comfort)• if you can avoid GC

• last-drop performance improvement

81

Page 82: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

#jfall17

www.jpinpoint.com

Questions?•want to learn more?• resources: www.jpinpoint.com

• accelerating Java applications training• covers Java 8 & 9

• 12-14 March 2018

•thanks for the attention!82

Page 83: New Java performance developments: compilation and garbage ... · New Java performance developments: compilation and garbage collection Jeroen Borgers @jborgers #jfall17. #jfall17

“Please rate my talk in the official

J-Fall app”

#jfall17