Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am trying to get the performance data on a (x86_64) Linux machine using the "perf tool". The intent of this exercise is to find out the "hostspots" in my program when I trigger a specific set of operations that result in high CPU utilization.
The output of the top -H command when I trigger the operations is as follows -
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
733 root 20 0 3682m 3.3g 3.2g R 99 47.3 148:38.14 T1
From the above output,
1. 96% time is spent in running user space processes on CPU 1
2. Thread "T1" is the thread that contributes to the bulk of the CPU utilization and %CPU of this thread is 99
Pls note that the time duration during which the thread T1 reports 99-100% CPU utilization is ~50 seconds
When I look at the perf data captured by executing the command “perf record -e cpu-clock --freq=8000 --call-graph -t 733 sleep 20” during the time thread "T1" reports 99% CPU utilization, this is what I see –
From the above capture, I am not able to find out what the hotspots in my program are.
The overhead of the top 10 functions in the "T1" thread adds up to ~21% and the sum of the overhead percentages of the entire sample set is ~50%. Since the thread "T1" is reporting ~100% CPU utilization (~96% of which is in the user space), I expect that the sum of overhead percentages of user space functions in the perf data to be closer to 96%, which is not the case as per the data captured.
Please let me know on -
1. How to interpret the above perf data and correlate it to the top command output in the above case.
2. Do I need to use some other perf event type other than cpu-clock to get more info on the program hotspots?
TIA,
TachUserQuest
Last edited by TechUserQuest; 03-18-2017 at 05:02 AM.
Reason: The message contents did not get posted the first time around.
Mention of religion in technical threads is not allowed. While I realize the comments were intended to be light hearted, please realize that all may not agree with this interpretation. Furthermore it is perhaps better within a thread to try to help a newly registered LQ member versus attempt to make jokes about their first post.
Hi TechUserQuest and welcome to LQ.
Please realize that the post you've made contains a title along and does not cover any details about your question. Please edit your question or reply to this thread to add more detail. If you have any questions about how to ask a more effective question, or how to use the LQ site, please see the links in the LQ Site FAQ.
Mention of religion in technical threads is not allowed.
You mean other than in signatures? I see direct religious messages in the signature of more than one user here at LQ. Will you be enforcing this rule on them?
You mean other than in signatures? I see direct religious messages in the signature of more than one user here at LQ.
It is allowed in user signatures and not within technical threads.
This was discussed in a thread in the suggestions and feedback forum: here.
Quote:
Originally Posted by MensaWater
Will you be enforcing this rule on them?
Please report discussions or use of religion within technical threads using the report button.
And thank you to TechUserQuest for updating their question. Let's please return to their question now that it has much more detail, and contend with that. Regarding the off-topic stuff, please start a different thread, visit the other discussion I've cited, or send me PM.
@TechUserQuest,
Perhaps your thread is not yielding the CPU properly.
Is there a way you can post the code, or representative code for that thread T1?
Is it a program which you're using the source or have written the source for?
A brute force thing which I've done for performance bottlenecks in my programming is to develop a timestamp macro which sends output to stdout or to a log file and I put the macro at various points in my code, example only, not compiled or tested, just ad hoc written in my reply here:
Code:
#define TIME_MARK(st) (printf("%s::%d.%d\n", st, seconds, milliseconds))
// the seconds and milliseconds I derived from one of the time calls, such as time(), whatever gives me the seconds and nanoseconds since the epoch, or just system start time, I just need something which gives me seconds and milliseconds
//some code
TIME_MARK("a");
function_call();
TIME_MARK("b");
// What that does is tells me about how long I was in my function, named function_call(). I place these around, using the alphabet, or numbers and zero in on what is taking so very long. Sometimes you surprise yourself and then hit yourself up on the side of your head at your stupidity. Or sometimes not.
That is a "for what it's worth" set of thoughts, which is to instrument time markers within your code to help you determine where in your code you take time, with the acceptance that by printing stuff out, you are "taking time". Therefore if you have to figure out milli or micro-seconds worth of precision (1) the general Linux kernel isn't going to help you much, and (2) this method will not work too well for you.
It is allowed in user signatures and not within technical threads.
This was discussed in a thread in the suggestions and feedback forum: here.
Please report discussions or use of religion within technical threads using the report button.
And thank you to TechUserQuest for updating their question. Let's please return to their question now that it has much more detail, and contend with that. Regarding the off-topic stuff, please start a different thread, visit the other discussion I've cited, or send me PM.
@TechUserQuest,
Perhaps your thread is not yielding the CPU properly.
Is there a way you can post the code, or representative code for that thread T1?
Is it a program which you're using the source or have written the source for?
Or do you only have a binary?
Thank you for the response @rtmistler. Thread T1 represents a program that I have the source for. Unfortunately, I cannot post the code. I will check if it is possible to post the representative code and get back.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.