Your SlideShare is downloading. ×
0
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Diagnosing Your Application on the JVM

1,111

Published on

Presentation from JavaOne 2013

Presentation from JavaOne 2013

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,111
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
65
Comments
0
Likes
4
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  1. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.1
  2. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.2 Diagnosing Your Application on the JVM Staffan Larsen Java SE Serviceability Architect staffan.larsen@oracle.com @stalar
  3. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.3 The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle s products remains at the sole discretion of Oracle.
  4. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.4 404 – Not Found java.security.AccessControlException: access denied ("java.lang.management.ManagementPermission" "control") at java.security.AccessControlContext.checkPermission(AccessControlContext.java:364) at java.security.AccessController.checkPermission(AccessController.java:555) at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) at oracle.jrockit.jfr.JFR.checkControl(JFR.java:43) at oracle.jrockit.jfr.RepositoryChunk.<init>(RepositoryChunk.java:68) at Demo$1.<init>(Demo.java:14) at Demo.start(Demo.java:14) at sun.applet.AppletPanel.run(AppletPanel.java:474) at java.lang.Thread.run(Thread.java:722)
  5. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.5 jcmd jps jvisualvm jinfo jmap jstack jstatd JMX perf counters attach jstat serviceability agent java flight recorder java mission control
  6. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.6
  7. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.7 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Agenda §  Demos, walk-through §  Internals §  Future
  8. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.8
  9. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.9 Demo Recap §  jps – list processes §  jcmd – send Diagnostic Commands –  VM.version –  Thread.print –  GC.class_histogram –  GC.heap_dump §  jstat – see performance counters §  Java Mission Control §  Java Flight Recorder
  10. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.10 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Agenda §  Demos, walk-through §  Internals §  Future
  11. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.11 Remote Access §  JMX –  jmc,  jvisualvm,  jconsole   –  Access information from java.lang.management MBeans –  SSL and authentication –  Enable startup: -­‐Dcom.sun.management.jmxremote   –  Enable runtime: jcmd  ManagementAgent.start   §  jstatd   –  Daemon that runs on remote machine –  jstat can connect to daemon
  12. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.12 Discovery – what is running? §  Well-known file for each JVM –  <temp>/hsperfdata_<user>/<pid>   –  /tmp/hsperfdata_staffan/3636   §  Created on JVM startup §  Deleted on JVM shutdown §  Unused files deleted on startup
  13. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.13 Java Discovery Protocol §  Java process will broadcast presence –  Every 5 seconds §  Broadcast package contains –  Main class name –  Unique id –  JMX service URL -­‐Dcom.sun.management.jmxremote.autodiscovery=true   jcmd  ManagementAgent.start  jdp.port=<port>   From freedigitalphotos.net/by digitalart 7u40
  14. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.14 Attach – talking to the JVM §  Allows sending “commands” for execution in the JVM §  Receive text output §  Local access by same user only §  Used by jcmd,  jstack,  jmap,  jinfo   §  Mechanics differ on platforms
  15. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.15 Attach: Linux / BSD / Solaris §  Create file /tmp/.attach_pid<pid>   §  Send SIGQUIT to JVM §  JVM looks for /tmp/.attach_pid<pid>   –  If not found a normal thread dump is done §  JVM will create socket: /tmp/.java_pid<pid>   §  Use socket for communication §  Solaris uses door API instead of sockets
  16. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.16 Attach: Windows §  Remote process injects code (!) into the JVM –  VirtualAllocEx  /  WriteProcessMemory   §  Remote process creates a thread in the JVM to call the code –  CreateRemoteThread   §  The code dynamically looks up JVM_EnqueueOperation() and calls it §  Reads result from a pipe
  17. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.17 Diagnostic Commands §  Helper routines inside the JVM §  Text output §  Executed via the jcmd utility –  soon JMX §  Self-describing help facility §  Different set of commands for different JVM versions JDK 8
  18. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.18 jvmstat / PerfCounter §  /tmp/hsperfdata_staffan/3636   –  Contains a lot of run-time information about the JVM §  Memory mapped file §  Updated continuously by JVM §  Use jstat to show information in readable form §  Use "jcmd  PerfCounter.print" to see raw contents
  19. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.19 Monitored JVM attach j* JMX jstat RMI JMX client JMX attach Mission Control VisualVM JConsole jcmd jstack jmap jinfo Accessing the JVM dcmd JVM jvmstat jstat(d)
  20. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.20 Communicating with the JVM Local access Remote access Two-way core files attach ✔ ✔ jvmstat ✔ JMX ✔ ✔ jstatd ✔ SA ✔ (✔) ✔
  21. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.21 attach JMX jvmstat jstatd RemoteLocal Two-way One-way Communicating with the JVM
  22. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.22 Serviceability Agent §  For core-files or non-responsive JVMs §  Uses debugger to read information §  Last resort - suspends process in unknown state jstack  <executable>  <core>   jstack  –F  <pid>  
  23. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.23 Monitored JVM JVMj* SA jstack jmap jinfo debugger vmSymbols Accessing the JVM
  24. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.24 Java Flight Recorder §  JVM-built-in profiler and tracer §  Non-intrusive §  Always-on §  Captures both JVM and application data –  GC, Locks, Compiler, Exceptions, CPU Usage, I/O, … §  After-the-fact analysis §  Circular buffers New! Photograph by Jeffrey Milstein http://butdoesitfloat.com/In-the-presence-of-massive-gravitational-fields-this-perfect
  25. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.25 JVM JFR: How Is It Built? §  Information gathering –  Instrumentation calls all over the JVM –  Application information via Java API §  Collected in Thread Local buffers ⇢ Global Buffers ⇢Disk §  Binary, proprietary file format §  Managed via JMX JFR Thread Buffers Disk JMX GC RuntimeCompiler Java API Global Buffers
  26. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.26 Java Mission Control §  Console –  Online Monitoring and Management –  MBean Browser –  Triggers & Alerts §  UI for Java Flight Recorder $  bin/jmc   New!
  27. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.27 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Agenda §  Demos, walk-through §  Internals §  Future
  28. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.28 Future §  More Diagnostic Commands (jcmd) –  Eventually replacing jstack,  jmap,  jinfo   §  JMX Enhancements –  Annotations, REST protocol, batched updates §  Improved Logging for the JVM –  JEP 158 §  Remove JConsole, hprof agent, jhat (?) It’s soon here!
  29. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.29 Take-away §  Know which tools exists §  Seen the tools in use §  Something new and something useful §  Go and experiment with the tools! @stalar staffan.larsen@oracle.com serviceability-dev@openjdk.java.net
  30. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.30 More Sessions §  Oracle Java Mission Control: Java Flight Recorder Deep Dive –  Tutorial –  Today 10 am – 12 pm §  Java Flight Recorder Behind The Scenes –  Session –  Wednesday 11:30 am – 12:30 pm
  31. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.31 @stalar staffan.larsen@oracle.com serviceability-dev@openjdk.java.net
  32. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.32

×