performance profiling with gprof

Status
Not open for further replies.

_klamath_

Ars Scholae Palatinae
770
I'm trying to use gprof to get some performance data on a fairly large application. For every incoming connection, a new server process is forked; when the connection terminates, the child exits. I need to get profiling information for a single one of those forked children. I've re-compiled the application with "-pg", and I get a gmon.out file for each child. However, the problem is that the data seems to be incomplete: after I execute "gprof /path/to/profiled/executable /path/to/gmon.out", the output begins with:

Code:
Flat profile:

Each sample counts as 0.01 seconds.
no time accumulated

%   cumulative   self              self     total           
time   seconds   seconds    calls  Ts/call  Ts/call  name    
0.00      0.00     0.00  2687913     0.00     0.00  BufferGetBlockNumber
0.00      0.00     0.00  1225023     0.00     0.00  ReadBufferInternal
0.00      0.00     0.00  1223633     0.00     0.00  ReadBuffer

And so on for a couple thousand lines (i.e. there is no timing data getting recorded; the names of the functions and the number of function calls seems to be correct, but without timing data it's not very useful). The child itself takes about 60 seconds to process the connection, so I know that something is definately wrong.

Any idea what I could be doing wrong?

TIA
 

_klamath_

Ars Scholae Palatinae
770
No, gprof enables timing data by default -- for example, I created a very simple C app (50 lines of code), on the same machine (with the same compiler and compilation flags), which produces the following gprof output:

Code:
Flat profile:

Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total
 time   seconds   seconds    calls  us/call  us/call  name
 99.95     43.51    43.51   285000   152.67   152.67  called_rarely
  0.02     43.52     0.01   300000     0.03     0.03  called_often
  0.02     43.53     0.01                             main

(And a bunch more lines -- the key being that timing that is being recorded properly.)

Thanks for the suggestion, but that doesn't seem to be it. Does anyone else have any ideas?

TIA
 

Matty

Ars Scholae Palatinae
649
Not sure how old this is, so it may no longer be releveant:

http://www.engin.umich.edu/labs/cpc/resources/software/ibm/gprof.html

"Profiling using the gprof command is problematic if your program runs the fork or exec subroutine on multiple, concurrent processes. Profiling is an attribute of the environment of each process, so if you are profiling a process that forks a new process, the child is also profiled. However, both processes write a gmon.out file in the directory from which you run the parent process, overwriting one of them."

Google is your friend :)

Matty
 
Status
Not open for further replies.