Re: Cumulative samples without callgraph?

William Cohen <[email protected]>
Newsgroups gmane.linux.oprofile
Message-ID <[email protected]>
On 05/13/2015 11:55 AM, Nikolaus Rath wrote:
> On 05/12/2015 07:55 PM, William Cohen wrote:
>> On 04/16/2015 01:00 PM, Nikolaus Rath wrote:
>>> Hello,
>>>
>>> I have gathered some profile data using just "operf <program>"
>>> (i.e., no -g option to gather callgraph data).
>>>
>>> However, when looking at the gmon output with
>>>
>>> $ opgprof <program> $ gprof -p <program> | head
>>>
>>> I find that there are distinct counts for cumulative and self:
>>>
>>>> Flat profile:
>>>>
>>>> Each sample counts as 1 samples. %   cumulative   self
>>>> self     total time   samples   samples    calls  T1/call
>>>> T1/call  name 5.19 14089090.00 14089090.00
>>>> dagmg_mumps_302_ 4.85 27256080.00 13166990.00
>>>> mcdriver_mp_mc_push_ 4.83 40373868.00 13117788.00
>>>> dagmg_mumps_249_ 4.56 52738720.00 12364852.00
>>>
>>>
>>> I'm confused by this. Doesn't "cumulative" mean the time spend in
>>> a function including time spend in calls to other functions? But if
>>> operf didn't look at the callgraph, how can it know anything about
>>> this? I thought that for every sample operf just records what
>>> function is being executed, but not how this function was called.
>>>
>>
>> gprof is only providing the flat sample information.  The cumulative
>> samples is the sum of all the samples up to that point. Thus, the
>> first line cumulative samples has 14089090.00, second line is
>> 14089090+13117788=27256080, the third line is
>> 14089090+13117788+13117788=40373868.
> 
> Ah, thank you! So just to make sure: this cumulative count is thus not
> at all what "cumulative" means when the profiling data is generated by
> e.g. "gcc -pg", and it does not tell me anything about how much time was
> spent with a given function on the stack?
> 
> Best,
> -Nikolaus
> 

Hi Nikolaus,

The gcc -pg option includes code to record calls/returns so gprof can generate call graph information fill out the other columns.  the "total ms/call" is probably what you are thinking of.  That should include the time of children.  You can see that in the example output on:

https://sourceware.org/binutils/docs/gprof/Flat-Profile.html#Flat-Profile

-Will

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.