SlideShare a Scribd company logo
1 of 66
Download to read offline
mjprof : 
A Monadic Approach 
for JVM Profiling 
Haim Yadid 
Performize-IT 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
About Me: Haim Yadid 
• 21 Years of SW development experience 
• independent Performance Expert 
• Consulting R&D Groups 
• Training: Java Performance Optimization 
• Community leader : Java.IL 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Java.IL 
• Israeli Java Community and User Group 
• Meetup : www.meetup.com/JavaIL/ 
• Twitter: @java_il 
• ~ 400 members 
• Meeting every month 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Background 
& 
Motivation 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
The Two Most Important Questions 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
The Two Most Important Questions 
My wife asks me 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
The Two Most Important Questions 
My wife asks me 
What are you doing? When will you be back? 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Profiler 
• A Performance analysis tool 
• Which answers questions about method calls: 
• E.g. : Number of invocation, Average duration,CPU 
consumptions Contention Memory allocation IO, Cache 
misses etc….. 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Statistical Profiler 
• A.k.a. as Sampling Profiler 
• Samples the treads activity every several milliseconds 
• Not very accurate for short tasks 
• Low/Medium overhead 
• Do not provide the number of invocations 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Instrumenting Profiler 
• A.k.a Tracing 
• Instruments the code 
• Knows when a method starts and when it ends 
• High overhead (depends on instrumentation) 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Instrumenting Profiler 
• A.k.a Tracing 
• Instruments the code 
• Knows when a method starts and when it ends 
• High overhead (depends on instrumentation) 
Public void foo(a) { 
Measure start time 
increase invocation count 
bla bla; 
Measure end time 
} 
Injected 
code 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
jstack - A Poor Man’s Profiler 
• The most trivial sampling profiler 
• Part of the JDK 
• Connects to a running JVM and samples all the threads 
• Only once ! 
• Writes to standard output 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
And it looks like this 
• For each thread we have the following block 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
And it looks like this 
• For each thread we have the following block 
Thread name Priority Id and native id 
"pool-35-thread-1" prio=5 tid=10315b800 nid=0x12c1fe000 waiting on condition 
[12c1fd000] 
java.lang.Thread.State: TIMED_WAITING (parking) 
at sun.misc.Unsafe.park(Native Method) 
- parking to wait for <107ac0140> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) 
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:198) 
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos 
..... 
Locked ownable synchronizers: 
- None 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Now do this a Million Times! 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Now do this a Million Times! 
• Tons of threads 
• Deep stacks 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
mjprof 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
mjprof 
• A command line tool 
• Acts on jstack output 
• Extends it (enriched thread dumps) 
• Applies a sequence of operations (monads) to 
• Filter 
• Aggregate 
• Manipulate 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Prerequisites 
• Java installed 
• Set JAVA_HOME (JDK1.7 or later) 
• Add ${JAVA_HOME}/bin to path 
• Attaching to processes requires JDK and not JRE 
• Can run on a headless machine 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Installing mjprof 
• Git repo : 
https://github.com/AdoptOpenJDK/mjprof 
• Download and unzip 
unzip mjprof1.0-bin.zip 
• Or clone and build 
mvn install assembly:assembly 
• Add mjprof directory to your path 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Synopsis and Help (Smoke test) 
• Running mjprof without parameters will print help 
• It is a good way to see it is functioning 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Synopsis and Help (Smoke test) 
• Running mjprof without parameters will print help 
• It is a good way to see it is functioning 
➜ mjprof git:(master) ✗ mjprof 
Synopsis 
A list of the following monads concatenated with . 
… 
Data sources: 
jstack/pid,[count],[sleep]/ -Generate dumps using stack 
path/path/ -Read thread dump from file 
stdin -Read thread dumps from standard input 
visualvm/path/ -Read profiling session from xml export of VisualVM 
…. 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Monads 
• Pipeline Building blocks 
• Monads can 
• Collect data 
• Filter out certain threads 
• Transform threads information 
• Aggregate threads information 
• Snapshot write state to a file or GUI 
• Concatenate with a . (period) 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Data Sources 
stdin 
file 
jstack 
jmx 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Data Sources 
stdin • cat mythreaddump.txt | mjprof … 
file 
jstack 
jmx 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Data Sources 
• cat mythreaddump.txt | mjprof … 
• mjprof path/mythreaddump.txt/ 
stdin 
file 
jstack 
jmx 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Data Sources 
• cat mythreaddump.txt | mjprof … 
• mjprof path/mythreaddump.txt/ 
• mjprof jstack/19873/ 
stdin 
file 
jstack 
jmx 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Data Sources 
• cat mythreaddump.txt | mjprof … 
• mjprof path/mythreaddump.txt/ 
• mjprof jstack/19873/ 
• mjprof jmx/myhost:65327/ 
stdin 
file 
jstack 
jmx 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Monads 
Filters Aggregations Stack frame level 
contains -contains group 
-prop -fn 
merge 
sort 
-sort 
frame 
waiting -locks 
count 
mergedcalles 
-frame 
top 
bottom 
trimbelow 
namesuf 
-fn 
-pkg 
jvm -jvm 
blocked 
locks 
running withstack 
output 
stdout 
gui 
snapshot 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Extending mjprof 
• mjprof is inherently extensible 
• Macros 
• A text file named macros.properties 
• Contains a sequence of macros 
• Plugins 
• Annotate your extension with @Plugin 
• Compile it and place your jar in the directory plugins under mjprof 
installation 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
10 mjprof Recipes 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Question: How many threads my process has? 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Question: How many threads my process has? 
path/stack.txt/ 
mjprof jstack/1971/ 
jstack/MainClass/ 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Question: How many threads my process has? 
path/stack.txt/ 
mjprof jstack/1971/ . count 
jstack/MainClass/ 
➜ distro mjprof jstack/1971/.count 
2014-11-01 10:34:10 
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.0-b70 mixed mode): 
Total number of threads is 1045 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Question: How many jetty thread are working ATM? 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Question: How many jetty thread are working ATM? 
mjprof jstack/MyApp/ 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Question: How many jetty thread are working ATM? 
mjprof jstack/MyApp/ . contains/name,qtp/ 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Question: How many jetty thread are working ATM? 
mjprof jstack/MyApp/ . contains/name,qtp/ 
. contains/state,RUN/ 
➜ 04112014 mjprof jstack/My4tApp/.contains/name,qtp/ 
2014-11-04 20:05:03 
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.0-b70 mixed mode): 
"qtp817406040-17-selector-ServerConnectorManager@69b87e8d/3" prio=5 ….3 runnable 
[0x000000011bc5f000] 
java.lang.Thread.State: RUNNABLE 
at sun.nio.ch.KQueueArrayWrapper.kevent0(Native Method) 
at sun.nio.ch.KQueueArrayWrapper.poll(KQueueArrayWrapper.java:202) 
at sun.nio.ch.KQueueSelectorImpl.doSelect(KQueueSelectorImpl.java:103) 
at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86) 
- locked <0x0000000780209080> (a sun.nio.ch.Util$2) 
- locked <0x0000000780209070> (a java.util.Collections$UnmodifiableSet) 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Question: How many jetty thread are working ATM? 
mjprof jstack/MyApp/ . contains/name,qtp/ 
. contains/state,RUN/ . count 
➜ 04112014 mjprof jstack/My4tApp/.contains/name,qtp/ 
2014-11-04 20:05:03 
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.0-b70 mixed mode): 
"qtp817406040-17-selector-ServerConnectorManager@69b87e8d/3" prio=5 ….3 runnable 
[0x000000011bc5f000] 
java.lang.Thread.State: RUNNABLE 
at sun.nio.ch.KQueueArrayWrapper.kevent0(Native Method) 
at sun.nio.ch.KQueueArrayWrapper.poll(KQueueArrayWrapper.java:202) 
at sun.nio.ch.KQueueSelectorImpl.doSelect(KQueueSelectorImpl.java:103) 
at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86) 
- locked <0x0000000780209080> (a sun.nio.ch.Util$2) 
- locked <0x0000000780209070> (a java.util.Collections$UnmodifiableSet) 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Question: Which threads are running my logic ? 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Question: Which threads are running my logic ? 
mjprof jstack/MyApp/ . contains/stack,myapp/ 
2014-11-04 20:11:55 
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.0-b70 mixed mode): 
"Indexing daemon" prio=5 tid=0x00007fb306bf4800 nid=0x6307 waiting on condition 
[0x000000011c171000] 
java.lang.Thread.State: TIMED_WAITING (sleeping) 
at java.lang.Thread.sleep(Native Method) 
at com.myapp.IndexManagement$1.run(IndexManagement.java:148) 
"main" prio=5 tid=0x00007fb303809000 nid=0x1303 in Object.wait() 
[0x0000000105500000] 
java.lang.Thread.State: WAITING (on object monitor) 
at java.lang.Object.wait(Native Method) 
at java.lang.Object.wait(Object.java:502) 
at com.myapp.MyAppApp.main(MyAppApp.java:18) 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Question: Stack-trace is cluttered, how do I shorten it ? 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Question: Stack-trace is cluttered, how do I shorten it ? 
mjprof jmx/MyApp/ . 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Question: Stack-trace is cluttered, how do I shorten it ? 
mjprof jmx/MyApp/ . frame/mycompany/ 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Question: Stack-trace is cluttered, how do I shorten it ? 
mjprof jmx/MyApp/ . frame/mycompany/ 
-frame/grizzly/ 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Question: Stack-trace is cluttered, how do I shorten it ? 
mjprof jmx/MyApp/ . frame/mycompany/ 
-frame/grizzly/ 
top/3/ 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Question: How can I group threads by state ? 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Question: How can I group threads by state ? 
mjprof jmx/MyApp/ . group/state/ . gui 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Question: How do I aggregate several thread dumps 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Question: How do I aggregate several thread dumps 
mjprof jmx/MyApp,10,1000/ 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Question: How do I aggregate several thread dumps 
mjprof jmx/MyApp,10,1000/ . 
group/state/ 
merge 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Question: How do I aggregate several thread dumps 
mjprof jmx/MyApp,10,1000/ . 
group/state/ 
merge . 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Question: How can I combine thread dumps from several processes? 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Question: How can I combine thread dumps from several processes? 
mjprof jmx/myhost1.com:5467/ . 
jmx/myhost2.com:5467/ . 
group/state/ . gui 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
#Devoxx #Performance #AdoptOpenJDK @lifeyx
How do I measure thread pool CPU consumption? 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
How do I measure thread pool CPU consumption? 
mjprof jmxc/MyApp/ 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
How do I measure thread pool CPU consumption? 
mjprof jmxc/MyApp/ . contains/name,COFFEE/ 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
How do I measure thread pool CPU consumption? 
mjprof jmxc/MyApp/ . contains/name,COFFEE/ 
. -pkg . group 
"*" count=7 tid=* cpu_ns=1164536000 wall_ms=4804 %cpu=24.24 
java.lang.Thread.State: TIMED_WAITING 
100.00% [7/7] at Thread.run(Thread.java:744) 
100.00% [7/7]  at Sleeper.run(Sleeper.java:51) 
100.00% [7/7]  at Sleeper.loopForever(Sleeper.java:37) 
100.00% [7/7]  at Sleeper.longerStackTrace(Sleeper.java:32) 
100.00% [7/7]  at Sleeper.longerStackTrace(Sleeper.java:32) 
100.00% [7/7]  at Sleeper.longerStackTrace(Sleeper.java:32) 
100.00% [7/7]  at Sleeper.longerStackTrace(Sleeper.java:32) 
100.00% [7/7]  at Sleeper.longerStackTrace(Sleeper.java:32) 
100.00% [7/7]  at Sleeper.longerStackTrace(Sleeper.java:30) 
100.00% [7/7]  at Recurse.singleCycle(Recurse.java:16) 
100.00% [7/7]  at Recurse.doRecursion(Recurse.java:25) 
100.00% [7/7]  at Recurse.doRecursion(Recurse.java:25) 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Question: Which threads are blocked by the lock I hold 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Question: Which threads are blocked by the lock I hold 
mjprof path/threaddump.txt/ . 
blocked 
. 
contains/stack,0x00000007aab51b38/ 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Question: What is the overall locking state of my application 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Question: What is the overall locking state of my application 
mjprof path/threaddump.txt/ . 
contains/stack,myapp/ 
locks 
. 
"CPU3_5" prio=5 tid=0x00007fc4f4889800 nid=0x5703 waiting for monitor… 
java.lang.Thread.State: BLOCKED (on object monitor) 
- waiting to lock <0x00000007aad98988> (a java.lang.Object) 
"CPU3_4" prio=5 tid=0x00007fc4f404a800 nid=0x5503 waiting for monitor… 
java.lang.Thread.State: BLOCKED (on object monitor) 
- waiting to lock <0x00000007aad98988> (a java.lang.Object) 
"CPU3_3" prio=5 tid=0x00007fc4f4049800 nid=0x5303 waiting on … 
java.lang.Thread.State: TIMED_WAITING (sleeping) 
- locked <0x00000007aad98988> (a java.lang.Object) 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
3#! 
#Devoxx #Performance #AdoptOpenJDK @lifeyx
Thanks / Contact Me 
lifey@performize-it.com 
blog.performize-it.com 
www.performize-it.com 
https://github.com/lifey 
http://il.linkedin.com/in/haimyadid 
@lifeyx 
#Devoxx #Performance #AdoptOpenJDK @lifeyx

