CPU Performance bottleneck analysis case in Linux

Source: Internet
Author: User

Problem Description:

When performing performance tests on notify, it was found that the CPU load suddenly soared and CPU utilization was as high as 95%. It is time to troubleshoot which threads consume the CPU and find the "culprit" that consumes the CPU from the code layer.

Steps:

1. First use Ps+grep to find the process PID being tested.

For example: Ps–ef|grep notify, get PID 29128.

2. Execute Top-h-p to display all threads under the process. Find the most CPU-intensive child-thread PID and convert it to 16-binary.

For example: Top-h-P 29128, see all child threads of notify. Among them, the%cpu proportion of the largest sub-thread PID is 879, converted to 16 binary is 36f.

3. Execute jstack|less and find the child thread PID to see the stack information.

For example: Jstack 29128|less, and then find nid=0x36f, 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)

<notify related stack information hiding < span= "" >>

......

4. Follow the method information in the stack to navigate to the code, and the next step is to analyze the tuning.

Postscript:

This method can easily and quickly locate the cause of CPU consumption, but the accuracy is not ideal. If you want to drill down into the methods that consume CPU TOP10, you can use specialized profiling tools, such as Oprofile, perf, and so on.

CPU Performance bottleneck analysis case in Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.