February 3, 2017 Leave a comment
Please go ahead and help yourself by using your favorite os’s package manager to get it installed in the system.
I am gonna play with it bit more to show you how you can manipulate the kernel internal to get the actual picture. But why I said “actual picture“? Because many of userspace tool missed the little stuff underneath to give you a clear view what is going on inside the system.
Well, first thing first (assuming you get over the triviality of installing the tool!),we need to capture the internal state of a running command.How do we do that? But before that, look at the man pages of this tool,it is short and precise,so it won’t take you too much time go through it. It looks something like this if you do man perf on the terminal window.
Then, you need to run perf –help to find out the options it provide and how to use it properly!
Well, now you need to do something (I mean some activity) and impose perf to get the internals for you.The easiest way,I think to run a command on one terminal and run the perf related command on others terminal window! just like below:
Running top -c on one screen window!
Another screen window I ran sudo perf record –all-cpus and wait for few seconds and press CTRL-C to terminate the data capture. In this case, I am trying to capture the all CPU related stats, that is why I passed that argument to perf record.
This captured data is saved in current directory with a name perf.data . Now , I am going to run other perf utility on this file to show . I ran perf script, which show traced data inside that file :
Okay, that’s a fragment of the output ,as I tried to capture the screenful only. But that is good enough to know what it is spitting out.
Then ,again I ran perf stat to find out the measure of any command pass along with it. The double dash (–) is for standard output.
For system profiling I ran perf top –all-cpus to get the enlisting of the current events.
Fine, I need to know what is stored in previously captured perf.data file,kinda report of perf events. For that I ran perf report -i perf.data (this file sits on the directory ,where I am firing this command)
Now, I am gonna capture some memory events in the perf.data file and then display it in below two screenshots. For the first screenshot, I ran perf mem record
And now you can see below the memory get consumed or distributed.
Next, I ran perf annotate , which basically show the codes of the along with assembly code ,next two screenshots are for that..
And look at how firefox’s code getting disassembled!
How to enlist the events captured by perf ? Simple, run perf evlist
Cool, now measuring the kernel memory properties, we need to run perf kmem record and perf kmem stat …..I have captured it in a single screenshot.
If we want to know any specific tool system behaviour on load time with some nice stat and graph ,then perf timechart is your friend. I tried to capture it in below screenshot, I ran perf timechart record top
Now I ran perf timechart and it saves the captured state in a svg file ..
How to see it? Simply open the file in the browser and you can see something similar like this :
And this :
Well, I believe this is enough to gives you heads up about performance measurement.If you are still interested to dig deep and know more about it. Please follow Branden Gregg of Netflix as he is maintaining and doing the bulk of work related to it.
Hope this helps.