More Related Content

What's hot

You didnt see it’s coming? "Dawn of hardened Windows Kernel"
You didnt see it’s coming? "Dawn of hardened Windows Kernel" You didnt see it’s coming? "Dawn of hardened Windows Kernel"
You didnt see it’s coming? "Dawn of hardened Windows Kernel"
Peter Hlavaty
 

What's hot (19)

De Java 8 a Java 11 y 14
De Java 8 a Java 11 y 14De Java 8 a Java 11 y 14
De Java 8 a Java 11 y 14
 
Attack on the Core
Attack on the CoreAttack on the Core
Attack on the Core
 
Beyond JVM - YOW Melbourne 2013
Beyond JVM - YOW Melbourne 2013Beyond JVM - YOW Melbourne 2013
Beyond JVM - YOW Melbourne 2013
 
De Java 8 a Java 17
De Java 8 a Java 17De Java 8 a Java 17
De Java 8 a Java 17
 
Back to the CORE
Back to the COREBack to the CORE
Back to the CORE
 
Vulnerability desing patterns
Vulnerability desing patternsVulnerability desing patterns
Vulnerability desing patterns
 
DeathNote of Microsoft Windows Kernel
DeathNote of Microsoft Windows KernelDeathNote of Microsoft Windows Kernel
DeathNote of Microsoft Windows Kernel
 
