Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Perl quickly demi-compiles everything to an intermediate representation every time you run a program. It doesn't save this intermediate. "Quickly" is of course relative, but it's typically a non-issue on modern computers with reasonable size programs. It was different in the days of 486's (oh the joys of dynamic loading modules in Perl 4 to save startup cost), and it can be an issue with many-thousand line programs. Also a non-issue for most people if your program runs a long time, as do many web frameworks. There is also actual work done for startup on some modules, which is typically very fast but it can add up.

One place it comes up a lot is with small command-line scripts written using Moose. Moose is awesome, but very heavy. Fortunately there is Moo which is a near drop-in replacement for Moose that is much lighter weight. Install Class::XSAccessor as well for a substantial performance improvement for method get/set calls. Moo is, of course, not a complete replacement for Moose, but it does an awful lot. Try it.

You could also try Mouse. These days it isn't as recommended because Moo solves the problem for most people, and Mouse has its own quirks. But it is a lot faster than Moose, so you could give it a try to see if it's worth investigating. It may be as simple as replacing "Moose" with "Mouse" in your files.

There are mechanisms for compiled Perl, or saving the state after the compile phase to avoid the startup, but they mostly just save you the startup time, and have a dodgy history of working. I would recommend against going this direction unless you understand the problem well enough to know this is something you really want. Rieni Urban does some work for CPanel on a compiled Perl but I'm really not up on its status. Restricted Perls such as RPerl are unlikely to help given your problems seem to be with Moose.

I really recommend as well using Devel::NYTProf. It should give a better understanding of what is taking your time. Regardless of changing the OO framework (Moose/Mouse/Moo/Mo/bless), it may be that you're doing something obviously slow once you see the graphs (e.g. maybe you're calling a method get for the same value in a tight loop and could just cache it, or your type constraints are killing you and maybe there's a faster way).


In reply to Re: Pre-compiled Perl? by danaj
in thread Pre-compiled Perl? by bbs2web

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-03-28 20:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found