[cgiapp] Model design in C::A/Titanium

Joshua Miller unrtst at gmail.com
Tue Sep 23 16:31:29 EDT 2008


On Tue, Sep 23, 2008 at 4:09 PM, Michael Peters <mpeters at plusthree.com>wrote:

> Joshua Miller wrote:
>
>  Using autoloader to only require in the subclasses when needed will also
>> keep memory usage down, as rarely used modules won't get loaded unless
>> they're actually called.
>>
>
> Are you running under normal CGI (do people still do that?).
>
> If not, and you're running on a "good" OS (one with copy-on-write memory)
> and you're using a forking environment (mod_perl, or most FastCGI
> implementations) you should pre-load all of you modules up front. This will
> actually decrease memory usage. Or course if you have a really, really
> rarely used module that is really, really big you might reconsider this
> advice. Unless I'm missing something?
>

You're not missing anything. I'm running under mod_perl under linux boxen,
and do pre-load a ton of modules that are used often. It's a > million line
system though, so there's a whole lot that doesn't load frequently. The
pre-load all module is a good rule of thumb - it's a lot easier than
defining how many uses a day justifies pre-loading.

The above snippet can be updated to just do a "use" on all the module at the
top, and remove the require part... but that will also mean that it'll need
updated every time you add a new subclass. The above will automatically find
and use the new subclass, which makes it good generic code (IMHO). And you
can always put the pre-loads in a separate apache startup file anyway.

--
Josh I.


More information about the cgiapp mailing list