You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Alx G <gl...@yahoo.co.uk> on 2008/01/21 12:36:05 UTC

Re: Apache::DProf giving empty tmon.out files

Hi,

I'm trying to use Apache::DProf with my Perl web app. I can't work out what
I'm doing wrong - it should be working but it isn't (how many times have we
all said that to ourselves eh?).

I've run out of options to try now, I hope someone can help me please.

I'm running Apache 2.2.3, the conf has the following in it:

--
...
LoadModule perl_module modules/mod_perl.so

# Perl profiler
#
#<Perl>
#    require Apache::DB;
#    Apache::DB->init;
#</Perl>
PerlModule Apache::DProf
...
--

I tried with and without the commented stuff - as was suggested in this
thread.

Apache is running in prefork, *not* worker mode (which was also pointed to
as a possible culprit)

/usr/sbin/httpd -V :
Server MPM:     Prefork
    threaded:     no
        forked:     yes (variable process count)

The tmon.out files *are*being created, by the apache user, but they don't
contain any useful info. I've also tried running apache using the -X command
to spawn no child processes.

I then hit a few different scripts in the browser and the most I ever see in
those files, when shutting down apache is a reference to APR::Pool DESTROY
and the usual stuff at the top, *but no other subroutine calls at all*.

What now?

Many thanks!
-- 
View this message in context: http://www.nabble.com/Apache%3A%3ADProf-giving-empty-tmon.out-files-tp7265235p14995795.html
Sent from the mod_perl - General mailing list archive at Nabble.com.


Re: Apache::DProf giving empty tmon.out files

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> Ok, just tried putting it in there, didn't seem to make any difference to
> the tmon output (naturally, checking after stopping the server). I had
> noticed a reference to APR::Pool in the tmon files before so I would have
> thought it was loading it in any case.

if you want to (again) try Devel::Profiler it's really as simple as adding

   use Devel::Profiler::Apache;

to your startup.pl.  see the t/conf/ files in the D::P (svn) 
distribution for a working example (assuming it passes the tests :)

you also need to start in single server mode or, alternatively, setting 
these

   MinSpareServers      1
   MaxSpareServers      1
   StartServers         1
   MaxClients           1
   MaxRequestsPerChild  0

at the bottom of your httpd.conf.  note also that you can set the output 
directory via

   Devel::Profiler::Apache->import(output_dir => $odir);

in your startup.pl.  see also

   http://use.perl.org/~geoff/journal/34562

for a list of packages to avoid.

lastly, it's been noted already, but in case you missed it, please note 
that you won't get any data until the child process exits (or httpd is 
shut down), so try killing off the child.

fwiw, I submitted a proposal for OSCon on profiling, specifically how we 
profile "a large mod_perl application" :)  hopefully the selection folks 
find it a worthy topic.

--Geoff

Re: Apache::DProf giving empty tmon.out files

Posted by Alx G <gl...@yahoo.co.uk>.

Perrin Harkins wrote:
> 
> On Jan 23, 2008 5:57 AM, Alx G <gl...@yahoo.co.uk> wrote:
>> #      PerlFixupHandler Apache::DB # tried this, just filled up my error
>> log
>> with very low-level mod_perl calls, page didn't load, nothing in tmon.out
>> (pages work fine without it)
> 
> That's how you run your code in the debugger.  You have to do it in
> non-forking mode and start httpd directly from a terminal.  Anyway,
> it's not a profiling tool.
> 
> 

Yeah I thought as much, but at that stage I was ready to try anything : )


Perrin Harkins wrote:
> 
> 
> I don't see you loading APR::Pool in your <Perl> section, as shown in the
> docs.
> 
> 

Ok, just tried putting it in there, didn't seem to make any difference to
the tmon output (naturally, checking after stopping the server). I had
noticed a reference to APR::Pool in the tmon files before so I would have
thought it was loading it in any case.

Worth a shot though.
-- 
View this message in context: http://www.nabble.com/Apache%3A%3ADProf-giving-empty-tmon.out-files-tp7265235p15045577.html
Sent from the mod_perl - General mailing list archive at Nabble.com.


Re: Apache::DProf giving empty tmon.out files

Posted by Perrin Harkins <pe...@elem.com>.
On Jan 23, 2008 5:57 AM, Alx G <gl...@yahoo.co.uk> wrote:
> #      PerlFixupHandler Apache::DB # tried this, just filled up my error log
> with very low-level mod_perl calls, page didn't load, nothing in tmon.out
> (pages work fine without it)

That's how you run your code in the debugger.  You have to do it in
non-forking mode and start httpd directly from a terminal.  Anyway,
it's not a profiling tool.

I don't see you loading APR::Pool in your <Perl> section, as shown in the docs.

- Perrin

Re: Apache::DProf giving empty tmon.out files

