[sf-perl] making perl compile phase faster

Francisco Obispo fobispo at isc.org
Sat Apr 30 15:39:47 PDT 2011


How about using AutoLoader in your modules?

The main difference is that function calls will be loaded as needed and not all at the same time. Which could significantly improve the overall loading speed.





On Apr 30, 2011, at 3:25 PM, George Hartzell wrote:

> Chris Weyl writes:
>> On Sat, Apr 30, 2011 at 11:29 AM, George Hartzell <hartzell at alerce.com>wrote:
>> 
>>> Chris Weyl writes:
>>>> Hm.  Do you actually need these modules loaded?  (I'm guessing not)  One
>>> way
>>>> I've dealt with things like this using, e.g., MooseX::App::Cmd and
>>> having a
>>>> role wrap execute() in each of the command classes, that then calls
>>>> Class::MOP::load_class() against any modules the command needs to do its
>>>> thing if the command is told to run.  (MX::App::Cmd is just what I tend
>>> to
>>>> use; the same methodology would work elsewhere.)  This doesn't do any
>>>> pre-compiling, but helps simply by cutting down to loading only what's
>>>> needed.
>>>> [...]
>>> 
>>> Hi Chris,
>>> 
>>> Can you post an example of this?  Or a bit more complete sketch?
>>> 
>>> I have several a MooseX::App::Cmd based classes that could probably
>>> benefit from this...
>>> 
>> 
>> Sure -- imagine something like this:
>> 
>> package MyApp::CommandRole::Lazy;
>> 
>> use Moose::Role;
>> use namespace::autoclean;
>> 
>> requires '_lazy_classes';
>> requires 'execute';
>> 
>> before execute => sub { Class::MOP::load_class($_) for $_[0]->_lazy_classes
>> };
> 
> Thanks!  That jogged things loose.  I think I can just do that call to
> laod_class in my command's common baseclass's execute method (which
> uses inner/augment to run the children's execute.
> 
> Nice.  We'll see if it speeds things up.
> 
> g.
> 
> 
> 
> _______________________________________________
> SanFrancisco-pm mailing list
> SanFrancisco-pm at pm.org
> http://mail.pm.org/mailman/listinfo/sanfrancisco-pm

Francisco Obispo 
Hosted@ Programme Manager
email: fobispo at isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
Key fingerprint = 532F 84EB 06B4 3806 D5FA  09C6 463E 614E B38D B1BE






More information about the SanFrancisco-pm mailing list