Hot Thread Identification


Diffusion 5.9

Diffusion 6.0

Diffusion 6.1

Diffusion 6.2

Diffusion 6.3

Diffusion Cloud


The following article is provided on an advice basis only. This article references third party software that may require licensing. This article describes how to identify which threads inside a Java process are consuming most CPU resources. This article assumes the Java process is running on Linux, since a Linux thread is the same as a process.

1. Getting thread / process IDs

Use the system performance analysis tool to find which thread is consuming excessive CPU resources. On Linux, use the top command with the -H flag to show all threads.

top -H

The processes are broken down into threads and listed in order of CPU consumption. Here, the thread which is using the most CPU is highlighted. Note the thread’s Process ID (PID), since you will need it in the following steps.

2. Getting the parent Java process

Use grep to get the TGID (thread group ID).

grep -i tgid /proc/${hot-thread-PID}/status

For this example, ${hot-thread-PID} = 19964 and it returns TGID = 8041.

3. Finding the Java thread from the process PID

Use the jcmd tool to create three thread dumps in intervals from 2 to 10 seconds, with the TGID from Step 2 as an argument:

jcmd ${TGID} Thread.print >> $TGID.threads

For this example, ${TGID} = 8041. You can also use the jcmd Script from the Thread Dumps knowledge base article for this purpose. Convert the PID of the hot thread identified in Step 1 into hex, using the command:

echo "obase=16; ${hot-thread-PID}" | bc

For this example, the hex output is 0x4dfc. Open the file with the thread dump, then find the thread with the nid equal to the PID in hex. If there is more than one entry for the same thread (which in this example is called multiplexer4), this might indicate that the program is spending excessive time to execute the same code over a short period of time.

4. Sending to Push support

Once you have determined the PID of the thread which is consuming excessive CPU resources, please send this and your compressed thread dump to Push Technology support.