[sf-perl] making perl compile phase faster

Chris Weyl cweyl at alumni.drew.edu
Fri Apr 29 13:46:44 PDT 2011


On Fri, Apr 29, 2011 at 12:30 PM, Michael Friedman <
friedman at highwire.stanford.edu> wrote:

> At my site, we run a lot of command-line perl scripts. Unfortunately, we
> also have 2794 perl modules. Some of our scripts load up thousands of lines
> of perl code before they can do anything, even display a usage statement.
> Generally, from the time you hit <return> it's at least 5 seconds before
> anything happens, often longer, because perl has to load in all the required
> modules.


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.

If they're all intertwined and you're looking for a way to make that
behavior lazy-load, I'm afraid this won't help you at all.  :)

                                  -Chris
-- 
Chris Weyl
Ex astris scientia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/sanfrancisco-pm/attachments/20110429/e5f09daf/attachment.html>


More information about the SanFrancisco-pm mailing list