SlideShare una empresa de Scribd logo
1 de 32
Descargar para leer sin conexión
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.1
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
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.
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)
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
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.6
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
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.8
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
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
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
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
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
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
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
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
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
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
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)
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 ✔ (✔) ✔
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.21
attach JMX
jvmstat jstatd
RemoteLocal
Two-way
One-way
Communicating with the JVM
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>	
  
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.23
Monitored JVM
JVMj*
SA
jstack
jmap
jinfo
debugger
vmSymbols
Accessing the JVM
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
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
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!
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
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!
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
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
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.31
@stalar
staffan.larsen@oracle.com
serviceability-dev@openjdk.java.net
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.32

Más contenido relacionado

La actualidad más candente

The JVM is your friend
The JVM is your friendThe JVM is your friend
The JVM is your friendKai Koenig
 
Java profiling Do It Yourself (jug.msk.ru 2016)
Java profiling Do It Yourself (jug.msk.ru 2016)Java profiling Do It Yourself (jug.msk.ru 2016)
Java profiling Do It Yourself (jug.msk.ru 2016)aragozin
 
What's New in the JVM in Java 8?
What's New in the JVM in Java 8?What's New in the JVM in Java 8?
What's New in the JVM in Java 8?Azul Systems Inc.
 
So You Want To Write Your Own Benchmark
So You Want To Write Your Own BenchmarkSo You Want To Write Your Own Benchmark
So You Want To Write Your Own BenchmarkDror Bereznitsky
 
Java on Linux for devs and ops
Java on Linux for devs and opsJava on Linux for devs and ops
Java on Linux for devs and opsaragozin
 
Inside The Java Virtual Machine
Inside The Java Virtual MachineInside The Java Virtual Machine
Inside The Java Virtual Machineelliando dias
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java WorkshopSimon Ritter
 
Memory Management: What You Need to Know When Moving to Java 8
Memory Management: What You Need to Know When Moving to Java 8Memory Management: What You Need to Know When Moving to Java 8
Memory Management: What You Need to Know When Moving to Java 8AppDynamics
 
Don't dump thread dumps
Don't dump thread dumpsDon't dump thread dumps
Don't dump thread dumpsTier1 App
 
Java Flight Recorder Behind the Scenes
Java Flight Recorder Behind the ScenesJava Flight Recorder Behind the Scenes
Java Flight Recorder Behind the ScenesStaffan Larsen
 
Powering the Next Generation Services with Java Platform - Spark IT 2010
Powering the Next Generation Services with Java Platform - Spark IT 2010Powering the Next Generation Services with Java Platform - Spark IT 2010
Powering the Next Generation Services with Java Platform - Spark IT 2010Arun Gupta
 
JVM Memory Management Details
JVM Memory Management DetailsJVM Memory Management Details
JVM Memory Management DetailsAzul Systems Inc.
 
Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)Ryan Cuprak
 
Java profiling Do It Yourself
Java profiling Do It YourselfJava profiling Do It Yourself
Java profiling Do It Yourselfaragozin
 
Monitoring and Troubleshooting Tools in Java 9
Monitoring and Troubleshooting Tools in Java 9Monitoring and Troubleshooting Tools in Java 9
Monitoring and Troubleshooting Tools in Java 9Poonam Bajaj Parhar
 
JDK9 Features (Summary, 31/Jul/2015) #JJUG
JDK9 Features (Summary, 31/Jul/2015) #JJUGJDK9 Features (Summary, 31/Jul/2015) #JJUG
JDK9 Features (Summary, 31/Jul/2015) #JJUGYuji Kubota
 
Find bottleneck and tuning in Java Application
Find bottleneck and tuning in Java ApplicationFind bottleneck and tuning in Java Application
Find bottleneck and tuning in Java Applicationguest1f2740
 

La actualidad más candente (20)

The JVM is your friend
The JVM is your friendThe JVM is your friend
The JVM is your friend
 
JVM Internals (2015)
JVM Internals (2015)JVM Internals (2015)
JVM Internals (2015)
 
Java profiling Do It Yourself (jug.msk.ru 2016)
Java profiling Do It Yourself (jug.msk.ru 2016)Java profiling Do It Yourself (jug.msk.ru 2016)
Java profiling Do It Yourself (jug.msk.ru 2016)
 
What's New in the JVM in Java 8?
What's New in the JVM in Java 8?What's New in the JVM in Java 8?
What's New in the JVM in Java 8?
 
