Possible Duplicate:
Saving gmon.out before killing a process
I'm trying to profile a server (source code available to me. c-code) on Linux environment. This server runs continuously like a web server. I'm trying to use gprof to profile the server. If the server exits by itself, gmon.out file is generated. I can use gprof and gmon.out to understand profiled data. Now the problem I have is, this server is running continuously, waiting for incoming socket connections, requests etc. If I kill this server, gmon.out is not generated. At this point I see the following options.
EDIT: The server is multi-process server. running on FreeBSD 7.2
I'm sure, people have solved these kind of problems before. I failed to find useful information on SO or outside.
I appreciate any thoughts/solutions people have.
Thanks a bunch.
UPDATE 1:
Somehow I managed to get ports for valgrind. When I run make I get the following errors.
=> valgrind-stable-352.tar.gz doesn't seem to exist in /usr/obj/ports/distfiles/.
=> Attempting to fetch from ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/.
fetch: ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/valgrind-stable-352.tar.gz: File unavailable (e.g., file not found, no access)
=> Attempting to fetch from http://www.rabson.org/.
fetch: http://www.rabson.org/valgrind-stable-352.tar.gz: No address record
=> Couldn't fetch it - please try to retrieve this
=> port manually into /usr/obj/ports/distfiles/ and try again.
*** Error code 1
I tried to find valgrind-stable-352.tar.gz on web. All of the links I found are dead.
I got pstack installed on my freebsd and the realised pstack gives only stack trace. reference : http://sourceforge.net/projects/bsd-pstack/
My understanding is that systemtap is only for kernel-space events, instrumentation etc.
I could be wrong or have insufficient information. Please correct me and give your thoughts. I really appreciate your assistance.
UPDATE 2: I think it will be helpful to give some details about the server that I'm trying to profile.
While you certainly should take your precations on profiling critical production systems, use oprofile or/and systemtap , They're likely included with your distro already.
Even if you get gprof to serve you, there are problems.
It is blind to any system calls or I/O. It is based on the assumption that you will never do an unnecessary hang. It only looks at CPU-bound issues.
If there is any recursion, it just can't handle it.
The times it gives you are based on shaky assumptions, such as that every call to a routine takes about the same amount of time. It gives you no line-level information.
Measuring is one thing, but if you want to find "bottlenecks" that are doing unnecessary things, whether CPU or I/O, a very rough but effective tool is lsstack
(which I think is on SourceForge).
Also, take a look at Zoom. It is a wall-time stack-sampler for Linux. It gives line-level percents, and I believe it can be attached and detached from a running process.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With