Show CPU per thread

Show CPU% for each thread to find the hot TID in a busy process before using jstack or perf.

pidstat -t -p <pid> 1

tool
troubleshooting32 commands
tags
troubleshootingperformancecpudebug

More troubleshooting commands

  • top -H -p <pid>

    Watch a process's threads live; convert the hot TID to hex (printf %x) to match nid in jstack.

  • mpstat -P ALL 1

    Show %usr, %sys and %iowait per core to tell one maxed-out core from evenly spread load.

  • vmstat 1 5 | awk 'NR>2{print "runq="$1" blocked="$2}'; nproc

    If the vmstat r column (runnable tasks) is above nproc, the CPU is saturated, not just showing a high load average.

  • ps -o nlwp= -p <pid>; ps -eLf | wc -l

    Count threads for one process and for the whole system; runaway threads can use up kernel.pid_max.

  • while sleep 5; do ps -o rss= -p <pid> | awk '{print strftime("%T"),$1/1024"MB"}'; done

    Sample RSS every 5 seconds to tell a real leak (steady growth) from normal ups and downs.

all 32 troubleshooting commands