SlideShare una empresa de Scribd logo
1 de 29
Descargar para leer sin conexión
Overview
Real life situations
Thread dump format
Taking thread dumps
TDA tools
Reading material
Questions
Real life situations
Problems with I/O
Threads 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
Problems with
      algorithms
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
Problems with
      locks and
    syncronization
No 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
Example:
 HashMap gives
 100% CPU load
Usage of not syncronised HashMap in a multi-threaded application
In certain situations it goes into infinite loop
This causes 100% CPU load
The probabilty of entering infinite loop depends on the size of the HashMap
Single thread dump reveals the problem
From Wikipedia:
                   Deadlocks
  “A deadlock is a situation in which two or more competing actions are each waiting
  for the other to finish, and thus neither ever does.
Deadlocks
In real life, deadlocks are pretty rare
CPU usage is usally close to 0
Single thread dump can reveal a deadlock situation
Lock contention
From Wikipedia:

  “This occurs whenever one process or thread attempts to acquire a lock held by
  another process or thread. The more granular the available locks, the less likely one
  process/thread will request a lock held by the other. (For example, locking a row
  rather than the entire table, or locking a cell rather than the entire row.)
Lock contention
The most common problem with multi-threaded applications related to lock
handling
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
Sporadic
             application
             behaviour
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
Thread dump
   format
Formats
Formats 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
HotSpot format
Thread states I
http://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 Java virtual machine is in this state.

       BLOCKED - A thread that is blocked waiting for a monitor lock is in this state.
Thread states II
“
WAITING - A thread that is waiting indefinitely for another thread to perform a
particular action is in this state.
TIMED_WAITING - A thread that is waiting for another thread to perform an
action for up to a specified waiting time is in this state.
TERMINATED - A thread that has exited is in this state.
Taking thread
   dumps
How?
jstack
jconsole
jvisualvm
write your own JMX client
use your favorite profiler
Demo
Thread dump
analysis tools
TDA tools
IBM Thread and Monitor Dump analysis
Java Thread Dump Analyzer
Samurai
Thread Dump Analyzer
Thread Dump Viewer
Demo
Book
Questions?
JVM Internals
           Training
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 Java Virtual Machine.
Intended for experienced JVM-based programmers, who want to get deeper with the
platform, this course will introduce the major subsystems of the JVM and practical ways
to apply this knowledge in real applications.
Topics I
History of Java and JVM
Specifications
Bytecode
Base components
Detailed architecture
JIT compilation
Garbage collection
Threads
Locks
Classloading
Topics II
Security
Monitoring tools
Java agents
Debugging
Memory analysis
Tuning principles
GC tuning
Responsiveness and throughput
Tuning Options
Registration
Training registration at:

http://aestasit.com/jvm-training-riga-2013

Or by sending e-mail to:

training@aestasit.com
Thanks!

Más contenido relacionado

La actualidad más candente

JVM for Dummies - OSCON 2011
JVM for Dummies - OSCON 2011JVM for Dummies - OSCON 2011
JVM for Dummies - OSCON 2011
Charles Nutter
 
Multithreading In Java
Multithreading In JavaMultithreading In Java
Multithreading In Java
parag
 

La actualidad más candente (20)

Spring Boot
Spring BootSpring Boot
Spring Boot
 
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
Performance Tuning -  Memory leaks, Thread deadlocks, JDK toolsPerformance Tuning -  Memory leaks, Thread deadlocks, JDK tools
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
 
WebLogic FAQs
WebLogic FAQsWebLogic FAQs
WebLogic FAQs
 
JVM Memory Management Details
JVM Memory Management DetailsJVM Memory Management Details
JVM Memory Management Details
 
What's new in Java 11
What's new in Java 11What's new in Java 11
What's new in Java 11
 
Introduction to Java 11
Introduction to Java 11 Introduction to Java 11
Introduction to Java 11
 
JVM for Dummies - OSCON 2011
JVM for Dummies - OSCON 2011JVM for Dummies - OSCON 2011
JVM for Dummies - OSCON 2011
 
The JVM is your friend
The JVM is your friendThe JVM is your friend
The JVM is your friend
 
