[sf-perl] making perl compile phase faster

George Hartzell hartzell at alerce.com
Sat Apr 30 15:25:25 PDT 2011


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.





More information about the SanFrancisco-pm mailing list