LINUX view all threads in progress

Use ps+grep to find the pid of the process under test.
For example: ps –ef|grep notify, the pid is 29128.
2. Execute top -H -p to display all threads under the process. Find the pid of the child thread that occupies the most CPU and convert it to hexadecimal.
For example: top -H -p 29128 to see all child threads of notify. Among them, the pid of the child thread with the largest proportion of %CPU is 879, which is 36f when converted into hexadecimal.
3. Execute jstack|less to find the pid of the child thread to see the stack information.
For example: jstack 29128|less, then look for nid=0x36f, and see the stack as follows
"dispatcherTPConfig-6-thread-22" prio=10 tid=0x000000004dd84000 nid=0x36f runnable [0x000000004ae18000]
java.lang.Thread.State: RUNNABLE
at java .util.ArrayList.contains(ArrayList.java:199)
>
...

4. Follow the method information in the stack to locate the code, and then analyze and optimize.

Postscript:
This method can easily and quickly locate the cause of CPU consumption, but the accuracy is not ideal. If you want to deeply check the method of consuming cpu top10, you can use special performance analysis tools, such as oprofile and perf.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326945057&siteId=291194637