Hi!
I'm about to profile our SER installation and since profiling
doesn't run out of the box here's a rough guide:
- you'll need to build SER from sources, thus get sources,
apply your patches and so on
- before compilation get this patch (for CVS HEAD):
http://dump.wormulon.net/patches/ser-profiling.diff
Call
$ patch -p0 < ser-profiling.diff
from the SER base directory.
What it does it invoking monstartup() in each child process
since the profiling information get lost when fork()ing.
I added all childs including timer and fifoserver. If you are
only interested in certain worker processes you can cut down
the resource impact by selectively activating profiling.
- enable profiling in Makefile.defs
- Set both -DPROFILING and PROFILE=-pg
- compile and deploy as usual
- Before starting SER using your standard init script you need
to set an environment variable that acts as a prefix to all
profiling data files. If you don't set it you'll only get one
file for the main process.
# export GMON_OUT_PREFIX=testrun
The gmon files will be named testrun.<PID> with the PID
matching
$ serctl fifo ps
SER may change the current working directory and drop
privileges on the way therefore I suggest you invoke the init
script from the SER working directory (-w option) so you'll
end up with all files in one place.
- Run SER for a while.
Not all gmon files will show up immediately, though.
- You should now be able to get per-process statistics using
$ gprof /usr/sbin/ser testrun.<PID>
- If cummulative statistics are what you are looking for use
$ gprof -s /usr/sbin/ser testrun.*
to create a new gmon.out which contains statistics over all
processes.
I have yet to fully analyze the results.
Cheers (and YMMV),
Hendrik