analysing heap dumps and optimising performance …...performance profiling - profilers ∗a soft...

35
Performance Optimisations Angelo D’ Agnano John Kostaras

Upload: others

Post on 23-Jun-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

Performance Optimisations

Angelo D’ Agnano

John Kostaras

Page 2: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

∗ Performance Monitoring

∗ an activity of nonintrusively collecting or observing performance data from a running application

∗ Performance Profiling

∗ an activity of collecting performance data from a running application that may be intrusive on application performance responsiveness or throughput

∗ Performance Tuning

∗ an activity of changing tuneables, source code, or configuration attribute(s) for the purposes of improving application responsiveness or throughput

15/9/2012 Analysing heap dumps and optimising performance 2

Performance activities

Page 3: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

∗ CPU∗ Graphical

∗ gnome-system-monitor, xosview (Unix/Linux)

∗ cpubar (Solaris)

∗ TaskManager, Performance Monitor (Windows)

∗ Text

∗ vmstat, mpstat, pidstat, top

∗prstat (Solaris)

∗ typeperf (Windows)

15/9/2012 Analysing heap dumps and optimising performance 3

OS Performance Monitoring

Page 4: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

∗Memory∗ vmstat∗ cpubar (Solaris)∗ Performance Monitor, typeperf (Windows)

∗Network∗ nicstat, typeperf (Windows)

∗ I/O∗ iostat, iosnoop.d (Solaris)

∗Other∗ sar (sysstat), kstat (Solaris), cpustat, cputrack

15/9/2012 Analysing heap dumps and optimising performance 4

OS Performance Monitoring(cont.)

Page 5: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

� Method profiler

� Collects information about method execution times

� Look for: internal/external method times, frequently called methods/classes etc.

� Memory profiler

� Collects information about object creation and/or garbage collection

� Thread profiler

� Looks for thread conflict situations

15/9/2012 Analysing heap dumps and optimising performance 5

Performance Profiling -Types of Profilers

Page 6: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

� Method profilers� Oracle Solaris Studio Performance Analyzer, HPJMeter,

JVisualVM� Free: java -agentlib:hprof=[help]|[<option>=<value>, ...], jvmstat,

JRockit Runtime Analyzer� Commercial: JProbe, OptimizeIt!, JProfiler, YourKit

� Memory profilers� Oracle Solaris Studio Performance Analyzer� HPJMeter� JVisualVM

� Thread profilers� JVisualVM� Google’s JChord, Java Race Finder, Mutability Detector, YourKit

15/9/2012 Analysing heap dumps and optimising performance 6

Performance Profiling -Profilers

Page 7: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

∗A soft real-time Java application based on NetBeans RCP

∗Displays plots and tracks on a digital map

∗Requirement to run on SunBlade 1500 (1 CPU 1.062 GHz UltraSPARC, 1 GB RAM)

A few things about the application to optimise

15/9/2012 Analysing heap dumps and optimising performance 7

Page 8: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

1) Research of root causes∗ Analysis of GC impact∗ Verification of lock contention∗ Hotspots in application code

2) Profile main branch application3) Identification of hotspots4) Optimisation of hotspots5) Performance measurement with & without

changes6) Integration of changes7) Restart from point 1

15/9/2012 Analysing heap dumps and optimising performance 8

Steps executed

Page 9: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

CPU Performance Monitoring

15/9/2012 Analysing heap dumps and optimising performance 9

Page 10: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

15/9/2012 Analysing heap dumps and optimising performance 10

Monitoring Results of Main branchNothing displayed CPU: 27%

cpubar

gnome-system-monitor

Page 11: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

15/9/2012 Analysing heap dumps and optimising performance 11

Monitoring Results of Main branchPlots & tracks with labels displayed CPU: 64%

Page 12: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

CPU Performance Profiling

15/9/2012 Analysing heap dumps and optimising performance 12

Page 13: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

15/9/2012 Analysing heap dumps and optimising performance 13

Identification of Hotspot 1Exclusive & inclusive user

CPU utilisation metrics

Page 14: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

15/9/2012 Analysing heap dumps and optimising performance 14

Identification of Hotspot 2

Page 15: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

15/9/2012 Analysing heap dumps and optimising performance 15

Details of Hotspot 2

Page 16: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

15/9/2012 Analysing heap dumps and optimising performance 16

Details of Hotspot 2 (cont.)

Page 17: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

15/9/2012 Analysing heap dumps and optimising performance 17

Details of Hotspot 2 (cont.)

Page 18: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

