Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to profile a continuously running server running on FreeBSD
    text
    copied!<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/10205543/saving-gmon-out-before-killing-a-process">Saving gmon.out before killing a process</a> </p> </blockquote> <p>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.</p> <ol> <li>change the source code to profile itself and log this information after receiving SIGKILL signal. This is by far the ugliest solution and may introduce noise in the measurement.</li> <li>Maybe there is a way to profile this server using gprof while the server is still running.</li> <li>Other tools to try?</li> </ol> <p><strong>EDIT:</strong> The server is multi-process server. running on FreeBSD 7.2</p> <p>I'm sure, people have solved these kind of problems before. I failed to find useful information on SO or outside.</p> <p>I appreciate any thoughts/solutions people have.</p> <p>Thanks a bunch.</p> <p><strong>UPDATE 1:</strong> </p> <ol> <li>gprof doesn't seem to work with multi-process server. When I manage to get gmon.out after executing my server, only parent process is instrumented which actually doesnt do real work!.</li> <li>oProfile doesn't support FreeBSD which is what my server is running on. For various reasons I can't(not allowed to) change OS.</li> <li>Valgrind website doesnt have a port for FreeBSD. But there are some references to a port to FreeBSD. I failed to find FreeBSD port source. </li> </ol> <p>Somehow I managed to get ports for valgrind. When I run make I get the following errors.</p> <pre><code>=&gt; valgrind-stable-352.tar.gz doesn't seem to exist in /usr/obj/ports/distfiles/. =&gt; 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) =&gt; Attempting to fetch from http://www.rabson.org/. fetch: http://www.rabson.org/valgrind-stable-352.tar.gz: No address record =&gt; Couldn't fetch it - please try to retrieve this =&gt; port manually into /usr/obj/ports/distfiles/ and try again. *** Error code 1 </code></pre> <p>I tried to find valgrind-stable-352.tar.gz on web. All of the links I found are dead.</p> <ol start="4"> <li><p>I got pstack installed on my freebsd and the realised pstack gives only stack trace. reference : <a href="http://sourceforge.net/projects/bsd-pstack/" rel="nofollow noreferrer">http://sourceforge.net/projects/bsd-pstack/</a></p></li> <li><p>My understanding is that systemtap is only for kernel-space events, instrumentation etc. </p></li> </ol> <p>I could be wrong or have insufficient information. Please correct me and give your thoughts. I really appreciate your assistance.</p> <p><strong>UPDATE 2</strong>: I think it will be helpful to give some details about the server that I'm trying to profile.</p> <ol> <li>it is multi-server program. I/O bound, to be specific mysql database.</li> <li>No threads involved. Each child-server-process handles only one request. configurable number of processes are created when the server starts.</li> <li>I would like to find time spent in each function and its frequency. function codes are a mix of CPU-bound and IO bound (I believe more IO).</li> <li>it is running on FreeBSD 7.2</li> <li>written in c. number of reads is much greater than writes to the database via this server.</li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload