Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

mod_perl and dtrace (or why certain unicode files don't load at startup time)

by redhotpenguin (Deacon)
on Dec 07, 2007 at 18:59 UTC ( #655717=perlquestion: print w/ replies, xml ) Need Help??
redhotpenguin has asked for the wisdom of the Perl Monks concerning the following question:

Greetings monks,

This is a cross post of an email sent to the mod_perl users list, there was a suggestion that I should post it here also because of utf experts hanging around here.

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 remaining 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.

Comment on mod_perl and dtrace (or why certain unicode files don't load at startup time)
Select or Download Code
Re: mod_perl and dtrace (or why certain unicode files don't load at startup time)
by eserte (Deacon) on Dec 08, 2007 at 00:01 UTC
    The Unicode standard is huge and there are many .pl files in perl's core dealing with every aspect of Unicode. It's just an optimization that most things are loaded on demand (e.g. if you're using regexps with special Unicode properties (\P, \p) or case insensitive matches or something like lc/uc).

    Of course, if you know your data and you're in a mod_perl environment, then preload as much as you can.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://655717]
Approved by clinton
Front-paged by clinton
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2014-08-28 01:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (254 votes), past polls