You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Fred Moyer <fr...@redhotpenguin.com> on 2007/12/07 19:10:44 UTC
Using dtrace to determine which modules aren't loaded at startup
time
Greetings mod_perl list,
I've been having fun with dtrace, and I most recently used it to see
what files are being accessed by mod_perl during requests. I've
preloaded all the modules in my application that I know about into
startup.pl, but when I startup my httpd server and make a request, I got
some unexpected results.
sudo rwsnoop -n httpd
501 3509 httpd R 405 http.pm
501 3509 httpd R 0 http.pm
501 3509 httpd R 2239 _server.pm
501 3509 httpd R 0 _server.pm
501 3509 httpd R 4096 _generic.pm
501 3509 httpd R 1563 _generic.pm
501 3509 httpd R 0 _generic.pm
501 3509 httpd R 2052 _query.pm
501 3509 httpd R 0 _query.pm
Those files showed up during the first request, but not subsequent
requests. A little digging showed that this was the URI::http module
being loaded at runtime, since my application uses URI. But I
'use URI ();' in my startup.pl - apparently URI::http isn't being
loaded. Looks like URI requires http.pm at runtime:
URI.pm:
# check we actually have one for the scheme:
unless (@{"${ic}::ISA"}) {
# Try to load it
eval "require $ic";
Fine and good, I added URI::http to my startup.pl and those file stats
went away. There were some other offenders too though:
501 3508 httpd R 4096 utf8_heavy.pl
501 3508 httpd R 4096 utf8_heavy.pl
501 3508 httpd R 2323 utf8_heavy.pl
501 3508 httpd R 0 utf8_heavy.pl
501 3508 httpd R 4096 PVA.pl
501 3508 httpd R 4096 PVA.pl
501 3508 httpd R 4096 PVA.pl
501 3508 httpd R 4096 PVA.pl
501 3508 httpd R 1952 PVA.pl
501 3508 httpd R 0 PVA.pl
501 3508 httpd R 1279 Exact.pl
501 3508 httpd R 0 Exact.pl
501 3508 httpd R 4096 Canonical.pl
501 3508 httpd R 4096 Canonical.pl
501 3508 httpd R 4096 Canonical.pl
501 3508 httpd R 4096 Canonical.pl
501 3508 httpd R 4096 Canonical.pl
501 3508 httpd R 1529 Canonical.pl
501 3508 httpd R 0 Canonical.pl
501 3508 httpd R 4096 Fold.pl
501 3508 httpd R 4096 Fold.pl
501 3508 httpd R 4096 Fold.pl
501 3508 httpd R 1709 Fold.pl
501 3508 httpd R 0 Fold.pl
501 3508 httpd R 324 SpacePer.pl
501 3508 httpd R 0 SpacePer.pl
Hmm, I use Encode in my application, and preload it but why aren't those
files being loaded at startup?
I tried adding 'use utf8 ();' to startup.pl and it had no effect.
So I added the following require directives to startup.pl
require 'utf8_heavy.pl';
require 'unicore/PVA.pl';
require 'unicore/Exact.pl';
require 'unicore/Canonical.pl';
require 'unicore/To/Fold.pl';
require 'unicore/lib/gc_sc/SpacePer.pl';
and everything but Fold.pl and SpacePer.pl was loaded at startup. The
remainind dtrace lines:
501 3687 httpd R 4096 Fold.pl
501 3687 httpd R 4096 Fold.pl
501 3687 httpd R 4096 Fold.pl
501 3687 httpd R 1709 Fold.pl
501 3687 httpd R 0 Fold.pl
501 3687 httpd R 324 SpacePer.pl
501 3687 httpd R 0 SpacePer.pl
I'm not sure why these programs are still loaded at runtime, but I've
probably managed to save about 40k or so per process by preloading these
modules I am guessing. Not much but every byte counts.
If anyone has the unicode foo to tell me why those programs aren't
loading, I'd be very interested in knowing.
- Fred
Re: Using dtrace to determine which modules aren't loaded at startup
time
Posted by Fred Moyer <fr...@redhotpenguin.com>.
Colin Wetherbee wrote:
> Fred Moyer wrote:
>> I've been having fun with dtrace, and I most recently used it to see
>> what files are being accessed by mod_perl during requests. I've
>> preloaded all the modules in my application that I know about into
>> startup.pl, but when I startup my httpd server and make a request, I
>> got some unexpected results.
>
> I abhor sounding ignorant, but I wonder if Linux analogues to dtrace and
> rwsnoop exist? The results of your "fun" are very interesting, and I am
> curious to investigate my own processes.
There is strace, and I think you can use Apache2::Instrument for
analyzing what your mp processes are doing.
Re: Using dtrace to determine which modules aren't loaded at startup
time
Posted by Colin Wetherbee <cw...@denterprises.org>.
Fred Moyer wrote:
> I've been having fun with dtrace, and I most recently used it to see
> what files are being accessed by mod_perl during requests. I've
> preloaded all the modules in my application that I know about into
> startup.pl, but when I startup my httpd server and make a request, I got
> some unexpected results.
I abhor sounding ignorant, but I wonder if Linux analogues to dtrace and
rwsnoop exist? The results of your "fun" are very interesting, and I am
curious to investigate my own processes.
Thank you.
Colin
Re: Using dtrace to determine which modules aren't loaded at startup
time
Posted by Fred Moyer <fr...@redhotpenguin.com>.
Michael Peters wrote:
> Fred Moyer wrote:
>
>> I've been having fun with dtrace, and I most recently used it to see
>> what files are being accessed by mod_perl during requests. I've
>> preloaded all the modules in my application that I know about into
>> startup.pl, but when I startup my httpd server and make a request, I got
>> some unexpected results.
>>
>> sudo rwsnoop -n httpd
>>
>> 501 3509 httpd R 405 http.pm
>> 501 3509 httpd R 0 http.pm
>> 501 3509 httpd R 2239 _server.pm
>> 501 3509 httpd R 0 _server.pm
>> 501 3509 httpd R 4096 _generic.pm
>> 501 3509 httpd R 1563 _generic.pm
>> 501 3509 httpd R 0 _generic.pm
>> 501 3509 httpd R 2052 _query.pm
>> 501 3509 httpd R 0 _query.pm
>
> I've done the same thing in the past by dumping %INC to a file at startup and
> then at the end of a request (using a cleanup handler) and then comparing the 2.
> And I get the benefit of the full path to the file. Is there something else that
> dtrace provides that my approach doesn't?
Only that the code doesn't have to be instrumented. I was surprised
that those files weren't loaded at startup, up to this point I hadn't
taken into consideration modules which were required at runtime.
There were a few other neat things I was able to do, like seeing that
mod_perl wrote to disk for $r->error calls during the request, as
opposed to waiting until after the response had been sent to the client
like the access log does. Stuff I knew was happening before, but seeing
it in action (same as when seeing the results of instrumenting my code)
make me think a bit more about the code I was writing.
Re: Using dtrace to determine which modules aren't loaded at startup
time
Posted by Michael Peters <mp...@plusthree.com>.
Fred Moyer wrote:
> I've been having fun with dtrace, and I most recently used it to see
> what files are being accessed by mod_perl during requests. I've
> preloaded all the modules in my application that I know about into
> startup.pl, but when I startup my httpd server and make a request, I got
> some unexpected results.
>
> sudo rwsnoop -n httpd
>
> 501 3509 httpd R 405 http.pm
> 501 3509 httpd R 0 http.pm
> 501 3509 httpd R 2239 _server.pm
> 501 3509 httpd R 0 _server.pm
> 501 3509 httpd R 4096 _generic.pm
> 501 3509 httpd R 1563 _generic.pm
> 501 3509 httpd R 0 _generic.pm
> 501 3509 httpd R 2052 _query.pm
> 501 3509 httpd R 0 _query.pm
I've done the same thing in the past by dumping %INC to a file at startup and
then at the end of a request (using a cleanup handler) and then comparing the 2.
And I get the benefit of the full path to the file. Is there something else that
dtrace provides that my approach doesn't?
--
Michael Peters
Developer
Plus Three, LP
Re: Using dtrace to determine which modules aren't loaded at
startup time
Posted by Clinton Gormley <cl...@traveljury.com>.
Really interesting mail - if you're on perl monks, please cross post it
to there - there are a few UTF gurus who could help you out there.
If you're not, drop me a line and I'll post it for you.
Clint
On Fri, 2007-12-07 at 10:10 -0800, Fred Moyer wrote:
> Greetings mod_perl list,
>
> I've been having fun with dtrace, and I most recently used it to see
> what files are being accessed by mod_perl during requests. I've
> preloaded all the modules in my application that I know about into
> startup.pl, but when I startup my httpd server and make a request, I got
> some unexpected results.
>
> sudo rwsnoop -n httpd
>
> 501 3509 httpd R 405 http.pm
> 501 3509 httpd R 0 http.pm
> 501 3509 httpd R 2239 _server.pm
> 501 3509 httpd R 0 _server.pm
> 501 3509 httpd R 4096 _generic.pm
> 501 3509 httpd R 1563 _generic.pm
> 501 3509 httpd R 0 _generic.pm
> 501 3509 httpd R 2052 _query.pm
> 501 3509 httpd R 0 _query.pm
>
> Those files showed up during the first request, but not subsequent
> requests. A little digging showed that this was the URI::http module
> being loaded at runtime, since my application uses URI. But I
> 'use URI ();' in my startup.pl - apparently URI::http isn't being
> loaded. Looks like URI requires http.pm at runtime:
>
> URI.pm:
>
> # check we actually have one for the scheme:
> unless (@{"${ic}::ISA"}) {
> # Try to load it
> eval "require $ic";
>
> Fine and good, I added URI::http to my startup.pl and those file stats
> went away. There were some other offenders too though:
>
> 501 3508 httpd R 4096 utf8_heavy.pl
> 501 3508 httpd R 4096 utf8_heavy.pl
> 501 3508 httpd R 2323 utf8_heavy.pl
> 501 3508 httpd R 0 utf8_heavy.pl
> 501 3508 httpd R 4096 PVA.pl
> 501 3508 httpd R 4096 PVA.pl
> 501 3508 httpd R 4096 PVA.pl
> 501 3508 httpd R 4096 PVA.pl
> 501 3508 httpd R 1952 PVA.pl
> 501 3508 httpd R 0 PVA.pl
> 501 3508 httpd R 1279 Exact.pl
> 501 3508 httpd R 0 Exact.pl
> 501 3508 httpd R 4096 Canonical.pl
> 501 3508 httpd R 4096 Canonical.pl
> 501 3508 httpd R 4096 Canonical.pl
> 501 3508 httpd R 4096 Canonical.pl
> 501 3508 httpd R 4096 Canonical.pl
> 501 3508 httpd R 1529 Canonical.pl
> 501 3508 httpd R 0 Canonical.pl
> 501 3508 httpd R 4096 Fold.pl
> 501 3508 httpd R 4096 Fold.pl
> 501 3508 httpd R 4096 Fold.pl
> 501 3508 httpd R 1709 Fold.pl
> 501 3508 httpd R 0 Fold.pl
> 501 3508 httpd R 324 SpacePer.pl
> 501 3508 httpd R 0 SpacePer.pl
>
> Hmm, I use Encode in my application, and preload it but why aren't those
> files being loaded at startup?
>
> I tried adding 'use utf8 ();' to startup.pl and it had no effect.
>
> So I added the following require directives to startup.pl
>
> require 'utf8_heavy.pl';
> require 'unicore/PVA.pl';
> require 'unicore/Exact.pl';
> require 'unicore/Canonical.pl';
> require 'unicore/To/Fold.pl';
> require 'unicore/lib/gc_sc/SpacePer.pl';
>
> and everything but Fold.pl and SpacePer.pl was loaded at startup. The
> remainind dtrace lines:
>
> 501 3687 httpd R 4096 Fold.pl
> 501 3687 httpd R 4096 Fold.pl
> 501 3687 httpd R 4096 Fold.pl
> 501 3687 httpd R 1709 Fold.pl
> 501 3687 httpd R 0 Fold.pl
> 501 3687 httpd R 324 SpacePer.pl
> 501 3687 httpd R 0 SpacePer.pl
>
> I'm not sure why these programs are still loaded at runtime, but I've
> probably managed to save about 40k or so per process by preloading these
> modules I am guessing. Not much but every byte counts.
>
> If anyone has the unicode foo to tell me why those programs aren't
> loading, I'd be very interested in knowing.
>
> - Fred