Spring Framework - Data Access
Spring Framework - Data AccessSpring Framework - Data Access
Spring Framework - Data Access
 
Spring boot
Spring bootSpring boot
Spring boot
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring boot
Spring bootSpring boot
Spring boot
 
Spring data jpa
Spring data jpaSpring data jpa
Spring data jpa
 
Hibernate presentation
Hibernate presentationHibernate presentation
Hibernate presentation
 
Multithreading In Java
Multithreading In JavaMultithreading In Java
Multithreading In Java
 
JVM++: The Graal VM
JVM++: The Graal VMJVM++: The Graal VM
JVM++: The Graal VM
 
Java Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and ExampleJava Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and Example
 
Java Presentation For Syntax
Java Presentation For SyntaxJava Presentation For Syntax
Java Presentation For Syntax
 
Multi threading
Multi threadingMulti threading
Multi threading
 
Spring boot
Spring bootSpring boot
Spring boot
 

Destacado

Thread dump troubleshooting
Thread dump troubleshootingThread dump troubleshooting
Thread dump troubleshooting
Jerry Chan
 
IDC & Gomez Webinar --Best Practices: Protect Your Online Revenue Through Web...
IDC & Gomez Webinar --Best Practices: Protect Your Online Revenue Through Web...IDC & Gomez Webinar --Best Practices: Protect Your Online Revenue Through Web...
IDC & Gomez Webinar --Best Practices: Protect Your Online Revenue Through Web...
Compuware APM
 

Destacado (8)

Thread dump troubleshooting
Thread dump troubleshootingThread dump troubleshooting
Thread dump troubleshooting
 
Performance Engineering Basics
Performance Engineering BasicsPerformance Engineering Basics
Performance Engineering Basics
 
IDC & Gomez Webinar --Best Practices: Protect Your Online Revenue Through Web...
IDC & Gomez Webinar --Best Practices: Protect Your Online Revenue Through Web...IDC & Gomez Webinar --Best Practices: Protect Your Online Revenue Through Web...
IDC & Gomez Webinar --Best Practices: Protect Your Online Revenue Through Web...
 
Basic Thread Knowledge
Basic Thread KnowledgeBasic Thread Knowledge
Basic Thread Knowledge
 
Don't dump thread dumps
Don't dump thread dumpsDon't dump thread dumps
Don't dump thread dumps
 
WebSphere Technical University: Top WebSphere Problem Determination Features
WebSphere Technical University: Top WebSphere Problem Determination FeaturesWebSphere Technical University: Top WebSphere Problem Determination Features
WebSphere Technical University: Top WebSphere Problem Determination Features
 
An Introduction to Software Performance Engineering
An Introduction to Software Performance EngineeringAn Introduction to Software Performance Engineering
An Introduction to Software Performance Engineering
 
Hp java heap dump analysis Workshop
Hp java heap dump analysis WorkshopHp java heap dump analysis Workshop
Hp java heap dump analysis Workshop
 

Similar a Thread Dump Analysis

Breaking The Clustering Limits @ AlphaCSP JavaEdge 2007
Breaking The Clustering Limits @ AlphaCSP JavaEdge 2007Breaking The Clustering Limits @ AlphaCSP JavaEdge 2007
Breaking The Clustering Limits @ AlphaCSP JavaEdge 2007
Baruch Sadogursky
 

Similar a Thread Dump Analysis (20)

Multithreading 101
Multithreading 101Multithreading 101
Multithreading 101
 
Java
JavaJava
Java
 
Java Multithreading
Java MultithreadingJava Multithreading
Java Multithreading
 
Java multithreading
Java multithreadingJava multithreading
Java multithreading
 
Multithreading
MultithreadingMultithreading
Multithreading
 
multithreading
multithreadingmultithreading
multithreading
 
Java
JavaJava
Java
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Java Multithreading and Concurrency
Java Multithreading and ConcurrencyJava Multithreading and Concurrency
Java Multithreading and Concurrency
 
jvm/java - towards lock-free concurrency
jvm/java - towards lock-free concurrencyjvm/java - towards lock-free concurrency
jvm/java - towards lock-free concurrency
 
Multithreading and concurrency in android
Multithreading and concurrency in androidMultithreading and concurrency in android
Multithreading and concurrency in android
 