Posted by Alx G <gl...@yahoo.co.uk>.

Alx G wrote:
> 
> 
> I'm trying to use Apache::DProf with my Perl web app. I can't work out
> what I'm doing wrong - it should be working but it isn't (how many times
> have we all said that to ourselves eh?).
> 
> I've run out of options to try now, I hope someone can help me please.
> 
> ... <snip> ...
> 
> I tried with and without the commented stuff - as was suggested in this
> thread.
> 
> Apache is running in prefork, *not* worker mode (which was also pointed to
> as a possible culprit)
> 
> /usr/sbin/httpd -V :
> Server MPM:     Prefork
>     threaded:     no
>         forked:     yes (variable process count)
> 
> The tmon.out files *are*being created, by the apache user, but they don't
> contain any useful info. I've also tried running apache using the -X
> command to spawn no child processes.
> 
> I then hit a few different scripts in the browser and the most I ever see
> in those files, when shutting down apache is a reference to APR::Pool
> DESTROY and the usual stuff at the top, *but no other subroutine calls at
> all*.
> 
> 


Sincere thanks to everyone who has offered advice and suggestions, I've
still not quite managed to get it working - I feel like there's probably
something really obvious staring me in the face. 

As a last ditch effort I thought I'd post an abridged version of my current
apache config in the hope that someone spots something crazy.

---
ServerTokens OS
ServerRoot "/etc/httpd"
PidFile run/httpd.pid
Timeout 120
KeepAlive Off
MaxKeepAliveRequests 100
KeepAliveTimeout 15

<IfModule prefork.c>
StartServers       8
MinSpareServers    5
MaxSpareServers   20
ServerLimit      256
MaxClients       256
MaxRequestsPerChild  4000
</IfModule>

Listen 80

... load various modules ...

LoadModule perl_module modules/mod_perl.so

<Perl>
    require Apache::DB;
    Apache::DB->init;
</Perl>

PerlModule Apache::DProf

Listen 8001
<VirtualHost "*:8001">
        DocumentRoot "/usr/local/myapp/htdocs"
        ErrorDocument 404 /cgi-bin/404handler.pl
        ErrorLog logs/myapp_error_log
        CustomLog logs/myapp_access_log combined
        PerlOptions +Parent
        PerlSwitches -I/usr/local/myapp/lib
</VirtualHost>

<Directory "/usr/local/myapp/htdocs">
        Order allow,deny
        Allow from all
</Directory>

<Directory /usr/local/myapp/htdocs/cgi-bin>
   <FilesMatch "\.pl$">
      SetEnv SYBASE /usr
      SetHandler perl-script
      PerlHandler ModPerl::PerlRun
#      PerlHandler ModPerl::RegistryPrefork # tried this also, no change
#      PerlFixupHandler Apache::DB # tried this, just filled up my error log
with very low-level mod_perl calls, page didn't load, nothing in tmon.out
(pages work fine without it)
      PerlOptions +ParseHeaders
      Options +ExecCGI
   </FilesMatch>
</Directory>

PerlModule Apache2::Reload
PerlInitHandler Apache2::Reload

... more misc config stuff ...
---

And this is the most I ever see in tmon.out:

---
#fOrTyTwO
$hz=100;
$XS_VERSION='DProf 20050603.00';
# All values are given in HZ
$over_utime=5; $over_stime=2; $over_rtime=17;
$over_tests=10000;
$rrun_utime=86; $rrun_stime=111; $rrun_rtime=2971;
$total_marks=2


PART2
@ 0 0 1
& 2 APR::Pool DESTROY
+ 2
- 2
@ 86 111 2970
---

Thanks again for your time.
-- 
View this message in context: http://www.nabble.com/Apache%3A%3ADProf-giving-empty-tmon.out-files-tp7265235p15039276.html
Sent from the mod_perl - General mailing list archive at Nabble.com.


Re: Apache::DProf giving empty tmon.out files

Posted by Perrin Harkins <pe...@elem.com>.
On Jan 21, 2008 7:26 AM, Alx G <gl...@yahoo.co.uk> wrote:
> Thanks for the tips John, however as I mentioned in my previous post, I did
> in fact try it with the DB->init call and it made no difference.

It will make a big difference, but it sounds like you have another
problem preventing you from getting to that point.

> Also, the
> tmon.out files *are* being created by the apache process so that's not an
> issue either.

This is worth double-checking.  Try becoming the user specified in
your httpd.conf and touch'ing these files.  Also, make sure you
actually shut down apache before you look at the files.  They may not
be written until you shut down.

- Perrin

Re: Apache::DProf giving empty tmon.out files

Posted by Alx G <gl...@yahoo.co.uk>.