So You Want To Write Your Own Benchmark
So You Want To Write Your Own BenchmarkSo You Want To Write Your Own Benchmark
So You Want To Write Your Own Benchmark
 
Java on Linux for devs and ops
Java on Linux for devs and opsJava on Linux for devs and ops
Java on Linux for devs and ops
 
Java Performance Tuning
Java Performance TuningJava Performance Tuning
Java Performance Tuning
 
Inside The Java Virtual Machine
Inside The Java Virtual MachineInside The Java Virtual Machine
Inside The Java Virtual Machine
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java Workshop
 
Memory Management: What You Need to Know When Moving to Java 8
Memory Management: What You Need to Know When Moving to Java 8Memory Management: What You Need to Know When Moving to Java 8
Memory Management: What You Need to Know When Moving to Java 8
 
Don't dump thread dumps
Don't dump thread dumpsDon't dump thread dumps
Don't dump thread dumps
 
Java Flight Recorder Behind the Scenes
Java Flight Recorder Behind the ScenesJava Flight Recorder Behind the Scenes
Java Flight Recorder Behind the Scenes
 
Powering the Next Generation Services with Java Platform - Spark IT 2010
Powering the Next Generation Services with Java Platform - Spark IT 2010Powering the Next Generation Services with Java Platform - Spark IT 2010
Powering the Next Generation Services with Java Platform - Spark IT 2010
 
JVM Memory Management Details
JVM Memory Management DetailsJVM Memory Management Details
JVM Memory Management Details
 
Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)
 
Java profiling Do It Yourself
Java profiling Do It YourselfJava profiling Do It Yourself
Java profiling Do It Yourself
 
Java On Speed
Java On SpeedJava On Speed
Java On Speed
 
Monitoring and Troubleshooting Tools in Java 9
Monitoring and Troubleshooting Tools in Java 9Monitoring and Troubleshooting Tools in Java 9
Monitoring and Troubleshooting Tools in Java 9
 
JDK9 Features (Summary, 31/Jul/2015) #JJUG
JDK9 Features (Summary, 31/Jul/2015) #JJUGJDK9 Features (Summary, 31/Jul/2015) #JJUG
JDK9 Features (Summary, 31/Jul/2015) #JJUG
 
Find bottleneck and tuning in Java Application
Find bottleneck and tuning in Java ApplicationFind bottleneck and tuning in Java Application
Find bottleneck and tuning in Java Application
 

Destacado

Debugging Your Production JVM
Debugging Your Production JVMDebugging Your Production JVM
Debugging Your Production JVMkensipe
 
Hands-on Performance Tuning Lab - Devoxx Poland
Hands-on Performance Tuning Lab - Devoxx PolandHands-on Performance Tuning Lab - Devoxx Poland
Hands-on Performance Tuning Lab - Devoxx PolandC2B2 Consulting
 
JavaOne 2014: Java Debugging
JavaOne 2014: Java DebuggingJavaOne 2014: Java Debugging
JavaOne 2014: Java DebuggingChris Bailey
 
Profiler Guided Java Performance Tuning
Profiler Guided Java Performance TuningProfiler Guided Java Performance Tuning
Profiler Guided Java Performance Tuningosa_ora
 
Towards JVM Dynamic Languages Toolchain
Towards JVM Dynamic Languages ToolchainTowards JVM Dynamic Languages Toolchain
Towards JVM Dynamic Languages ToolchainAttila Szegedi
 
Hotspot Garbage Collection - The Useful Parts
Hotspot Garbage Collection - The Useful PartsHotspot Garbage Collection - The Useful Parts
Hotspot Garbage Collection - The Useful PartsjClarity
 
Efficient Memory and Thread Management in Highly Parallel Java Applications
Efficient Memory and Thread Management in Highly Parallel Java ApplicationsEfficient Memory and Thread Management in Highly Parallel Java Applications
Efficient Memory and Thread Management in Highly Parallel Java Applicationspkoza
 
Java Performance Tuning
Java Performance TuningJava Performance Tuning
Java Performance TuningMinh Hoang
 
Real Life Java EE Performance Tuning
Real Life Java EE Performance TuningReal Life Java EE Performance Tuning
Real Life Java EE Performance TuningC2B2 Consulting
 
An Introduction To Java Profiling
An Introduction To Java ProfilingAn Introduction To Java Profiling
An Introduction To Java Profilingschlebu
 