15/9/2012 Analysing heap dumps and optimising performance 18

Identification of Hotspot 2 (cont.)

Page 19: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

CPU Performance Tuning

15/9/2012 Analysing heap dumps and optimising performance 19

Page 20: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

15/9/2012 Analysing heap dumps and optimising performance 20

Performance before the changes CPU: 60%

Page 21: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

15/9/2012 Analysing heap dumps and optimising performance 21

Performance after the changes CPU: 50%

Page 22: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

15/9/2012 Analysing heap dumps and optimising performance 22

Profiling comparison 1

Page 23: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

15/9/2012 Analysing heap dumps and optimising performance 23

Profiling comparison 2

Page 24: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

Memory Performance Profiling/Tuning

Goal is not to improve the CPU usage but to mitigate the impact of the GC on the real-time behaviour of the application

15/9/2012 Analysing heap dumps and optimising performance 24

Page 25: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

New Generation GCs Old Generation GCs

Copying collector (< Java 5)-XX:+UseSerialGC

Mark-Sweep collector (< Java 5)-XX:+UseSerialGC

Parallel copying collector (≥ Java 5)-XX:+UseParNewGC

Parallel Scavenge MarkSweep collector-XX:+UseParallelOldGC

Parallel scavenge collector (≥ Java 5,

>10GB heap space)-XX:+UseParallelGC

Concurrent Mark Sweep collector

(≥ Java 6)-XX:+UseConcMarkSweepGC

G1 young generation (≥ Java 7)-XX:+UseG1GC

G1 mixed generation (≥ Java 7)-XX:+UseG1GC

15/9/2012 Analysing heap dumps and optimising performance 25

Generational Spaces &Garbage Collectors

Eden S1 S2 Tenured

New Generation

Permanent

Old Generation

Page 26: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

� -Xmx = -Xms

� –XX:PermSize = –XX:MaxPermSize

� Use -Xmn instead of –XX:NewSizeand –XX:MaxNewSize

� Disable adaptive sizing of generations –XX:-UseAdaptiveSizePolicy

if –XX:SurvivorRatio is specified

� Use –XX:+UseConcMarkSweepGC

� 40<–XX:CMSInitiatingOccupancyFraction<70

and always use –XX:+UseCMSInitiatingOccupancyOnly with it

15/9/2012 Analysing heap dumps and optimising performance 26

Recommended Settingshttp://randomlyrr.blogspot.be/2012/03/java-tuning-in-nutshell-part-1.html

Page 27: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

run.args.extra =

-Xms256m -Xmx768m -Xincgc

-XX:+UseConcMarkSweepGC

-XX:SurvivorRatio=3

–XX:-UseAdaptiveSizePolicy

-XX:CMSInitiatingOccupancyFraction=60

–XX:+UseCMSInitiatingOccupancyOnly

15/9/2012 Analysing heap dumps and optimising performance 27

Application’s Runtime arguments

Max heap size

Init heap size

Eden=76,8 Mb, S1,S2= 25,6 Mb

CMS: Concurrent MarkSweep

Page 28: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

15/9/2012 Analysing heap dumps and optimising performance 28

HPJMeter

Page 29: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

15/9/2012 Analysing heap dumps and optimising performance 29

HPJMeter

Page 30: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

15/9/2012 Analysing heap dumps and optimising performance 30

HPJMeter

Page 31: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

15/9/2012 Analysing heap dumps and optimising performance 31

HPJMeter

Page 32: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

15/9/2012 Analysing heap dumps and optimising performance 32

HPJMeter

Page 33: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

Thread Profiling/Tuning?

15/9/2012 Analysing heap dumps and optimising performance 33

Page 34: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

∗ Hunt C. & John B. (2011), Java Performance, Prentice Hall

∗ Kabutz H. (2011), Java Master’s course slides

∗ http://www.youtube.com/watch?v=VGQAL9aUKfs∗ http://randomlyrr.blogspot.be/2012/03/java-tuning-

in-nutshell-part-1.html∗ http://www.fasterj.com/articles/oraclecollectors1.sh

tml∗ http://www.oracle.com/technetwork/java/javase/te

ch/vmoptions-jsp-140102.html

15/9/2012 Analysing heap dumps and optimising performance 34

References

Page 35: Analysing heap dumps and optimising performance …...Performance Profiling - Profilers ∗A soft real-time Java application based on NetBeansRCP ∗Displays plots and tracks on a

Questions

15/9/2012 35Analysing heap dumps and optimising performance

?