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
-
You will see a huge increase in speed for pretty much any script under Apache::Registry (the persistent handler),
- You won't see an increase for scripts that don't use modules under Apache::PerlRun (the non-persistent, but module caching handler),
- You will see an increase for scripts that DO use modules under Apache::PerlRun, but no where near what you'd see under Apache::Registry.
Hope this clears things up!