Skip to content

Instantly share code, notes, and snippets.

@directorscut82
Created January 11, 2018 13:30
Show Gist options
  • Save directorscut82/d75f3544c312a0ef3403c4b6ba1d78f2 to your computer and use it in GitHub Desktop.
Save directorscut82/d75f3544c312a0ef3403c4b6ba1d78f2 to your computer and use it in GitHub Desktop.
[find highest cpu usage per thread] #CLI
Just to clarify all the steps required to diagnose this issue. (thanks everyone for postings) :
Following command shows the list of process with their CPU / Memory usage :
ps auxf
Following command gives the list of all threads of a process sorted with CPU usage.
top -H -p [PID]
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1654 root 20 0 1416m 1.2g 24m t 100 36.8 21:26.23 python
1687 root 20 0 1416m 1.2g 24m t 0 36.8 0:05.07 python
Thread 1654 is chewing CPU. Attach gdb to the process
gdb /path/of/process [pid]
Following command in gdb to get list of threads
(gdb) info threads
2 Thread 0xa7bffb40 (LWP 20736) "python" 0xb7736424 in __kernel_vsyscall ()
1 Thread 0xb73a56c0 (LWP 1654) "python" 0xb7736424 in __kernel_vsyscall ()
in gdb switch to the thread to check its stack.
(gdb) thread 1
(gdb) bt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment