in reply to Re: mod_perl implementation
in thread mod_perl implementation

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!

Replies are listed 'Best First'.
Re: Re: Re: mod_perl implementation
by lestrrat (Deacon) on Jul 12, 2001 at 23:22 UTC

    Ah, I haven't really used Apache::PerlRun, so I wasn't aware of that difference. I exclusively use Apache::Registry, and thought that *that* was the heart of mod_perl

    But I still do would like to point out that if the script itself is relatively small, I personally didn't see much of a difference -- that is, not enough to make me go ga-ga over mod_perl. Maybe it was just that my particular configuration was that way, but since this original poster seemed unsure if mod_perl was doing its magic, I wanted to point out that the perceived difference may not be that big, if the initial compilation overhead wasn't as big.

    Does that make sense?

    Anyhow, I learned the difference between Apache::PerlRun and Apache::Registry today. that's cool. Thanks