Jprofiler - CPU profiling

Jprofiler can serve many purposes, and CPU profiling and analysis is one of them.

This article is more about how to analyze the collected CPU profile data rather than collecting the data(which is pretty straight forward).

Below are a few points to note while analyzing a CPU profile:

(note: The callStacks have been blacked out purposely)

  1. After collecting the profile, it is ideal to select the "Thread Status" as "All States" to begin with. This makes sure that you don't miss out on the Threads that might be culprits, but are not in Runnable state.


2. Take a quick look at hotspot section to see if there is something that is obvious and wrong. The hot spots view shows a list of calls of a selected type. The list is truncated at the point where calls use less than 0.1% of the total time of all calls. The methods can be sorted based on self-time here and seen if there is any one particular method taking more than necessary time at a glance.


3. Take a look at Threads section, and see if there is any one particular thread that is doing all the work. If yes, and if that is one doing most of the work that you are interested in, then you can set it as root and reduce the noise of other non-required calls.


4. Now go through the CPU call tree and find the method that corresponds to your run which is consuming most of the CPU time and one that looks fishy.

5. Set this method as root (this will reduce the noise of other methods) and subject it to further analysis. (right click > set as root)

-NOTE : This root selected is applied through all the tabs. To see all the calls in any tabs, you need to first remove this root.

6. Next, you can > right click, analysis, calculate cumulative outgoing calls. This is helpful because,  in the regular call tree you will see the calls going out of out of the method for only that particular call stack. But by checking cumulative outgoing call, you can check the all outgoing call from the particular method.


7. As a compliment to "calculate cumulative outgoing calls" you can also check "calculate backtrace to selected method". 

a. This instead of showing the outgoing calls from the method like above, it shows the backtrace that contribute to the invocation of the selected method.

b. Back trace analysis has total time and self-time selection options on the top, much similar to the options in hotspot view

8. Also, it will be interesting now to see the hotspot section, as there will be fewer methods and only the methods of your interest now, due to the root set in step 5. I will show only the hot spot methods under this root.

9. Once you have narrowed down to the method that is taking time, you can use the option "show call graph" to see a pictorial view of inbound and outgoing call from it.


Hope this helps.

要查看或添加评论,请登录

Akshay Deshpande的更多文章

  • [Performance] : What does CPU% usage tell us ?

    [Performance] : What does CPU% usage tell us ?

    [Edit] -- All my latest articles are not published at - https://performanceengineeringin.wordpress.

    6 条评论
  • [Performance] : Understanding CPU Time

    [Performance] : Understanding CPU Time

    As a Performance Engineer, time and again you will come across a situation where you want to profile CPU of a system…

    4 条评论
  • Performance Engineering Checklists

    Performance Engineering Checklists

    Checklists; something that I truly believe in having for everything. Right from list of things to check before leaving…

    5 条评论
  • Random module in Python

    Random module in Python

    Time and again if you are building a small game or if you are trying to pick something randomly in Python, you will…

  • [Linux] Understanding Load Average

    [Linux] Understanding Load Average

    I am writing this quick article to help understand the importance of Load Average in Linux for a Performance Engineer…

    4 条评论
  • Understanding Physical and Logical CPUs

    Understanding Physical and Logical CPUs

    Here is a quick write up on what actually Physical and Logical CPU mean, and how are they different. To begin with, the…

    3 条评论
  • Counter in Python

    Counter in Python

    Counters is the best thing that has happened to Python when you think as a Data analyst. Counters can be used as an…

    2 条评论
  • Learning how to learn [Python]

    Learning how to learn [Python]

    As Brain Herbert has rightly said: It is very much important to learn new things (anything) as learning never ends…

社区洞察

其他会员也浏览了