Slide 1

Slide 1 text

IS YOUR PROFILER SPEAKING THE SAME LANGUAGE AS YOU? SIMON MAPLE @SJMAPLE

Slide 2

Slide 2 text

ABOUT ME SIMON MAPLE @SJMAPLE

Slide 3

Slide 3 text

SIMON MAPLE @SJMAPLE VIRTUAL JUG FOUNDER LONDON JUG CO-ORGANISER JAVA CHAMPION JAVAONE ROCKSTAR SPEAKER REBELLABS AUTHOR ABOUT ME

Slide 4

Slide 4 text

4 MONITORING TOOLS

Slide 5

Slide 5 text

PROFILERS 5

Slide 6

Slide 6 text

TESTING TOOLS 6

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

RebelLabs reports 8

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

APPLICATION PERFORMANCE 12

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

PROFILING CPU TRACING SAMPLING MEMORY USAGE ALLOCATION WHAT DOES PROFILING COVER?

Slide 16

Slide 16 text

PROFILING CPU TRACING SAMPLING MEMORY USAGE ALLOCATION WHAT DOES PROFILING COVER?

Slide 17

Slide 17 text

WHAT IS A SAMPLE?

Slide 18

Slide 18 text

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?

Slide 19

Slide 19 text

19

Slide 20

Slide 20 text

20

Slide 21

Slide 21 text

SAMPLING INTERVAL: 20MS SAMPLE COUNT: 4

Slide 22

Slide 22 text

SAMPLING INTERVAL: 1MS SAMPLE COUNT: 100+

Slide 23

Slide 23 text

SAMPLING main() foo() bar() KeyserSöze()

Slide 24

Slide 24 text

24 SAFEPOINTS

Slide 25

Slide 25 text

SAMPLING main() foo() bar() KeyserSöze()

Slide 26

Slide 26 text

SAFEPOINT BIAS SAFEPOINTS main() foo() bar() KeyserSöze()

Slide 27

Slide 27 text

SAFEPOINT BIAS SAFEPOINTS main() foo() bar() KeyserSöze()

Slide 28

Slide 28 text

CAN IT BE TAMED?

Slide 29

Slide 29 text

TAMING SAFEPOINT BIAS Java Mission Control Proprietary protocol Java 7u40 Honest Profiler JVMTI AsyncGetCallTrace https://github.com/RichardWarburton/honest-profiler

Slide 30

Slide 30 text

JAVA.UTIL IS HOT?

Slide 31

Slide 31 text

java.util is hot? :)

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

34 TRACING (INSTRUMENTATION)

Slide 35

Slide 35 text

public  void  businessMethod()  {
    long  start  =  System.currentTimeMillis();   
    work();   
    Profiler.log(System.currentTimeMillis()-­‐start);   } TRACING

Slide 36

Slide 36 text

public  void  businessMethod()  {
    long  start  =  System.nanoTime();   
    work();   
    Profiler.log(System.nanoTime()-­‐start);
 } TRACING

Slide 37

Slide 37 text

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

Slide 38

Slide 38 text

SYSTEM.NANOTIME SYSTEM.CURRENTTIMEMILLIS PARALLEL THREAD SLEEP-WAKEUP-UPDATE YIELD-WAKEUP-UPDATE BUSY-LOOP-UPDATE TIMING

Slide 39

Slide 39 text

class  Profiler  {   
    Loop  loop;
 
