httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Carlson <jcarl...@jnous.com>
Subject Re: How to profile apache?
Date Thu, 10 Apr 2003 22:41:07 GMT
Well, I'll go ahead and answer my own question, in case it helps someone else. 
Here are the observations I made in getting profiling to work.

1) gcc on solaris (at least 2.95.3 thru 3.2.2) defines moncontrol in gmon.o as 
static, which means Apache won't compile with -DGPROF.  However, changing the 
definition of MONCONTROL to a noop seems to work fine -- apparently Solaris 
carries the monitor status across a fork.

2) the default GprofDir is logs/, which means your Apache user needs permission 
to write there (unlike the normal case in which the logs are opened with the uid 
of the user running apachectl).  This was my main mistake, at first.  Also I 
learned that it's necessary to set GprofDir to a value ending in '%' to get any 
meaningful results for gprof.

3) as far as I can tell, gprof doesn't support profiling shared libraries (with 
the exception of LD_PROFILE, which is fairly limited), so it's a good idea to 
link apr, apr-util, etc with httpd statically.  I achieved this by passing 
PROGRAM_LDFLAGS=-static to make (don't know what the right way is).  Also, I 
linked the module I wanted to test statically, by passing --with-module to 
configure, and mucking about until my code matched the necessary conventions.

4) there's a bug in prefork.c that creates GprofDir directories with goofy 
permissions (--xrw-r-x, with a umask of 022 becomes --xr--r-x) which bit me. 
C.f. the patch I sent yesterday.

... I think that's it.  Now it's time to interpret the results!  Anyway, I hope 
this helps some other developer, someday.

Jim


Jim Carlson wrote:
> Hello,
>   I'm sure this is an oft answered question, but I can't seem to get 
> useful data from gprof with apache.  I've tried compiling Apache with 
> the following configure line:
> 
>   CC=gcc CFLAGS="-pg -DGPROF" ./configure
> 
> and running it with:
> 
>   bin/httpd -X
> 
> after which I use httperf to generate many requests and 'apachectl -k 
> stop' to shut it down gracefully.  However, the gmon.out which is 
> created (viewed with 'gprof -z bin/httpd') doesn't seem to have any 
> timing data from after the server  config process.  For instance, 
> ap_run_post_config is called once, but ap_run_handler is called never 
> (according to gprof).
> 
> Now I am guilty of the following: I commented out the definition of 
> MONCONTROL(), because gcc on Solaris defines it statically (OT but: is 
> this ever going to be fixed?) -- however, shouldn't the -X option 
> obviate the need for turning off/on profiling in the parent/child?  At 
> any rate, I would like to profile under Solaris, but I am willing to rig 
> up a linux box if this will help.
> 
> Lastly, my real goal is to profile my own module under load.  I'm 
> concerned that getting gprof to display info on a dlopen'ed .so will 
> also be a challenge -- so if anyone can advise me on that, it would be 
> appreciated (this would also allow me to see symbols from libapr.so).  
> (After much googling, I haven't found much on the relationship between 
> gprof and DSO's, other than some cryptic references to DL_PROFILE.)  I 
> believe my current problem is logically prior, however, because the 
> core, http_core modules are compiled into httpd, and I'm not getting 
> info from them either.
> 
> Any help is much appreciated!!  Thanks,
> 
> Jim
> 
> p.s. relevant specs:
> 
> Apache/2.0.44 (pretty much a stock build, except for the ./configure 
> line given above)
> Compiled in modules:
>   core.c
>   mod_access.c
>   mod_auth.c
>   mod_include.c
>   mod_log_config.c
>   mod_env.c
>   mod_setenvif.c
>   prefork.c
>   http_core.c
>   mod_mime.c
>   mod_status.c
>   mod_autoindex.c
>   mod_asis.c
>   mod_cgi.c
>   mod_negotiation.c
>   mod_dir.c
>   mod_imap.c
>   mod_actions.c
>   mod_userdir.c
>   mod_alias.c
>   mod_so.c
> 
> gcc 3.2.2
> SunOS valkyrie 5.8 Generic_108528-09 sun4u sparc SUNW,Ultra-5_10
> 
> 


Mime
View raw message