Everything I Ever Learned About JVM Performance Tuning @Twitter
Everything I Ever Learned About JVM Performance Tuning @TwitterEverything I Ever Learned About JVM Performance Tuning @Twitter
Everything I Ever Learned About JVM Performance Tuning @TwitterAttila Szegedi
 

Destacado (11)

Debugging Your Production JVM
Debugging Your Production JVMDebugging Your Production JVM
Debugging Your Production JVM
 
Hands-on Performance Tuning Lab - Devoxx Poland
Hands-on Performance Tuning Lab - Devoxx PolandHands-on Performance Tuning Lab - Devoxx Poland
Hands-on Performance Tuning Lab - Devoxx Poland
 
JavaOne 2014: Java Debugging
JavaOne 2014: Java DebuggingJavaOne 2014: Java Debugging
JavaOne 2014: Java Debugging
 
Profiler Guided Java Performance Tuning
Profiler Guided Java Performance TuningProfiler Guided Java Performance Tuning
Profiler Guided Java Performance Tuning
 
Towards JVM Dynamic Languages Toolchain
Towards JVM Dynamic Languages ToolchainTowards JVM Dynamic Languages Toolchain
Towards JVM Dynamic Languages Toolchain
 
Hotspot Garbage Collection - The Useful Parts
Hotspot Garbage Collection - The Useful PartsHotspot Garbage Collection - The Useful Parts
Hotspot Garbage Collection - The Useful Parts
 
Efficient Memory and Thread Management in Highly Parallel Java Applications
Efficient Memory and Thread Management in Highly Parallel Java ApplicationsEfficient Memory and Thread Management in Highly Parallel Java Applications
Efficient Memory and Thread Management in Highly Parallel Java Applications
 
Java Performance Tuning
Java Performance TuningJava Performance Tuning
Java Performance Tuning
 
Real Life Java EE Performance Tuning
Real Life Java EE Performance TuningReal Life Java EE Performance Tuning
Real Life Java EE Performance Tuning
 
An Introduction To Java Profiling
An Introduction To Java ProfilingAn Introduction To Java Profiling
An Introduction To Java Profiling
 
Everything I Ever Learned About JVM Performance Tuning @Twitter
Everything I Ever Learned About JVM Performance Tuning @TwitterEverything I Ever Learned About JVM Performance Tuning @Twitter
Everything I Ever Learned About JVM Performance Tuning @Twitter
 

Similar a Diagnosing Your Application on the JVM

GlassFish in Production Environments
GlassFish in Production EnvironmentsGlassFish in Production Environments
GlassFish in Production EnvironmentsBruno Borges
 
JVMs in Containers - Best Practices
JVMs in Containers - Best PracticesJVMs in Containers - Best Practices
JVMs in Containers - Best PracticesDavid Delabassee
 
Why should i switch to Java SE 7
Why should i switch to Java SE 7Why should i switch to Java SE 7
Why should i switch to Java SE 7Vinay H G
 
GlassFish REST Administration Backend at JavaOne India 2012
GlassFish REST Administration Backend at JavaOne India 2012GlassFish REST Administration Backend at JavaOne India 2012
GlassFish REST Administration Backend at JavaOne India 2012Arun Gupta
 
Production Time Profiling Out of the Box
Production Time Profiling Out of the BoxProduction Time Profiling Out of the Box
Production Time Profiling Out of the BoxMarcus Hirt
 
Java code coverage with JCov. Implementation details and use cases.
Java code coverage with JCov. Implementation details and use cases.Java code coverage with JCov. Implementation details and use cases.
Java code coverage with JCov. Implementation details and use cases.Alexandre (Shura) Iline
 
GlassFish REST Administration Backend
GlassFish REST Administration BackendGlassFish REST Administration Backend
GlassFish REST Administration BackendArun Gupta
 
GlassFish BOF
GlassFish BOFGlassFish BOF
GlassFish BOFglassfish
 
Batch Applications for the Java Platform
Batch Applications for the Java PlatformBatch Applications for the Java Platform
Batch Applications for the Java PlatformSivakumar Thyagarajan
 
Ebs performance tuning session feb 13 2013---Presented by Oracle
Ebs performance tuning session  feb 13 2013---Presented by OracleEbs performance tuning session  feb 13 2013---Presented by Oracle
Ebs performance tuning session feb 13 2013---Presented by OracleAkash Pramanik
 
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7Max Andersen
 