Heiko Jansen wrote:
> 
> 
> Am Montag, den 21.01.2008, 06:19 -0800 schrieb Alx G:
> 
> ...
> 
>>  The code I'm running is just a collection of cgi scripts that hook
>> into the back-end libraries of the system, so the code is definitely
>> loaded
>> and run after the the DB->init and Dprof module.
> 
> But surely they're not run as plain old cgi?
> Sorry, just had to ask - sometimes I found out that it was the most
> obvious thing that I somehow forgot about...
> 
> Heiko
> 
> 

Sure, I appreciate your input Heiko. If I output the value of
$ENV{'mod_perl'} it shows mod_perl/2.0.2 (or something like that), so I
believe that shows it's not running as plain cgi.
-- 
View this message in context: http://www.nabble.com/Apache%3A%3ADProf-giving-empty-tmon.out-files-tp7265235p15000908.html
Sent from the mod_perl - General mailing list archive at Nabble.com.


Re: Apache::DProf giving empty tmon.out files

Posted by Heiko Jansen <ja...@hbz-nrw.de>.
Am Montag, den 21.01.2008, 06:19 -0800 schrieb Alx G:

> No worries. For the record, I just tried putting the DB->init before
> everything else (after loading mod_perl obviously) in the conf - no joy
> though.

The Apache::DB POD mentions using "use APR::Pool ();" right before "use
Apache::DB ();"

But I don't think that's the point, since there is at least some output
in the files.

>  The code I'm running is just a collection of cgi scripts that hook
> into the back-end libraries of the system, so the code is definitely loaded
> and run after the the DB->init and Dprof module.

But surely they're not run as plain old cgi?
Sorry, just had to ask - sometimes I found out that it was the most
obvious thing that I somehow forgot about...

Heiko



Re: Apache::DProf giving empty tmon.out files

Posted by Alx G <gl...@yahoo.co.uk>.

John ORourke wrote:
> 
> Alx G wrote:
>> Thanks for the tips John, however as I mentioned in my previous post, I
>> did
>> in fact try it with the DB->init call and it made no difference. Also,
>> the
>> tmon.out files *are* being created by the apache process so that's not an
>> issue either.
>>   
> 
> I misunderstood, sorry.  If you're getting just a few subroutine calls 
> recorded, then it seems like some perl modules are being loaded before 
> you run Apache::DB->init.  That was my problem anyway - I was loading my 
> code with a PerlModule directive before doing Apache::DB->init
> 
> cheers
> John
> 
> 
> 

No worries. For the record, I just tried putting the DB->init before
everything else (after loading mod_perl obviously) in the conf - no joy
though. The code I'm running is just a collection of cgi scripts that hook
into the back-end libraries of the system, so the code is definitely loaded
and run after the the DB->init and Dprof module.

-- 
View this message in context: http://www.nabble.com/Apache%3A%3ADProf-giving-empty-tmon.out-files-tp7265235p14998229.html
Sent from the mod_perl - General mailing list archive at Nabble.com.


Re: Apache::DProf giving empty tmon.out files

Posted by John ORourke <jo...@o-rourke.org>.
Alx G wrote:
> Thanks for the tips John, however as I mentioned in my previous post, I did
> in fact try it with the DB->init call and it made no difference. Also, the
> tmon.out files *are* being created by the apache process so that's not an
> issue either.
>   

I misunderstood, sorry.  If you're getting just a few subroutine calls 
recorded, then it seems like some perl modules are being loaded before 
you run Apache::DB->init.  That was my problem anyway - I was loading my 
code with a PerlModule directive before doing Apache::DB->init

cheers
John


Re: Apache::DProf giving empty tmon.out files

Posted by Alx G <gl...@yahoo.co.uk>.


John ORourke wrote:
> 
> Alx G wrote:
>> I'm running Apache 2.2.3, the conf has the following in it:
>>
>> --
>> ...
>> LoadModule perl_module modules/mod_perl.so
>>
>> # Perl profiler
>> #
>> #<Perl>
>> #    require Apache::DB;
>> #    Apache::DB->init;
>> #</Perl>
>> PerlModule Apache::DProf
>> ...
>> --
>>
>> I tried with and without the commented stuff - as was suggested in this
>> thread.
>>   
> 
> I'm running prefork and have used DProf many times.  I even wrote a 
> script to merge multiple tmon.out files, so you can see how your app is 
> doing in its normal environment.
> 
> The lack of recording happens when you don't do Apache::DB->init, and 
> you also need to explicitly create the 'dprof' directory in your apache 
> log directory, and make the apache user own it.
> 
> ----------------------- perl config include:
> <Perl>
>     require Apache::DB;
>     Apache::DB->init; # required otherwise very few subroutine calls get 
> captured
> </Perl>
> PerlModule Apache::DProf
> 
> ----------------------- files:
> (replace /var/log/httpd with your main log file path)
> 
> /var/log/httpd/dprof/   ********** you have to explicitly create this, 
> and make it owned by the apache user
> 
> /var/log/httpd/dprof/PID/tmon.out   <----- output from a particular 
> process (where PID is the pid)
> 
> -----------------
> Once you've let it run and made a few requests (make lots of requests so 
> any heavy startup code doesn't overshadow the real results, and so each 
> process gets a go), merge the tmon.out files using this script:
> 
> http://www.versatilia.com/downloads/merge-tmon-out.pl
> 
> (see top of file for usage)
> 
> hope that helps,
> John
> 
> 

