

Moose is Perl: A Guide to the New Revolution - Mithaldu
http://rjbs.manxome.org/talks/moose/

======
otterley
Moose is cool, but it can be a significant performance impediment to any
program that uses Moose-wrapped objects or their methods frequently (this is
true even of the XS-based Moose implementation). Function calls are expensive
in Perl, and adding Moose wrappers causes them to be invoked sometimes an
order of magnitude more frequently. You can see how bad it is by profiling
your code with NYTProf.

Consequently, I've often recommended implementors extricate Moose from
performance-critical programs.

~~~
stevan_little
Very odd, because for regular methods, Moose does not wrap anything.

There is a compile time penalty for Moose overall, but for instance, the Moose
generated accessors typically benchmark very well in comparison. They will
start to slow down when you add type constraints, but this is essentially
extra code you are asking Moose to execute so you can't expect to get it for
free.

I highly suspect you have been using MooseX::Declare or
MooseX::Method::Signatures, both of which have a high performance penalty for
method calls. These modules should not be looked at as being Moose, they are
optional extensions.

~~~
otterley
Much of the overhead can be attributed to Moose::Util::TypeConstraints, which
is part of the base package.

~~~
Mithaldu
I'm summarizing explanations from the #moose irc channel now:

Yes, type checks are the main source for performance issue.

However, they are completely optional. This means you can safely disable them
in places where you think you don't need them, and only enable them where you
think you do. Keep in mind that writing something manually though won't be
faster.

This means, that when performance is an issue, your first step would be to
fork your dependency and disable type checks. That should get you almost the
same speed as a complete Moose-free rewrite, at a fraction of the cost of an
actual rewrite. If that really isn't enough, you're likely to get better
performance by rewriting in C, than in Moose-free Perl.

~~~
otterley
Good feedback. Thanks!

