thread dump analysis
TRANSCRIPT
![Page 1: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/1.jpg)
OverviewReal life situations
Thread dump format
Taking thread dumps
TDA tools
Reading material
Questions
![Page 2: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/2.jpg)
Real life situations
![Page 3: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/3.jpg)
Problems with I/OThreads maybe blocked or perform slowly during access to I/O resources:
File system
Network
Database
Single or multiple thread dumps may help understading the problem
![Page 4: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/4.jpg)
Problems withalgorithms
Algorithm complexity is not suited well for the data set size
Algorithm is overusing expensive resources or memory
Algorithm is overusing locks, while it can be implemented in a lock-free manner
Single or multiple thread dumps may help noticing the problem
![Page 5: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/5.jpg)
Problems withlocks and
syncronizationNo locking (not thread-safe implementations)
Deadlocks (overly syncronised)
Lock contention (overly syncronised)
Lock overhead (too many locks)
Single or multiple thread dumps may explain the situation
![Page 6: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/6.jpg)
Example:HashMap gives100% CPU load
Usage of not syncronised in a multi-threaded applicationHashMap
In certain situations it goes into infinite loop
This causes 100% loadCPU
The probabilty of entering infinite loop depends on the size of the HashMap
Single thread dump reveals the problem
![Page 7: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/7.jpg)
DeadlocksFrom Wikipedia:
“A deadlock is a situation in which two or more competing actions are each waitingfor the other to finish, and thus neither ever does.
![Page 8: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/8.jpg)
DeadlocksIn real life, deadlocks are pretty rare
CPU usage is usally close to 0
Single thread dump can reveal a deadlock situation
![Page 9: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/9.jpg)
Lock contentionFrom Wikipedia:
“This occurs whenever one process or thread attempts to acquire a lock held byanother process or thread. The more granular the available locks, the less likely oneprocess/thread will request a lock held by the other. (For example, locking a rowrather than the entire table, or locking a cell rather than the entire row.)
![Page 10: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/10.jpg)
Lock contentionThe most common problem with multi-threaded applications related to lockhandling
Sometimes easy, sometimes very hard to detect
You can only see one layer at a time
Multiple thread dumps may help to detect lock contention situations
![Page 11: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/11.jpg)
Sporadicapplicationbehaviour
May be related to not thread safe code
May be related to load patterns
May be related to specific data
Threads dumps may or may not help
![Page 12: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/12.jpg)
Thread dumpformat
![Page 13: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/13.jpg)
FormatsFormats differ for various JVM and application server implementations
There is no tool that supports them all
Though format is usually very readble and follows same principles
![Page 14: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/14.jpg)
HotSpot format
![Page 15: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/15.jpg)
Thread states Ihttp://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Thread.State.html
“A thread can be in one of the following states:
NEW - A thread that has not yet started is in this state.
RUNNABLE - A thread executing in the virtual machine is in this state.Java
BLOCKED - A thread that is blocked waiting for a monitor lock is in this state.
![Page 16: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/16.jpg)
Thread states II“
WAITING - A thread that is waiting indefinitely for another thread to perform aparticular action is in this state.
TIMED_WAITING - A thread that is waiting for another thread to perform anaction for up to a specified waiting time is in this state.
TERMINATED - A thread that has exited is in this state.
![Page 17: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/17.jpg)
Taking threaddumps
![Page 18: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/18.jpg)
How?jstack
jconsole
jvisualvm
write your own clientJMX
use your favorite profiler
![Page 19: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/19.jpg)
Demo
![Page 20: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/20.jpg)
Thread dumpanalysis tools
![Page 21: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/21.jpg)
TDA toolsIBM Thread and Monitor Dump analysis
Java Thread Dump Analyzer
Samurai
Thread Dump Analyzer
Thread Dump Viewer
![Page 22: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/22.jpg)
Demo
![Page 23: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/23.jpg)
Book
![Page 24: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/24.jpg)
Questions?
![Page 25: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/25.jpg)
JVM InternalsTraining
Aestas/IT organizes "JVM Internals" training on March 25/26, 2013.
This 2–day course takes the developer on an in-depth tour of the Virtual Machine.JavaIntended for experienced JVM-based programmers, who want to get deeper with theplatform, this course will introduce the major subsystems of the JVM and practical waysto apply this knowledge in real applications.
![Page 26: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/26.jpg)
Topics IHistory of and JVMJava
Specifications
Bytecode
Base components
Detailed architecture
JIT compilation
Garbage collection
Threads
Locks
Classloading
![Page 27: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/27.jpg)
Topics IISecurity
Monitoring tools
Java agents
Debugging
Memory analysis
Tuning principles
GC tuning
Responsiveness and throughput
Tuning Options
![Page 28: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/28.jpg)
RegistrationTraining registration at:
http://aestasit.com/jvm-training-riga-2013
Or by sending e-mail to:
![Page 29: Thread Dump Analysis](https://reader037.vdocuments.mx/reader037/viewer/2022100309/554f38cbb4c905471e8b4881/html5/thumbnails/29.jpg)
Thanks!