lestrrat you got it partially right, assuming you're only using the Apache::PerlRun handler.

First off, mod_perl doesn't cache "library files" unless you tell it to in httpd.conf.

If you haven't set a handler for your scripts you won't be getting any benefits. mod_perl only caches "library files" for other scripts handled by mod_perl. e.g. if you pre-load CGI.pm in your httpd binary with mod_perl, you'll be preloading it for your mod_perl scripts only. Again, if you don't set up a handler (in httpd.conf) for scripts to be cached by mod_perl, you won't see any benefits.

There's a couple of major handlers you'll use, (assuming you don't write your own), Apache::PerlRun and Apache::Registry.

Apache::PerlRun caches modules for other scripts handled by Apache::PerlRun (and probably Apache::Registry). The scripts handled by PerlRun still have to load and compile themselves, but not the modules. You'll see an increase in scripts that use modules that are handled under PerlRun

Apache::Registry caches the script itself and the modules. This is where you get the huge speed increases, whether or not you use modules. Each call to the script comes directly from the httpd binary, bypassing the load and compile phase.

Put another way, straight mod_cgi scripts still load in modules, compile, and then exit usually, offering you none of the benefits of mod_perl. If you set these non-persistent scripts to be handled by the Apache::PerlRun handler, then you will see a small speed increase because the module caching will happen, though the script itself will be compiled and run on each execute.

On the simple script without many modules thing, you won't see many benefits under Apache::PerlRun because the scripts themselves aren't being cached. If you have scripts that use many modules and run them under Apache::PerlRun, you will see an increase in speed.

However, pretty much any script run under Apache::Registry will have a huge speed increase, whether or not it uses modules. This is because each instance of the script doesn't have to be reloaded and compiled, it's resident in the httpd binary.

The Bottom Line

Hope this clears things up!


In reply to Re: Re: mod_perl implementation by Hero Zzyzzx
in thread mod_perl implementation by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.