    public  static  void  start(String  method)  {
        long  now  =  loop.getTime();          …
    }  

Slide 40

Slide 40 text

public  class  Loop  implements  Runnable  {
        private  volatile  long  time;
        public  void  run()  {
                while  (running)  {
                        time  =  System.nanoTime();
                        sleep();
                }
        }          public  final  long  getTime()  {
                return  time;
        }  

Slide 41

Slide 41 text

NANO SECONDS Reading 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

Slide 42

Slide 42 text

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

Slide 43

Slide 43 text

SLEEP TIMER: TIME-SLICING & SCHEDULING MINIMUM SLEEP TIMES: Win8: 1.7 ms (1.0 ms using JNI + socket poll) Linux: 0.1 ms OS X: 0.05 ms VirtualBox + Linux: don’t ask :) Still uses 25-50% of CPU core YIELD? Windows scheduler skips yielded threads in case of CPU starvation

Slide 44

Slide 44 text

public  class  Loop  implements  Runnable  {
        private  volatile  long  time;
        public  void  run()  {
                while  (running)  {
                        time  =  System.nanoTime();
                        sleep();
                }
        }          private  void  sleep()  {
            if  (!MiscUtil.isWindows())  {
                  Thread.yield();
            }
        }

Slide 45

Slide 45 text

public  class  Loop  implements  Runnable  {
        private  volatile  long  time;
        public  void  run()  {
                while  (running)  {
                        time  =  System.nanoTime();
                        sleep();
                }
        }          private  void  sleep()  {
            if  (!MiscUtil.isWindows())  {
                  Thread.yield();
            }
        }

Slide 46

Slide 46 text

public  class  Loop  implements  Runnable  {
        private  volatile  long  time;
        public  void  run()  {
                while  (running)  {
                        time  =  System.nanoTime();
                        sleep();
                }
        }          private  void  sleep()  {
            if  (!MiscUtil.isWindows())  {
                  Thread.yield();
            }
        }

Slide 47

Slide 47 text

public  class  Loop  implements  Runnable  {
        private  volatile  long  time;
        public  void  run()  {
                while  (running)  {
                        time  =  System.nanoTime();
                        sleep();
                }
        }          private  void  sleep()  {
            if  (!MiscUtil.isWindows())  {
                  Thread.yield();
            }
        }

Slide 48

Slide 48 text

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

Slide 49

Slide 49 text

main() foo() bar() baz() 2 3 4 TRACING

Slide 50

Slide 50 text

main() foo() bar() baz() 2 3 5 boo() TRACING

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

PERFORMANCE PIPELINE

Slide 54

Slide 54 text

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

Slide 55

Slide 55 text

55 1. Functionality 2. Quality 3. Performance 4. Security THE SOFTWARE MANTRA

Slide 56

Slide 56 text

56 1. Functionality 2. Quality 3. Performance 4. Security THE SOFTWARE MANTRA

Slide 57

Slide 57 text

57 1. Functionality - MAKE IT WORK 2. Quality 3. Performance 4. Security THE SOFTWARE MANTRA

Slide 58

Slide 58 text

58 1. Functionality - MAKE IT WORK 2. Quality - MAKE IT WORK WELL 3. Performance 4. Security THE SOFTWARE MANTRA

Slide 59

Slide 59 text

59 1. Functionality - MAKE IT WORK 2. Quality - MAKE IT WORK WELL 3. Performance - MAKE IT WORK FAST 4. Security THE SOFTWARE MANTRA

Slide 60

Slide 60 text

60 1. Functionality - MAKE IT WORK 2. Quality - MAKE IT WORK WELL 3. Performance - MAKE IT WORK FAST 4. Security - ? ? ? ? ? ? ? ? THE SOFTWARE MANTRA

Slide 61

Slide 61 text

61 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

Slide 62

Slide 62 text

62 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

Slide 63

Slide 63 text

63 TOP 5 PERFORMANCE ISSUES source: http://zeroturnaround.com/rebellabs/developer-productivity-report-2015-java-performance-survey-results/

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

65 Reactive - Wait until an issue occurs, then resolve it as quickly as possible. Proactive - prevent POTENTIAL issues from EVER occurring. REACTIVE OR PROACTIVE?

Slide 66

Slide 66 text

66 THE PIPELINE

Slide 67

Slide 67 text

INTRODUCING…

Slide 68

Slide 68 text

68 FREE STUFF! 0t.ee/javaone-jr 0t.ee/javaone-xr

Slide 69

Slide 69 text

No content