Oracle Solaris 11.1 New Features
Oracle Solaris 11.1 New FeaturesOracle Solaris 11.1 New Features
Oracle Solaris 11.1 New FeaturesOrgad Kimchi
 
Have You Seen Java EE Lately?
Have You Seen Java EE Lately?Have You Seen Java EE Lately?
Have You Seen Java EE Lately?Reza Rahman
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxAna-Maria Mihalceanu
 
Haj 4344-java se 9 and the application server-1
Haj 4344-java se 9 and the application server-1Haj 4344-java se 9 and the application server-1
Haj 4344-java se 9 and the application server-1Kevin Sutter
 
Java Mission Control in Java SE 7U40
Java Mission Control in Java SE 7U40Java Mission Control in Java SE 7U40
Java Mission Control in Java SE 7U40Roger Brinkley
 
Best Practices for Interoperable XML Databinding with JAXB
Best Practices for Interoperable XML Databinding with JAXBBest Practices for Interoperable XML Databinding with JAXB
Best Practices for Interoperable XML Databinding with JAXBMartin Grebac
 
20151010 my sq-landjavav2a
20151010 my sq-landjavav2a20151010 my sq-landjavav2a
20151010 my sq-landjavav2aIvan Ma
 

Similar a Diagnosing Your Application on the JVM (20)

GlassFish in Production Environments
GlassFish in Production EnvironmentsGlassFish in Production Environments
GlassFish in Production Environments
 
JVMs in Containers - Best Practices
JVMs in Containers - Best PracticesJVMs in Containers - Best Practices
JVMs in Containers - Best Practices
 
JVMs in Containers
JVMs in ContainersJVMs in Containers
JVMs in Containers
 
Why should i switch to Java SE 7
Why should i switch to Java SE 7Why should i switch to Java SE 7
Why should i switch to Java SE 7
 
GlassFish REST Administration Backend at JavaOne India 2012
GlassFish REST Administration Backend at JavaOne India 2012GlassFish REST Administration Backend at JavaOne India 2012
GlassFish REST Administration Backend at JavaOne India 2012
 
Troubleshooting Tools In JDK
Troubleshooting Tools In JDKTroubleshooting Tools In JDK
Troubleshooting Tools In JDK
 
Production Time Profiling Out of the Box
Production Time Profiling Out of the BoxProduction Time Profiling Out of the Box
Production Time Profiling Out of the Box
 
Java code coverage with JCov. Implementation details and use cases.
Java code coverage with JCov. Implementation details and use cases.Java code coverage with JCov. Implementation details and use cases.
Java code coverage with JCov. Implementation details and use cases.
 
GlassFish REST Administration Backend
GlassFish REST Administration BackendGlassFish REST Administration Backend
GlassFish REST Administration Backend
 
GlassFish BOF
GlassFish BOFGlassFish BOF
GlassFish BOF
 
Batch Applications for the Java Platform
Batch Applications for the Java PlatformBatch Applications for the Java Platform
Batch Applications for the Java Platform
 
Ebs performance tuning session feb 13 2013---Presented by Oracle
Ebs performance tuning session  feb 13 2013---Presented by OracleEbs performance tuning session  feb 13 2013---Presented by Oracle
Ebs performance tuning session feb 13 2013---Presented by Oracle
 
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
 
Oracle Solaris 11.1 New Features
Oracle Solaris 11.1 New FeaturesOracle Solaris 11.1 New Features
Oracle Solaris 11.1 New Features
 
Have You Seen Java EE Lately?
Have You Seen Java EE Lately?Have You Seen Java EE Lately?
Have You Seen Java EE Lately?
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox
 
Haj 4344-java se 9 and the application server-1
Haj 4344-java se 9 and the application server-1Haj 4344-java se 9 and the application server-1
Haj 4344-java se 9 and the application server-1
 
Java Mission Control in Java SE 7U40
Java Mission Control in Java SE 7U40Java Mission Control in Java SE 7U40
Java Mission Control in Java SE 7U40
 
Best Practices for Interoperable XML Databinding with JAXB
Best Practices for Interoperable XML Databinding with JAXBBest Practices for Interoperable XML Databinding with JAXB
Best Practices for Interoperable XML Databinding with JAXB
 
20151010 my sq-landjavav2a
20151010 my sq-landjavav2a20151010 my sq-landjavav2a
20151010 my sq-landjavav2a
 

Último

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 

Último (20)

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 

Diagnosing Your Application on the JVM

  • 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