2017tjp erik ostermuellercmgcanada.altervista.org/presentations/2018 apr pres/mtdp_ expos… ·...
TRANSCRIPT
![Page 1: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/1.jpg)
Erik Ostermueller Author of
Troubleshooting Java Performance
http://bit.ly/2017tjp
Author of Java performance certification exam at
http://c0d3r.org
java architect
lead performance engineer
FIS Global
@EOstermueller
erikostermueller.com
1
![Page 2: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/2.jpg)
P.A.t.h Checklistwhere to look for
performance defects
● Persistence● Alien systems● threads● heap
2
![Page 3: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/3.jpg)
mTDpthe missing Visibility Tool
That will change everything
manual Thread Dump profiling
3
![Page 4: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/4.jpg)
The problem: How can I Troubleshoot
any running jvm?
4
![Page 5: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/5.jpg)
Don't need:● license for the expensive APM tool● JMX enabled● a java profiler installed● access to that environment
Any running JVM?Yes!!!!
5
![Page 6: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/6.jpg)
Finally troubleshootAnyRunningJVM
6
![Page 7: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/7.jpg)
Plug it in now!Don’t make me restart my JVMDon’t make me install stuff
7
![Page 8: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/8.jpg)
Why don’t more people use mTDp?● mTDp is hiding in a messy closet of
under-documented perf techniques ( Building Better Applications / 1994 )
● Perhaps mTDp is mathematically misconstrued?
http://ostermueller.blogspot.com/2017/04/the-math-behind-manual-thread-dump.html
8
![Page 9: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/9.jpg)
Thread Dumps: Old school and New schoolWithout mTDp, thread dumps diagnose these:
With mTDp we can solve many more problems!
9
![Page 10: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/10.jpg)
60 seconds on Thread Dump
the basic
10
![Page 11: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/11.jpg)
Jstack is low overhead
I use it regularly in prod and test
11
![Page 12: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/12.jpg)
Capture a Simple Thread DUmp
12
![Page 13: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/13.jpg)
Thread dump example: Jstack <myPid> or “kill -3”
13
![Page 14: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/14.jpg)
Landmarks in a Stack Trace (my terms)● Current - running on CPU when jstack was invoked● Trigger - your code that leads to ‘Current’ ● Entry - The protocol (HTTP, JMS) that started thread
14
![Page 15: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/15.jpg)
A Big Scary Stack Trace
15
![Page 16: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/16.jpg)
16
![Page 17: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/17.jpg)
17
![Page 18: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/18.jpg)
mTDp:A Description
18
![Page 19: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/19.jpg)
Take four or so thread dumps …as load is applied …with a few seconds between each
19
Step 1
![Page 20: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/20.jpg)
If something that you could fix…shows up in the dumps …for two or more threads …that are under load, then it is worth fixing!
20
Step 2
![Page 21: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/21.jpg)
A Visual of Four Thread Dumps
21
![Page 22: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/22.jpg)
mTDpTips
22
![Page 23: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/23.jpg)
Focus on Threads Under Load
(assume your code is the problem)
● Focus on all stack traces containing your package name!
● Focus on all stack traces started by your end users’ protocol.
If an HTTPS system, look for threads with an “entry” marked with HTTPS-ish class names.
23
![Page 24: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/24.jpg)
“web container” threads
24
Examples of HTTP Threads:
![Page 25: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/25.jpg)
● Which SQL statement is slow?● Slow backend system?● Great concurrency metric!● Great connection pool metric!● more!
Other mTDp Tricks:
25
![Page 26: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/26.jpg)
Common ways to mess up mTDp● Make judgements based on just one thread dump
FIX → take 4 or more
● Make judgements based on system with low-load or no-loadFIX → check for moderate CPU use
26
![Page 27: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/27.jpg)
Common ways to mess up mTDp (part 2)● Don’t lose focus of the threads under load.
○ If an HTTPS system, look for threads with an “entry” marked with HTTPS-ish class names.
○ If a JMS system, look for threads with an “entry” marked with JMS-ish class names.
● Thread dumps don’t show GC/heap problemsFIX → use jstat for a “plug-it-in-now” view of GC.
27
![Page 28: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/28.jpg)
Reminder: GC issues don’t show up in thread dumps
28
![Page 29: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/29.jpg)
Use vi and notepad++
Thread Dump analysis tools are great, but they limit you to the tip of the iceberg.
29
![Page 30: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/30.jpg)
mTDp can detect problems large (>1s) and small (2-3ms)
30
![Page 31: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/31.jpg)
mTDpDemo
31
![Page 32: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads](https://reader035.vdocuments.site/reader035/viewer/2022070823/5f32806884397f1180559f34/html5/thumbnails/32.jpg)
THE ENDErik Ostermueller Author of
Troubleshooting Java Performance
http://bit.ly/2017tjp
Author of Java performance certification exam at
http://c0d3r.org
java architect
lead performance engineer
FIS Global
@EOstermueller
erikostermueller.com
32