编程知识 cdmana.com

The method of checking the high CPU usage in Java field

linux In the environment , Use top -c command , Check the status of each process on the server CPU usage .
b + x, Then you can highlight the rows of interest and the columns that are running . Like my first screenshot . then q sign out top command ,
And then again top -Hp pid, This is me  top -Hp 426476 Check which threads are actually consumed in a single process CPU.
Select a few threads that account for a large proportion id, Use command printf "%x\n" 54956   Put the process id Turn it into 16 Base number
Use jstack Command to view stack information , Specifically :jstack 53514 | grep '0xd6ac' -A10 -A10 After filtering the keywords (A:after)10 Line information , If it's not enough, you can add it yourself .
Final analysis , See if there are any familiar words , Inferring what logic is actually running , preemption CPU

Want to see es What is the thread doing in the process , Not yet , Execution failed .
Let's test it with our own program . Same operation , First ps once , Find the process id, direct top -Hp I want to see the progress id, Then pick a thread in it id, Carry out orders
printf "%x\n" 54956   ( take PID To 16 Base number )
jstack 53514 | grep '0xd6ac' -A10 ( Be careful :16 Add... To the front 0x)
jstack Follow the process id, then grep When , close 16 Base thread id, And then look n That's ok , Then analysis stack Print information

Here you see the name of the thread pool , Combine your own code , It's the program that's consuming kafka Data? .
in addition , You can also print the stack information :jstack 53514 > cpuInfo.txt
And then use cat perhaps less And other command tools for filtering :cat -n cpuInfo.txt | grep -A10 '0xd6ac'

版权声明
本文为[Please call me elder martial brother__]所创,转载请带上原文链接,感谢
https://cdmana.com/2021/04/20210422033801137y.html

Scroll to Top