|
From: John R. <jr...@bi...> - 2013-02-06 15:33:08
|
> I have a simple question. I'm using Valgrind for database profiling. The db server is a daemon program, and it seems I can only do profiling by attaching Valgrind to the daemon. I googled and still cannot find the answer. > Please let me know how can I do that. BTW, the kcachegrind website(http://kcachegrind.sourceforge.net/) has been available. It would help if there were more explanation than just "database profiling." Ordinarily "profiling" means applying some measurements to the dynamic subroutine call graph, such as: count the number of times each subroutine is entered (and perhaps from which caller), time the duration of execution within each subroutine (and perhaps as a "black box" [including all routines that it calls], and perhaps separated by which routine was the caller.) Or, use "cache misses" as the measurement unit (instead of nanoseconds); etc. Anyway, apply the usual trick for intercepting daemons: Move the current executable program somewhere else (give it a new name or a new directory), create an executable shell script which invokes valgrind on the moved daemon, and put the shell script at the old pathname of the daemon. Then terminate execution of the current daemon process ("kill -TERM <pid>", etc.) and re-start the daemon; sometimes such a restart is "automatic". If you have "no control" over the daemon, then 'oprofile' might be the only effective option. Oprofile can be invoked at any time, then samples the pc and accumulates a histogram of which subroutine it was in. -- |