Top Banner
@sjmaple #VoxxedBerlin IS YOUR PROFILER SPEAKING THE SAME LANGUAGE AS YOU? SIMON MAPLE @SJMAPLE
56

Voxxed berlin2016profilers|

Feb 17, 2017

Download

Software

Grzegorz Duda
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Voxxed berlin2016profilers|

@sjmaple#VoxxedBerlin

IS YOUR PROFILER SPEAKING THE SAME LANGUAGE AS YOU?

SIMON MAPLE @SJMAPLE

Page 2: Voxxed berlin2016profilers|

2

Page 3: Voxxed berlin2016profilers|

PERFORMANCE PIPELINE

Page 4: Voxxed berlin2016profilers|

Placeholder TexttopicName

Page 5: Voxxed berlin2016profilers|

Placeholder TexttopicName

Page 6: Voxxed berlin2016profilers|

Placeholder TexttopicName

Page 7: Voxxed berlin2016profilers|

PERFORMANCE PIPELINE

Page 8: Voxxed berlin2016profilers|

8

source: http://zeroturnaround.com/rebellabs/developer-productivity-report-2015-java-performance-survey-results/

Page 9: Voxxed berlin2016profilers|

9

1. Functionality - MAKE IT WORK 2. Quality - MAKE IT WORK WELL 3. Performance - MAKE IT WORK FAST 4. Security - MAKE IT WORK SECURELY

THE SOFTWARE MANTRA

Page 10: Voxxed berlin2016profilers|

10

1. Functionality - MAKE IT WORK 2. Quality - MAKE IT WORK WELL 3. Performance - MAKE IT WORK FAST 4. Security - MAKE IT WORK SECURELY

THE SOFTWARE MANTRA

Page 11: Voxxed berlin2016profilers|

11

TOP 5 PERFORMANCE ISSUES

source: http://zeroturnaround.com/rebellabs/developer-productivity-report-2015-java-performance-survey-results/

Page 12: Voxxed berlin2016profilers|
Page 13: Voxxed berlin2016profilers|

13

Reactive - Wait until an issue occurs, then resolve it as quickly as possible.

Proactive - prevent POTENTIAL issues from EVER occurring.

REACTIVE OR PROACTIVE?

Page 14: Voxxed berlin2016profilers|

PROFILING

CPU

TRACING SAMPLING

MEMORY

USAGE ALLOCATION

WHAT DOES PROFILING COVER?

Page 15: Voxxed berlin2016profilers|

PROFILING

CPU

TRACING SAMPLING

MEMORY

USAGE ALLOCATION

WHAT DOES PROFILING COVER?

Page 16: Voxxed berlin2016profilers|

WHAT IS A SAMPLE?

Page 17: Voxxed berlin2016profilers|

THREAD DUMP: CTRL+BREAK ON WINDOWS KILL -3 PID ON *NIX

"http-nio-8080-exec-1" #40 daemon prio=5 os_prio=31 tid=0x00007fd7057ed800 nid=0x7313 runnable java.lang.Thread.State: RUNNABLE at o.s.s.p.w.OwnerController.processFindForm(OwnerController.java:89) at s.r.NativeMethodAccessorImpl.invoke0(Native Method) at s.r.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at s.r.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at j.l.r.Method.invoke(Method.java:497)

WHAT IS A SAMPLE?

Page 18: Voxxed berlin2016profilers|

18

Page 19: Voxxed berlin2016profilers|

19

Page 20: Voxxed berlin2016profilers|

SAMPLING INTERVAL: 20MS

SAMPLE COUNT: 4

Page 21: Voxxed berlin2016profilers|

SAMPLING INTERVAL: 1MS

SAMPLE COUNT: 100+

Page 22: Voxxed berlin2016profilers|

SAMPLING

main()foo()bar()

KeyserSöze()

Page 23: Voxxed berlin2016profilers|

23

SAFEPOINTS

Page 24: Voxxed berlin2016profilers|

SAMPLING

main()foo()bar()

KeyserSöze()

Page 25: Voxxed berlin2016profilers|

SAFEPOINT BIAS

SAFEPOINTS

main()foo()bar()

KeyserSöze()

Page 26: Voxxed berlin2016profilers|

SAFEPOINT BIAS

SAFEPOINTS

main()foo()bar()

KeyserSöze()

Page 27: Voxxed berlin2016profilers|

CAN IT BE TAMED?

Page 28: Voxxed berlin2016profilers|

TAMING SAFEPOINT BIASJava Mission Control

Proprietary protocol Java 7u40

Honest Profiler JVMTI AsyncGetCallTrace

https://github.com/RichardWarburton/honest-profiler

Page 29: Voxxed berlin2016profilers|

JAVA.UTIL IS HOT?

Page 30: Voxxed berlin2016profilers|

java.util is hot? :)

Page 31: Voxxed berlin2016profilers|
Page 32: Voxxed berlin2016profilers|
Page 33: Voxxed berlin2016profilers|
Page 34: Voxxed berlin2016profilers|

34

TRACING (INSTRUMENTATION)

Page 35: Voxxed berlin2016profilers|

publicvoidbusinessMethod(){longstart=System.currentTimeMillis();work();Profiler.log(System.currentTimeMillis()-start);}

TRACING

Page 36: Voxxed berlin2016profilers|

publicvoidbusinessMethod(){longstart=System.nanoTime();work();Profiler.log(System.nanoTime()-start);}

TRACING

Page 37: Voxxed berlin2016profilers|

publicvoidbusinessMethod(){Profiler.start(“businessMethod”);try{work();}finally{Profiler.log("businessMethod");}}

TRACING

Page 38: Voxxed berlin2016profilers|

SYSTEM.NANOTIMESYSTEM.CURRENTTIMEMILLISPARALLEL THREAD

SLEEP-WAKEUP-UPDATEYIELD-WAKEUP-UPDATEBUSY-LOOP-UPDATE

TIMING

Page 39: Voxxed berlin2016profilers|

classProfiler{Looploop;publicstaticvoidstart(Stringmethod){longnow=loop.getTime();…}

Page 40: Voxxed berlin2016profilers|

publicclassLoopimplementsRunnable{privatevolatilelongtime;publicvoidrun(){while(running){time=System.nanoTime();sleep();}}

publicfinallonggetTime(){returntime;}

Page 41: Voxxed berlin2016profilers|

NANO SECONDSReading memory is not free. It takes cycles = nanoseconds

Each (software) layer is not free. JVM, JNI, OS, HW

http://shipilev.net/blog/2014/nanotrusting-nanotime/

Nanotrusting the NanoTime

Page 42: Voxxed berlin2016profilers|

NANO SECONDS PUT INTO PERSPECTIVE GRANULARITY_NANOTIME: 26.300 +- 0.205 NS LATENCY_NANOTIME: 25.542 +- 0.024 NS

GRANULARITY_NANOTIME: 29.322 +- 1.293 NS LATENCY_NANOTIME: 29.910 +- 1.626 NS

GRANULARITY_NANOTIME: 371.419 +- 1.541 NS LATENCY_NANOTIME: 14.415 +- 0.389 NS

LINUX

SOLARIS

WINDOWS

http://shipilev.net/blog/2014/nanotrusting-nanotime/

Nanotrusting the NanoTime

Page 43: Voxxed berlin2016profilers|

SLEEP TIMER: TIME-SLICING & SCHEDULINGMINIMUM SLEEP TIMES:

Win8: 1.7 ms (1.0 ms using JNI + socket poll)Linux: 0.1 msOS X: 0.05 msVirtualBox + Linux: don’t ask :)Still uses 25-50% of CPU core

YIELD?Windows scheduler skips yielded threads in case of CPU starvation

Page 44: Voxxed berlin2016profilers|

publicclassLoopimplementsRunnable{privatevolatilelongtime;publicvoidrun(){while(running){time=System.nanoTime();sleep();}}privatevoidsleep(){if(!MiscUtil.isWindows()){Thread.yield();}}

Page 45: Voxxed berlin2016profilers|

publicclassLoopimplementsRunnable{privatevolatilelongtime;publicvoidrun(){while(running){time=System.nanoTime();sleep();}}privatevoidsleep(){if(!MiscUtil.isWindows()){Thread.yield();}}

Page 46: Voxxed berlin2016profilers|

publicclassLoopimplementsRunnable{privatevolatilelongtime;publicvoidrun(){while(running){time=System.nanoTime();sleep();}}privatevoidsleep(){if(!MiscUtil.isWindows()){Thread.yield();}}

Page 47: Voxxed berlin2016profilers|

publicclassLoopimplementsRunnable{privatevolatilelongtime;publicvoidrun(){while(running){time=System.nanoTime();sleep();}}privatevoidsleep(){if(!MiscUtil.isWindows()){Thread.yield();}...}

Page 48: Voxxed berlin2016profilers|

main()foo()bar()baz()

TRACING

Page 49: Voxxed berlin2016profilers|

main()foo()

bar()baz()

234

TRACING

Page 50: Voxxed berlin2016profilers|

main()foo()

bar()baz()

235

boo()

TRACING

Page 51: Voxxed berlin2016profilers|
Page 52: Voxxed berlin2016profilers|
Page 53: Voxxed berlin2016profilers|

53

THE PIPELINE

Page 54: Voxxed berlin2016profilers|

INTRODUCING…

Page 55: Voxxed berlin2016profilers|

55

FREE STUFF!

0t.ee/voxxedberlin16

Page 56: Voxxed berlin2016profilers|

@sjmaple#VoxxedBerlin

QUESTIONS?

SIMON MAPLE @SJMAPLE

VIRTUAL JUG FOUNDER

LONDON JUG CO-LEADER

JAVA CHAMPION

JAVAONE ROCKSTAR

REBELLABS AUTHOR