Thread Dump Analysis

  • 2,436 views
Uploaded on

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,436
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
61
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. OverviewReal life situationsThread dump formatTaking thread dumpsTDA toolsReading materialQuestions
  • 2. Real life situations
  • 3. Problems with I/OThreads maybe blocked or perform slowly during access to I/O resources: File system Network DatabaseSingle or multiple thread dumps may help understading the problem
  • 4. Problems with algorithmsAlgorithm complexity is not suited well for the data set sizeAlgorithm is overusing expensive resources or memoryAlgorithm is overusing locks, while it can be implemented in a lock-free mannerSingle or multiple thread dumps may help noticing the problem
  • 5. Problems with locks 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
  • 6. Example: HashMap gives 100% CPU loadUsage of not syncronised HashMap in a multi-threaded applicationIn certain situations it goes into infinite loopThis causes 100% CPU loadThe probabilty of entering infinite loop depends on the size of the HashMapSingle 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. DeadlocksIn real life, deadlocks are pretty rareCPU usage is usally close to 0Single thread dump can reveal a deadlock situation
  • 9. Lock contentionFrom 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 contentionThe most common problem with multi-threaded applications related to lockhandlingSometimes easy, sometimes very hard to detectYou can only see one layer at a timeMultiple thread dumps may help to detect lock contention situations
  • 11. Sporadic application behaviourMay be related to not thread safe codeMay be related to load patternsMay be related to specific dataThreads dumps may or may not help
  • 12. Thread dump format
  • 13. FormatsFormats differ for various JVM and application server implementationsThere is no tool that supports them allThough format is usually very readble and follows same principles
  • 14. HotSpot format
  • 15. 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 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 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.
  • 17. Taking thread dumps
  • 18. How?jstackjconsolejvisualvmwrite your own JMX clientuse your favorite profiler
  • 19. Demo
  • 20. Thread dumpanalysis tools
  • 21. TDA toolsIBM Thread and Monitor Dump analysisJava Thread Dump AnalyzerSamuraiThread Dump AnalyzerThread Dump Viewer
  • 22. Demo
  • 23. Book
  • 24. Questions?
  • 25. JVM Internals TrainingAestas/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 theplatform, this course will introduce the major subsystems of the JVM and practical waysto apply this knowledge in real applications.
  • 26. Topics IHistory of Java and JVMSpecificationsBytecodeBase componentsDetailed architectureJIT compilationGarbage collectionThreadsLocksClassloading
  • 27. Topics IISecurityMonitoring toolsJava agentsDebuggingMemory analysisTuning principlesGC tuningResponsiveness and throughputTuning Options
  • 28. RegistrationTraining registration at:http://aestasit.com/jvm-training-riga-2013Or by sending e-mail to:training@aestasit.com
  • 29. Thanks!