Chris Knight wrote:

Hi all, I found some mention of profiling Apache with gprof via google. I tried the following:

% setenv CFLAGS '-pg -DGPROF -g'
% ./configure [my configure flags]
% make; make install; cd $PREFIX
[alter the conf file to set the MaxRequestsPerChild to 1]
% bin/httpd -X
[make a request and close the connection, which should cause httpd to terminate normally.]


I should end up with a "gmon.out" file that I can then feed to gprof, but I'm not. Is there a step I'm missing and/or is this possible? For that matter, is there any official documentation regarding profiling?

(In reality I want to profile a particular module but I thought it would be interesting to profile all of Apache's internals as well to get a complete picture.)

After Jeff graciously pointed out that some gprof changes had occurred in 2.1-dev, I decided to give it a try and sure enough I could get a gmon.out file. Then, after doing a bunch of diffs, I came to the conclusion that the code defguarded by NO_USE_SIGACTION was removed in 2.1 and I tried defining that, sure enough it works now. Huzzah! (Just thought I'd report in so someone else trying to profile 2.0 will not stumble across this problem.)


So the way to get profiling in 2.0.48:

% setenv CFLAGS '-pg -DGPROF -g -DNO_USE_SIGACTION'
% ./configure [my configure flags]
% make; make install; cd $PREFIX
[alter the conf file to set the MaxRequestsPerChild to 1]
% bin/httpd -X
[make a request and close the connection]

I had a suspicion it had something to do with signals (since you don't get a gmon.out unless the process dies normally). Anyways, fixed a bug in the code along the way. :^)



Reply via email to