Thanks for the tips John, however as I mentioned in my previous post, I did
in fact try it with the DB->init call and it made no difference. Also, the
tmon.out files *are* being created by the apache process so that's not an
issue either.

-- 
View this message in context: http://www.nabble.com/Apache%3A%3ADProf-giving-empty-tmon.out-files-tp7265235p14996493.html
Sent from the mod_perl - General mailing list archive at Nabble.com.


Re: Apache::DProf giving empty tmon.out files

Posted by John ORourke <jo...@o-rourke.org>.
Alx G wrote:
> I'm running Apache 2.2.3, the conf has the following in it:
>
> --
> ...
> LoadModule perl_module modules/mod_perl.so
>
> # Perl profiler
> #
> #<Perl>
> #    require Apache::DB;
> #    Apache::DB->init;
> #</Perl>
> PerlModule Apache::DProf
> ...
> --
>
> I tried with and without the commented stuff - as was suggested in this
> thread.
>   

I'm running prefork and have used DProf many times.  I even wrote a 
script to merge multiple tmon.out files, so you can see how your app is 
doing in its normal environment.

The lack of recording happens when you don't do Apache::DB->init, and 
you also need to explicitly create the 'dprof' directory in your apache 
log directory, and make the apache user own it.

----------------------- perl config include:
<Perl>
    require Apache::DB;
    Apache::DB->init; # required otherwise very few subroutine calls get 
captured
</Perl>
PerlModule Apache::DProf

----------------------- files:
(replace /var/log/httpd with your main log file path)

/var/log/httpd/dprof/   ********** you have to explicitly create this, 
and make it owned by the apache user

/var/log/httpd/dprof/PID/tmon.out   <----- output from a particular 
process (where PID is the pid)

-----------------
Once you've let it run and made a few requests (make lots of requests so 
any heavy startup code doesn't overshadow the real results, and so each 
process gets a go), merge the tmon.out files using this script:

http://www.versatilia.com/downloads/merge-tmon-out.pl

(see top of file for usage)

hope that helps,
John


Re: Apache::DProf giving empty tmon.out files

Posted by Alx G <gl...@yahoo.co.uk>.

Geoffrey Young wrote:
> 
> 
> 
> Alx G wrote:
>> Hi,
>> 
>> I'm trying to use Apache::DProf with my Perl web app. I can't work out
>> what
>> I'm doing wrong - it should be working but it isn't (how many times have
>> we
>> all said that to ourselves eh?).
>> 
>> I've run out of options to try now, I hope someone can help me please.
> 
> try Devel::Profiler:
> 
>    http://search.cpan.org/dist/Devel-Profiler/
> 
> you might want to try the svn sources, since it's been a while since 
> there has been a release
> 
>    http://sourceforge.net/projects/devel-profiler/
> 
> --Geoff
> 
> 

Thanks Geoff, I gave Devel::Profiler and Devel::Profiler::Apache a go -
neither of those seemed to want to generate any kind of output at all (the
'profiler' directory is in the right place and writable). I ran apache in
the normal prefork mode and the -X (no children) option. I stopped the
server after testing the scripts to check for the tmon.out files.

I also tried Dprof and Devel both before and after loading mod_perl in the
conf, with and without DB->init, same result in each case, i.e. it didn't
work.

To recap, so far I have Dprof that runs and generates some tmon.out files
with no application calls in them. I also have Devel, which generates
nothing at all.

-- 
View this message in context: http://www.nabble.com/Apache%3A%3ADProf-giving-empty-tmon.out-files-tp7265235p14999845.html
Sent from the mod_perl - General mailing list archive at Nabble.com.


Re: Apache::DProf giving empty tmon.out files

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Alx G wrote:
> Hi,
> 
> I'm trying to use Apache::DProf with my Perl web app. I can't work out what
> I'm doing wrong - it should be working but it isn't (how many times have we
> all said that to ourselves eh?).
> 
> I've run out of options to try now, I hope someone can help me please.

try Devel::Profiler:

   http://search.cpan.org/dist/Devel-Profiler/

you might want to try the svn sources, since it's been a while since 
there has been a release

   http://sourceforge.net/projects/devel-profiler/

--Geoff