NovaProva, a new generation unit test framework for C programs
NovaProva, a new generation unit test framework for C programsNovaProva, a new generation unit test framework for C programs
NovaProva, a new generation unit test framework for C programs
 
Devoxx PL: Is your profiler speaking the same language as you?
Devoxx PL: Is your profiler speaking the same language as you?Devoxx PL: Is your profiler speaking the same language as you?
Devoxx PL: Is your profiler speaking the same language as you?
 
DevoxxUK: Is your profiler speaking the same language as you?
DevoxxUK: Is your profiler speaking the same language as you?DevoxxUK: Is your profiler speaking the same language as you?
DevoxxUK: Is your profiler speaking the same language as you?
 
Power of linked list
Power of linked listPower of linked list
Power of linked list
 
Guardians of your CODE
Guardians of your CODEGuardians of your CODE
Guardians of your CODE
 
De Java 8 ate Java 14
De Java 8 ate Java 14De Java 8 ate Java 14
De Java 8 ate Java 14
 
Thread dumps
Thread dumpsThread dumps
Thread dumps
 
How to implement a simple dalvik virtual machine
How to implement a simple dalvik virtual machineHow to implement a simple dalvik virtual machine
How to implement a simple dalvik virtual machine
 
Solaris DTrace, An Introduction
Solaris DTrace, An IntroductionSolaris DTrace, An Introduction
Solaris DTrace, An Introduction
 
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the CoreNSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
 
