Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Journal of jjore (6662)

Sunday August 23, 2009
06:45 PM

Simple trick to get more copy-on-write goodness

[ #39514 ]

I've got a preforking Apache server at work that's not sharing enough memory among the many children. This snippet helped identify post-fork module loading. I put an @INC hook at the end of my httpd.conf and it writes a warning to my log whenever the forked child loads something.

# httpd.conf
...
<Perl>
  # This fragment goes at the end, when I think I'm ready to let Apache start forking
  $main::PARENT_PID = $$;
  unshift @INC, sub {
    print STDERR "LATE LOAD: $_[1]\n" if $$ != $main::PARENT_PID;
    return undef;
  };
</Perl>

I just found 233 modules I was loading post-fork. Oops! It's now trivial to make sure my httpd.conf has the proper lines to load the stuff I was forgetting to:

# httpd.conf
LoadModule XML::LibXML
LoadModule LWP::UserAgent
...

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.