Download
1 / 28

Diagnosing Your Application on the JVM - PowerPoint PPT Presentation


  • 126 Views
  • Uploaded on

Diagnosing Your Application on the JVM. Staffan Larsen Java SE Serviceability Architect [email protected] @stalar. Notice.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Diagnosing Your Application on the JVM' - river


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Diagnosing your application on the jvm
Diagnosing Your Application on the JVM

Staffan LarsenJava SE Serviceability Architect

[email protected]

@stalar


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


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)


jstack

attach

JMX

jinfo

jstatd

jps

jvisualvm

jstat

jcmd

perf counters

jmap

serviceability agent


Agenda

Agenda



Agenda1

Agenda


Remote access
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!


Discovery
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


Java discovery protocol
Java Discovery Protocol

JDP

From freedigitalphotos.net/by digitalart


Attach
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


Attach linux bsd solaris
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


Attach windows
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


Diagnostic commands
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!


J vmstat perfcounter
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


Accessing the jvm
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



Serviceability agent
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>


Accessing the jvm1
Accessing the JVM

jstack

jmap

jinfo

Monitored JVM

j*

JVM

vmSymbols

SA

debugger


Java mission control
Java Mission Control

  • Java Mission Control


Java flight recorder
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


Agenda2

Agenda


Future
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 (?)


Take away
Take-away

  • Know which tools exists

  • Seen the tools in use

  • Something new and something useful

  • Go and experiment with the tools!

@stalar

[email protected]

[email protected]


Q&A

@stalar

[email protected]

[email protected]


ad