Threads
ThreadsThreads
Threads
 
You didnt see it’s coming? "Dawn of hardened Windows Kernel"
You didnt see it’s coming? "Dawn of hardened Windows Kernel" You didnt see it’s coming? "Dawn of hardened Windows Kernel"
You didnt see it’s coming? "Dawn of hardened Windows Kernel"
 

Viewers also liked

Viewers also liked (10)

Java 8 Launch - MetaSpaces
Java 8 Launch - MetaSpacesJava 8 Launch - MetaSpaces
Java 8 Launch - MetaSpaces
 
Coding for Android on steroids with Kotlin
Coding for Android on steroids with KotlinCoding for Android on steroids with Kotlin
Coding for Android on steroids with Kotlin
 
Taking Kotlin to production, Seriously
Taking Kotlin to production, SeriouslyTaking Kotlin to production, Seriously
Taking Kotlin to production, Seriously
 
A topology of memory leaks on the JVM
A topology of memory leaks on the JVMA topology of memory leaks on the JVM
A topology of memory leaks on the JVM
 
The Future of Futures - A Talk About Java 8 CompletableFutures
The Future of Futures - A Talk About Java 8 CompletableFuturesThe Future of Futures - A Talk About Java 8 CompletableFutures
The Future of Futures - A Talk About Java 8 CompletableFutures
 
ClassLoader Leaks
ClassLoader LeaksClassLoader Leaks
ClassLoader Leaks
 
The Java Memory Model
The Java Memory ModelThe Java Memory Model
The Java Memory Model
 
Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJava
 
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
 
Playing with State Monad
Playing with State MonadPlaying with State Monad
Playing with State Monad
 

Similar to mjprof: Monadic approach for JVM profiling

Similar to mjprof: Monadic approach for JVM profiling (20)

Terraform Modules and Continuous Deployment
Terraform Modules and Continuous DeploymentTerraform Modules and Continuous Deployment
Terraform Modules and Continuous Deployment
 
Oracle WebLogic Diagnostics & Perfomance tuning
Oracle WebLogic Diagnostics & Perfomance tuningOracle WebLogic Diagnostics & Perfomance tuning
Oracle WebLogic Diagnostics & Perfomance tuning
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
GOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter SlidesGOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter Slides
 
