CPU performance bottleneck analysis under Linux __linux

Source: Internet
Author: User

Problem Description:

When performing performance tests on notify, the CPU load was suddenly high and CPU utilization was up to 95%. This is the time to troubleshoot which threads consume the CPU, and from the code layer to find CPU-hogging "culprit."

steps:

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

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

2. Execute Top-h-P <pid>, which shows all threads under the process. Locate the most CPU-consuming child thread PID and convert it to 16.

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 is 36f.

3. Perform Jstack <pid>|less, find the thread PID to see the stack information.

For example: Jstack 29128|less, and then look for 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 >

......

4. The method information in the follow-up stack is positioned to the code, and the next step is to analyze the tuning.

PostScript:

This method can simply and quickly locate the reason of CPU consumption, but the accuracy is not ideal. If you want to drill down to the CPU Top10 method, you can use specialized profiling tools, such as Oprofile, perf.

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.