1 / 28

Diagnosing Your Application on the JVM

Diagnosing Your Application on the JVM. Staffan Larsen Java SE Serviceability Architect staffan.larsen@oracle.com @stalar. Notice.

river
Télécharger la présentation

Diagnosing Your Application on the JVM

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Diagnosing Your Application on the JVM Staffan LarsenJava SE Serviceability Architect staffan.larsen@oracle.com @stalar

  2. Notice 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 DECISION. THE DEVELOPMENT, RELEASE, AND TIMING OF ANY FEATURES OR FUNCTIONALITY DESCRIBED FOR ORACLE'S PRODUCTS REMAINS AT THE SOLE DISCRETION OF ORACLE.

  3. 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)

  4. jstack attach JMX jinfo jstatd jps jvisualvm jstat jcmd perf counters jmap serviceability agent

  5. Demos, walk-through • Internals • Future Agenda

  6. DEMO

  7. Demos, walk-through • Internals • Future Agenda

  8. Remote access • JMX • jvisualvm, jconsole • Access information from java.lang.managementMBeans • SSL and authentication • Enable startup: -Dcom.sun.management.jmxremote • Enable runtime: jcmdManagementServer.start • jstatd • Daemon that runs on remote machine • jstat can connect to daemon New!

  9. Discovery What is running on my system? • 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

  10. Java Discovery Protocol JDP From freedigitalphotos.net/by digitalart

  11. 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 • Mechanics differ on platforms

  12. 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 /tmp/.java_pid<pid> socket • Use socket for communication • Solaris uses door API instead of socket

  13. 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

  14. 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 Coming Soon!

  15. 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

  16. Accessing the JVM jcmd jstack jmap jinfo Monitored JVM JMX JMX RMI j* jstat(d) jstat JMX client dcmd JVM attach jvmstat attach Mission Control VisualVM JConsole

  17. Communicating with the JVM

  18. 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>

  19. Accessing the JVM jstack jmap jinfo Monitored JVM j* JVM vmSymbols SA debugger

  20. Java Mission Control • Java Mission Control

  21. Java Flight Recorder • JVM-built-in profiler and tracer • Non-intrusive • Always-on • Circular buffers • Captures both JVM and application data • GC, Locks, Compiler, Exceptions, CPU Usage, I/O, … … • After-the-fact analysis New! Photograph by Jeffrey Milstein http://butdoesitfloat.com/In-the-presence-of-massive-gravitational-fields-this-perfect

  22. Demos, walk-through • Internals • Future Agenda

  23. Future It’s soon here! • More Diagnostic Commands (jcmd) • Eventually replacing jstack, jmap, jinfo • JMX 2.0 • Improved Logging for the JVM • JEP 158 • Deprecate JConsole, hprof agent (?)

  24. 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

  25. Q&A @stalar staffan.larsen@oracle.com serviceability-dev@openjdk.java.net

More Related