JDK Tools For Performance Diagnostics
JDK Tools For Performance DiagnosticsJDK Tools For Performance Diagnostics
JDK Tools For Performance Diagnostics
 
.NET Debugging Workshop
.NET Debugging Workshop.NET Debugging Workshop
.NET Debugging Workshop
 
Toward dynamic analysis of obfuscated android malware
Toward dynamic analysis of obfuscated android malwareToward dynamic analysis of obfuscated android malware
Toward dynamic analysis of obfuscated android malware
 
Byte code manipulation and instrumentalization in Java
Byte code manipulation and instrumentalization in JavaByte code manipulation and instrumentalization in Java
Byte code manipulation and instrumentalization in Java
 
J1 2015 "Debugging Java Apps in Containers: No Heavy Welding Gear Required"
J1 2015 "Debugging Java Apps in Containers: No Heavy Welding Gear Required"J1 2015 "Debugging Java Apps in Containers: No Heavy Welding Gear Required"
J1 2015 "Debugging Java Apps in Containers: No Heavy Welding Gear Required"
 
Server-Side JavaScript Developement - Node.JS Quick Tour
Server-Side JavaScript Developement - Node.JS Quick TourServer-Side JavaScript Developement - Node.JS Quick Tour
Server-Side JavaScript Developement - Node.JS Quick Tour
 
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)
 
HotSpotコトハジメ
HotSpotコトハジメHotSpotコトハジメ
HotSpotコトハジメ
 
Heap & thread dump
Heap & thread dumpHeap & thread dump
Heap & thread dump
 
Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introduction
 
Sista: Improving Cog’s JIT performance
Sista: Improving Cog’s JIT performanceSista: Improving Cog’s JIT performance
Sista: Improving Cog’s JIT performance
 
What we can expect from Java 9 by Ivan Krylov
What we can expect from Java 9 by Ivan KrylovWhat we can expect from Java 9 by Ivan Krylov
What we can expect from Java 9 by Ivan Krylov
 
PostgreSQL and Linux Containers
PostgreSQL and Linux ContainersPostgreSQL and Linux Containers
PostgreSQL and Linux Containers
 
DanNotes 2013: OpenNTF Domino API
DanNotes 2013: OpenNTF Domino APIDanNotes 2013: OpenNTF Domino API
DanNotes 2013: OpenNTF Domino API
 
Postgre sql linuxcontainers by Jignesh Shah
Postgre sql linuxcontainers by Jignesh ShahPostgre sql linuxcontainers by Jignesh Shah
Postgre sql linuxcontainers by Jignesh Shah
 

More from Haim Yadid

More from Haim Yadid (16)

Loom me up Scotty! Project Loom - What's in it for Me?
Loom me up Scotty!  Project Loom - What's in it for Me?Loom me up Scotty!  Project Loom - What's in it for Me?
Loom me up Scotty! Project Loom - What's in it for Me?
 
“Show Me the Garbage!”, Garbage Collection a Friend or a Foe
“Show Me the Garbage!”, Garbage Collection a Friend or a Foe“Show Me the Garbage!”, Garbage Collection a Friend or a Foe
“Show Me the Garbage!”, Garbage Collection a Friend or a Foe
 
Kotlin Backend Development 6 Yrs Recap. The Good, the Bad and the Ugly
Kotlin Backend Development 6 Yrs Recap. The Good, the Bad and the UglyKotlin Backend Development 6 Yrs Recap. The Good, the Bad and the Ugly
Kotlin Backend Development 6 Yrs Recap. The Good, the Bad and the Ugly
 
“Show Me the Garbage!”, Understanding Garbage Collection
“Show Me the Garbage!”, Understanding Garbage Collection“Show Me the Garbage!”, Understanding Garbage Collection
“Show Me the Garbage!”, Understanding Garbage Collection
 
Java Memory Structure
Java Memory Structure Java Memory Structure
Java Memory Structure
 
Basic JVM Troubleshooting With Jmx
Basic JVM Troubleshooting With JmxBasic JVM Troubleshooting With Jmx
Basic JVM Troubleshooting With Jmx
 
The Freelancer Journey
The Freelancer JourneyThe Freelancer Journey
The Freelancer Journey
 
Building microservices with Kotlin
Building microservices with KotlinBuilding microservices with Kotlin
Building microservices with Kotlin
 
Let's talk about Garbage Collection
Let's talk about Garbage CollectionLet's talk about Garbage Collection
Let's talk about Garbage Collection
 
