Thread Dump Analyzer

All

Intro

    Sometimes, on Java we can’t trace or profile since instrumentation would take too long, so then thread dumps seem an appropriate tool.  This article is partially based on Pierre’s course[2] and Confluence Support [4].

   Although not a tracing technique, using this tool is possible to do a sampling recording, getting a set of snapshots with the same delay.

Thread Dump Basic

    Well, the dump itself is an execution snapshot of the threads created in Java. The skill to differentiate the threads you care is something to be developed and can be partially solved using the tools – that I talk below.  It is indeed a collection of stack trees. The threads have basically 6 states [4]:

  • NEW
  • RUNNABLE
  • BLOCKED
  • WAITING
  • TIMED_WAITING
  • TERMINATED

Thread Dump Generation

       It’s possible to use JPS to find the applications running Java. 

        1 – kill -3 [pid] –> signal to the process to tomcat

        2 – Jstack command                      

        3 – Java Visual VM [5]

                     Very visual method but we can see the live threads on the console.

        4 – Console – dump straight from the console 

Thread Dump Analysis

        It is technically a screenshot of the threads. It will bring info and several tools can be used to analyze it, though it’s possible to analyze straight from the file, which highlights some details the on the file.

       Don’t analyze all the threads but rather try to find a pattern from a few patterns, with locked threads and all this. This type of analysis can show Heat Depletion [3], in which Pierre-Hugues describes a Thread Dump analysis only using txt analysis.

TDA Tools

   But the manual analysis will become difficult, either because is long or is complex threads, blocked threads, and deadlocked threads are easier to find using a TDA tool, like TDA or Samurai.

Thread Dump Analyzer

      The so-called TDA is an analyzer, is a visualization tool that is used after having the log data using jstack utility, which is part of the JDK not the JRE. 

     Then you can run TDA using  java -jar tda.jar

     We can see then the threads using the visualization tool.

Other tools

     The article [1] compares in some aspects Samurai and TDA tool, according to the author, John Mazzitelli, Samurai loses points by the threads names but appreciated the grouping mechanism used that combines threads with a similar state.

REFs

[1] https://planet.jboss.org/post/simple_tools_to_analyze_thread_dumps

[2] https://www.youtube.com/watch?v=1qzHSEjU8Hc&list=PLeLNWvESQ0GaJv8VCelD0bXiTIcVCRuSC

[3]https://www.youtube.com/watch?v=3dKufRRT_3E

[4] https://confluence.atlassian.com/confkb/how-to-analyse-thread-dumps-788039144.html

[5] https://visualvm.github.io/



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s