I did a lot of profiling and optimization work for the latest releases of Moose and Class::MOP. My focus was on improving module compilation speed. My profiling workload was simply running perl -d:NYTProf -MMarkdent::Simple::Document -e1
The Markdent module in question loads a lot of Moose-using modules, uses plenty of roles, and is generally a good Moose compilation workout.
When profiling, I found that the biggest culprit was looking up methods in a module's namespace. We were making nearly 10,000 calls to Class::MOP::Mixin::HasMethods->get_method, which is one of our most expensive operations. I was able to reduce the number of calls to under 4,000.
What's a bit sad, however, is that this only appears to save 6-10% of the compilation time in real usage. I'm not sure why that is, but I think the issue is that the perl core's compilation time may be a big factor. As I said, loading that one Markdent modules loads a lot of modules (203 individual .pm files), and the raw overhead of simply reading all those files and compiling them may be a significant chunk of the compilation time.
It's really hard to test this theory, though, since I don't really have a non-Moose version of Markdent to test as a control.
Anyway, this latest release of Moose and CMOP at least provides some speedups. Thanks to Tim Bunce for working on Devel::NYTProf. It's a fantastic tool, and it makes profiling a pleasure to do.