JVM Garbage Collection logs, you do not want to ignore them! - Reversim Summi...
JVM Garbage Collection logs, you do not want to ignore them! - Reversim Summi...JVM Garbage Collection logs, you do not want to ignore them! - Reversim Summi...
JVM Garbage Collection logs, you do not want to ignore them! - Reversim Summi...
 
Java 8 - Stamped Lock
Java 8 - Stamped LockJava 8 - Stamped Lock
Java 8 - Stamped Lock
 
Concurrency and Multithreading Demistified - Reversim Summit 2014
Concurrency and Multithreading Demistified - Reversim Summit 2014Concurrency and Multithreading Demistified - Reversim Summit 2014
Concurrency and Multithreading Demistified - Reversim Summit 2014
 
A short Intro. to Java Mission Control
A short Intro. to Java Mission ControlA short Intro. to Java Mission Control
A short Intro. to Java Mission Control
 
Java Enterprise Edition Concurrency Misconceptions
Java Enterprise Edition Concurrency Misconceptions Java Enterprise Edition Concurrency Misconceptions
Java Enterprise Edition Concurrency Misconceptions
 
Tales About Scala Performance
Tales About Scala PerformanceTales About Scala Performance
Tales About Scala Performance
 
Israeli JUG - IL JUG presentation
Israeli JUG -  IL JUG presentation Israeli JUG -  IL JUG presentation
Israeli JUG - IL JUG presentation
 

Recently uploaded

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

Recently uploaded (20)

Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 

