Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Pre-compiled Perl?

by danaj (Friar)
on Apr 04, 2017 at 16:19 UTC ( #1187015=note: print w/replies, xml ) Need Help??


in reply to Pre-compiled Perl?

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).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1187015]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2022-01-17 00:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (50 votes). Check out past polls.

    Notices?