Thread priorities in java
Thread priorities in javaThread priorities in java
Thread priorities in java
 
Threading in java - a pragmatic primer
Threading in java - a pragmatic primerThreading in java - a pragmatic primer
Threading in java - a pragmatic primer
 
Slide 7 Thread-1.pptx
Slide 7 Thread-1.pptxSlide 7 Thread-1.pptx
Slide 7 Thread-1.pptx
 
Java Threading
Java ThreadingJava Threading
Java Threading
 
Java concurrency
Java concurrencyJava concurrency
Java concurrency
 
Here comes the Loom - Ya!vaConf.pdf
Here comes the Loom - Ya!vaConf.pdfHere comes the Loom - Ya!vaConf.pdf
Here comes the Loom - Ya!vaConf.pdf
 
Breaking The Clustering Limits @ AlphaCSP JavaEdge 2007
Breaking The Clustering Limits @ AlphaCSP JavaEdge 2007Breaking The Clustering Limits @ AlphaCSP JavaEdge 2007
Breaking The Clustering Limits @ AlphaCSP JavaEdge 2007
 
J threads-pdf
J threads-pdfJ threads-pdf
J threads-pdf
 
Java threading
Java threadingJava threading
Java threading
 

Más de Dmitry Buzdin

Developing Useful APIs
Developing Useful APIsDeveloping Useful APIs
Developing Useful APIs
Dmitry Buzdin
 
Архитектура Ленты на Одноклассниках
Архитектура Ленты на ОдноклассникахАрхитектура Ленты на Одноклассниках
Архитектура Ленты на Одноклассниках
Dmitry Buzdin
 
Riding Redis @ask.fm
Riding Redis @ask.fmRiding Redis @ask.fm
Riding Redis @ask.fm
Dmitry Buzdin
 
Rubylight JUG Contest Results Part II
Rubylight JUG Contest Results Part IIRubylight JUG Contest Results Part II
Rubylight JUG Contest Results Part II
Dmitry Buzdin
 
Rubylight Pattern-Matching Solutions
Rubylight Pattern-Matching SolutionsRubylight Pattern-Matching Solutions
Rubylight Pattern-Matching Solutions
Dmitry Buzdin
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
Dmitry Buzdin
 
Poor Man's Functional Programming
Poor Man's Functional ProgrammingPoor Man's Functional Programming
Poor Man's Functional Programming
Dmitry Buzdin
 
Rubylight programming contest
Rubylight programming contestRubylight programming contest
Rubylight programming contest
Dmitry Buzdin
 
Continuous Delivery
Continuous Delivery Continuous Delivery
Continuous Delivery
Dmitry Buzdin
 
Introduction to DevOps
Introduction to DevOpsIntroduction to DevOps
Introduction to DevOps
Dmitry Buzdin
 
Pragmatic Java Test Automation
Pragmatic Java Test AutomationPragmatic Java Test Automation
Pragmatic Java Test Automation
Dmitry Buzdin
 

Más de Dmitry Buzdin (20)

How Payment Cards Really Work?
How Payment Cards Really Work?How Payment Cards Really Work?
How Payment Cards Really Work?
 
Как построить свой фреймворк для автотестов?
Как построить свой фреймворк для автотестов?Как построить свой фреймворк для автотестов?
Как построить свой фреймворк для автотестов?
 
How to grow your own Microservice?
How to grow your own Microservice?How to grow your own Microservice?
How to grow your own Microservice?
 
How to Build Your Own Test Automation Framework?
How to Build Your Own Test Automation Framework?How to Build Your Own Test Automation Framework?
How to Build Your Own Test Automation Framework?
 
Delivery Pipeline for Windows Machines
Delivery Pipeline for Windows MachinesDelivery Pipeline for Windows Machines
Delivery Pipeline for Windows Machines
 
Big Data Processing Using Hadoop Infrastructure
Big Data Processing Using Hadoop InfrastructureBig Data Processing Using Hadoop Infrastructure
Big Data Processing Using Hadoop Infrastructure
 
JOOQ and Flyway
JOOQ and FlywayJOOQ and Flyway
JOOQ and Flyway
 