mjprof: Monadic approach for JVM profiling

  • 1. mjprof : A Monadic Approach for JVM Profiling Haim Yadid Performize-IT #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 2. About Me: Haim Yadid • 21 Years of SW development experience • independent Performance Expert • Consulting R&D Groups • Training: Java Performance Optimization • Community leader : Java.IL #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 3. Java.IL • Israeli Java Community and User Group • Meetup : www.meetup.com/JavaIL/ • Twitter: @java_il • ~ 400 members • Meeting every month #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 4. Background & Motivation #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 5. The Two Most Important Questions #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 6. The Two Most Important Questions My wife asks me #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 7. The Two Most Important Questions My wife asks me What are you doing? When will you be back? #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 8. Profiler • A Performance analysis tool • Which answers questions about method calls: • E.g. : Number of invocation, Average duration,CPU consumptions Contention Memory allocation IO, Cache misses etc….. #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 9. Statistical Profiler • A.k.a. as Sampling Profiler • Samples the treads activity every several milliseconds • Not very accurate for short tasks • Low/Medium overhead • Do not provide the number of invocations #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 10. Instrumenting Profiler • A.k.a Tracing • Instruments the code • Knows when a method starts and when it ends • High overhead (depends on instrumentation) #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 11. Instrumenting Profiler • A.k.a Tracing • Instruments the code • Knows when a method starts and when it ends • High overhead (depends on instrumentation) Public void foo(a) { Measure start time increase invocation count bla bla; Measure end time } Injected code #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 12. jstack - A Poor Man’s Profiler • The most trivial sampling profiler • Part of the JDK • Connects to a running JVM and samples all the threads • Only once ! • Writes to standard output #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 13. And it looks like this • For each thread we have the following block #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 14. And it looks like this • For each thread we have the following block Thread name Priority Id and native id "pool-35-thread-1" prio=5 tid=10315b800 nid=0x12c1fe000 waiting on condition [12c1fd000] java.lang.Thread.State: TIMED_WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <107ac0140> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:198) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos ..... Locked ownable synchronizers: - None #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 15. Now do this a Million Times! #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 16. Now do this a Million Times! • Tons of threads • Deep stacks #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 17. mjprof #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 18. mjprof • A command line tool • Acts on jstack output • Extends it (enriched thread dumps) • Applies a sequence of operations (monads) to • Filter • Aggregate • Manipulate #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 19. Prerequisites • Java installed • Set JAVA_HOME (JDK1.7 or later) • Add ${JAVA_HOME}/bin to path • Attaching to processes requires JDK and not JRE • Can run on a headless machine #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 20. Installing mjprof • Git repo : https://github.com/AdoptOpenJDK/mjprof • Download and unzip unzip mjprof1.0-bin.zip • Or clone and build mvn install assembly:assembly • Add mjprof directory to your path #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 21. Synopsis and Help (Smoke test) • Running mjprof without parameters will print help • It is a good way to see it is functioning #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 22. Synopsis and Help (Smoke test) • Running mjprof without parameters will print help • It is a good way to see it is functioning ➜ mjprof git:(master) ✗ mjprof Synopsis A list of the following monads concatenated with . … Data sources: jstack/pid,[count],[sleep]/ -Generate dumps using stack path/path/ -Read thread dump from file stdin -Read thread dumps from standard input visualvm/path/ -Read profiling session from xml export of VisualVM …. #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 23. Monads • Pipeline Building blocks • Monads can • Collect data • Filter out certain threads • Transform threads information • Aggregate threads information • Snapshot write state to a file or GUI • Concatenate with a . (period) #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 24. Data Sources stdin file jstack jmx #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 25. Data Sources stdin • cat mythreaddump.txt | mjprof … file jstack jmx #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 26. Data Sources • cat mythreaddump.txt | mjprof … • mjprof path/mythreaddump.txt/ stdin file jstack jmx #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 27. Data Sources • cat mythreaddump.txt | mjprof … • mjprof path/mythreaddump.txt/ • mjprof jstack/19873/ stdin file jstack jmx #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 28. Data Sources • cat mythreaddump.txt | mjprof … • mjprof path/mythreaddump.txt/ • mjprof jstack/19873/ • mjprof jmx/myhost:65327/ stdin file jstack jmx #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 29. Monads Filters Aggregations Stack frame level contains -contains group -prop -fn merge sort -sort frame waiting -locks count mergedcalles -frame top bottom trimbelow namesuf -fn -pkg jvm -jvm blocked locks running withstack output stdout gui snapshot #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 30. Extending mjprof • mjprof is inherently extensible • Macros • A text file named macros.properties • Contains a sequence of macros • Plugins • Annotate your extension with @Plugin • Compile it and place your jar in the directory plugins under mjprof installation #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 31. 10 mjprof Recipes #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 33. Question: How many threads my process has? #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 34. Question: How many threads my process has? path/stack.txt/ mjprof jstack/1971/ jstack/MainClass/ #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 35. Question: How many threads my process has? path/stack.txt/ mjprof jstack/1971/ . count jstack/MainClass/ ➜ distro mjprof jstack/1971/.count 2014-11-01 10:34:10 Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.0-b70 mixed mode): Total number of threads is 1045 #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 36. Question: How many jetty thread are working ATM? #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 37. Question: How many jetty thread are working ATM? mjprof jstack/MyApp/ #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 38. Question: How many jetty thread are working ATM? mjprof jstack/MyApp/ . contains/name,qtp/ #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 39. Question: How many jetty thread are working ATM? mjprof jstack/MyApp/ . contains/name,qtp/ . contains/state,RUN/ ➜ 04112014 mjprof jstack/My4tApp/.contains/name,qtp/ 2014-11-04 20:05:03 Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.0-b70 mixed mode): "qtp817406040-17-selector-ServerConnectorManager@69b87e8d/3" prio=5 ….3 runnable [0x000000011bc5f000] java.lang.Thread.State: RUNNABLE at sun.nio.ch.KQueueArrayWrapper.kevent0(Native Method) at sun.nio.ch.KQueueArrayWrapper.poll(KQueueArrayWrapper.java:202) at sun.nio.ch.KQueueSelectorImpl.doSelect(KQueueSelectorImpl.java:103) at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86) - locked <0x0000000780209080> (a sun.nio.ch.Util$2) - locked <0x0000000780209070> (a java.util.Collections$UnmodifiableSet) #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 40. Question: How many jetty thread are working ATM? mjprof jstack/MyApp/ . contains/name,qtp/ . contains/state,RUN/ . count ➜ 04112014 mjprof jstack/My4tApp/.contains/name,qtp/ 2014-11-04 20:05:03 Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.0-b70 mixed mode): "qtp817406040-17-selector-ServerConnectorManager@69b87e8d/3" prio=5 ….3 runnable [0x000000011bc5f000] java.lang.Thread.State: RUNNABLE at sun.nio.ch.KQueueArrayWrapper.kevent0(Native Method) at sun.nio.ch.KQueueArrayWrapper.poll(KQueueArrayWrapper.java:202) at sun.nio.ch.KQueueSelectorImpl.doSelect(KQueueSelectorImpl.java:103) at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86) - locked <0x0000000780209080> (a sun.nio.ch.Util$2) - locked <0x0000000780209070> (a java.util.Collections$UnmodifiableSet) #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 41. Question: Which threads are running my logic ? #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 42. Question: Which threads are running my logic ? mjprof jstack/MyApp/ . contains/stack,myapp/ 2014-11-04 20:11:55 Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.0-b70 mixed mode): "Indexing daemon" prio=5 tid=0x00007fb306bf4800 nid=0x6307 waiting on condition [0x000000011c171000] java.lang.Thread.State: TIMED_WAITING (sleeping) at java.lang.Thread.sleep(Native Method) at com.myapp.IndexManagement$1.run(IndexManagement.java:148) "main" prio=5 tid=0x00007fb303809000 nid=0x1303 in Object.wait() [0x0000000105500000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) at java.lang.Object.wait(Object.java:502) at com.myapp.MyAppApp.main(MyAppApp.java:18) #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 43. Question: Stack-trace is cluttered, how do I shorten it ? #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 44. Question: Stack-trace is cluttered, how do I shorten it ? mjprof jmx/MyApp/ . #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 45. Question: Stack-trace is cluttered, how do I shorten it ? mjprof jmx/MyApp/ . frame/mycompany/ #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 46. Question: Stack-trace is cluttered, how do I shorten it ? mjprof jmx/MyApp/ . frame/mycompany/ -frame/grizzly/ #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 47. Question: Stack-trace is cluttered, how do I shorten it ? mjprof jmx/MyApp/ . frame/mycompany/ -frame/grizzly/ top/3/ #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 48. Question: How can I group threads by state ? #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 49. Question: How can I group threads by state ? mjprof jmx/MyApp/ . group/state/ . gui #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 50. Question: How do I aggregate several thread dumps #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 51. Question: How do I aggregate several thread dumps mjprof jmx/MyApp,10,1000/ #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 52. Question: How do I aggregate several thread dumps mjprof jmx/MyApp,10,1000/ . group/state/ merge #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 53. Question: How do I aggregate several thread dumps mjprof jmx/MyApp,10,1000/ . group/state/ merge . #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 54. Question: How can I combine thread dumps from several processes? #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 55. Question: How can I combine thread dumps from several processes? mjprof jmx/myhost1.com:5467/ . jmx/myhost2.com:5467/ . group/state/ . gui #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 57. How do I measure thread pool CPU consumption? #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 58. How do I measure thread pool CPU consumption? mjprof jmxc/MyApp/ #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 59. How do I measure thread pool CPU consumption? mjprof jmxc/MyApp/ . contains/name,COFFEE/ #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 60. How do I measure thread pool CPU consumption? mjprof jmxc/MyApp/ . contains/name,COFFEE/ . -pkg . group "*" count=7 tid=* cpu_ns=1164536000 wall_ms=4804 %cpu=24.24 java.lang.Thread.State: TIMED_WAITING 100.00% [7/7] at Thread.run(Thread.java:744) 100.00% [7/7] at Sleeper.run(Sleeper.java:51) 100.00% [7/7] at Sleeper.loopForever(Sleeper.java:37) 100.00% [7/7] at Sleeper.longerStackTrace(Sleeper.java:32) 100.00% [7/7] at Sleeper.longerStackTrace(Sleeper.java:32) 100.00% [7/7] at Sleeper.longerStackTrace(Sleeper.java:32) 100.00% [7/7] at Sleeper.longerStackTrace(Sleeper.java:32) 100.00% [7/7] at Sleeper.longerStackTrace(Sleeper.java:32) 100.00% [7/7] at Sleeper.longerStackTrace(Sleeper.java:30) 100.00% [7/7] at Recurse.singleCycle(Recurse.java:16) 100.00% [7/7] at Recurse.doRecursion(Recurse.java:25) 100.00% [7/7] at Recurse.doRecursion(Recurse.java:25) #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 61. Question: Which threads are blocked by the lock I hold #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 62. Question: Which threads are blocked by the lock I hold mjprof path/threaddump.txt/ . blocked . contains/stack,0x00000007aab51b38/ #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 63. Question: What is the overall locking state of my application #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 64. Question: What is the overall locking state of my application mjprof path/threaddump.txt/ . contains/stack,myapp/ locks . "CPU3_5" prio=5 tid=0x00007fc4f4889800 nid=0x5703 waiting for monitor… java.lang.Thread.State: BLOCKED (on object monitor) - waiting to lock <0x00000007aad98988> (a java.lang.Object) "CPU3_4" prio=5 tid=0x00007fc4f404a800 nid=0x5503 waiting for monitor… java.lang.Thread.State: BLOCKED (on object monitor) - waiting to lock <0x00000007aad98988> (a java.lang.Object) "CPU3_3" prio=5 tid=0x00007fc4f4049800 nid=0x5303 waiting on … java.lang.Thread.State: TIMED_WAITING (sleeping) - locked <0x00000007aad98988> (a java.lang.Object) #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 65. 3#! #Devoxx #Performance #AdoptOpenJDK @lifeyx
  • 66. Thanks / Contact Me lifey@performize-it.com blog.performize-it.com www.performize-it.com https://github.com/lifey http://il.linkedin.com/in/haimyadid @lifeyx #Devoxx #Performance #AdoptOpenJDK @lifeyx