Developing Useful APIs
Developing Useful APIsDeveloping Useful APIs
Developing Useful APIs
 
Whats New in Java 8
Whats New in Java 8Whats New in Java 8
Whats New in Java 8
 
Архитектура Ленты на Одноклассниках
Архитектура Ленты на ОдноклассникахАрхитектура Ленты на Одноклассниках
Архитектура Ленты на Одноклассниках
 
Dart Workshop
Dart WorkshopDart Workshop
Dart Workshop
 
Riding Redis @ask.fm
Riding Redis @ask.fmRiding Redis @ask.fm
Riding Redis @ask.fm
 
Rubylight JUG Contest Results Part II
Rubylight JUG Contest Results Part IIRubylight JUG Contest Results Part II
Rubylight JUG Contest Results Part II
 
Rubylight Pattern-Matching Solutions
Rubylight Pattern-Matching SolutionsRubylight Pattern-Matching Solutions
Rubylight Pattern-Matching Solutions
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Poor Man's Functional Programming
Poor Man's Functional ProgrammingPoor Man's Functional Programming
Poor Man's Functional Programming
 
Rubylight programming contest
Rubylight programming contestRubylight programming contest
Rubylight programming contest
 
Continuous Delivery
Continuous Delivery Continuous Delivery
Continuous Delivery
 
Introduction to DevOps
Introduction to DevOpsIntroduction to DevOps
Introduction to DevOps
 
Pragmatic Java Test Automation
Pragmatic Java Test AutomationPragmatic Java Test Automation
Pragmatic Java Test Automation
 

Thread Dump Analysis

  • 1. Overview Real life situations Thread dump format Taking thread dumps TDA tools Reading material Questions
  • 3. Problems with I/O Threads 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
  • 4. Problems with algorithms 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
  • 5. Problems with locks and syncronization No 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
  • 6. Example: HashMap gives 100% CPU load Usage of not syncronised HashMap in a multi-threaded application In certain situations it goes into infinite loop This causes 100% CPU load The probabilty of entering infinite loop depends on the size of the HashMap Single thread dump reveals the problem
  • 7. From Wikipedia: Deadlocks “A deadlock is a situation in which two or more competing actions are each waiting for the other to finish, and thus neither ever does.
  • 8. Deadlocks In real life, deadlocks are pretty rare CPU usage is usally close to 0 Single thread dump can reveal a deadlock situation
  • 9. Lock contention From Wikipedia: “This occurs whenever one process or thread attempts to acquire a lock held by another process or thread. The more granular the available locks, the less likely one process/thread will request a lock held by the other. (For example, locking a row rather than the entire table, or locking a cell rather than the entire row.)
  • 10. Lock contention The most common problem with multi-threaded applications related to lock handling 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
  • 11. Sporadic application behaviour 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
  • 12. Thread dump format
  • 13. Formats Formats 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
  • 15. Thread states I http://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 Java virtual machine is in this state. BLOCKED - A thread that is blocked waiting for a monitor lock is in this state.
  • 16. Thread states II “ WAITING - A thread that is waiting indefinitely for another thread to perform a particular action is in this state. TIMED_WAITING - A thread that is waiting for another thread to perform an action for up to a specified waiting time is in this state. TERMINATED - A thread that has exited is in this state.
  • 17. Taking thread dumps
  • 18. How? jstack jconsole jvisualvm write your own JMX client use your favorite profiler
  • 19. Demo
  • 21. TDA tools IBM Thread and Monitor Dump analysis Java Thread Dump Analyzer Samurai Thread Dump Analyzer Thread Dump Viewer
  • 22. Demo
  • 23. Book
  • 25. JVM Internals Training 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 Java Virtual Machine. Intended for experienced JVM-based programmers, who want to get deeper with the platform, this course will introduce the major subsystems of the JVM and practical ways to apply this knowledge in real applications.
  • 26. Topics I History of Java and JVM Specifications Bytecode Base components Detailed architecture JIT compilation Garbage collection Threads Locks Classloading
  • 27. Topics II Security Monitoring tools Java agents Debugging Memory analysis Tuning principles GC tuning Responsiveness and throughput Tuning Options