Converting a Moose application to a Mouse|Moose hybrid
Hailo has been converted from a Moose application to a hybrid Mouse/Moose application for release 0.20.
This brought its memory usage from 28MB to 20MB. Hailo is around 4.000 lines and the patch required to make it Mouse + Moose compatible (including testing both at make test
time) is just under 500 lines.
As well as reduced memory use another big plus is the reduced startup time. hailo(1)
starts with Mouse in around 250 ms flat whereas with Moose it hovers around 530 ms. The difference in startup time is clear when running the testsuite with Moose & Mouse:
We had to hack around there not being a MouseX::StrictConstructor analogous to MooseX::StrictConstructor and I fixed a bug in Mouse which caused Mouse's Int type not to support values larger than 2^32 on 32 bit systems.
What was the reason for going to Mouse? Startup does not seem to be an issue as Hailo looks like a long running process (sorry if I got that wrong). Memory savings are nice though.
But why not switch to Mouse completely if that is an issue?
It's running on a busy virtual host of ours with 1GB in memory so we've been reducing the memory use of everything there, Hailo included.
Having faster startup time is also always nice. Although we run it as a long-running process it's also available as a command-line utility which someone might want to call up occasionally from a long-running process. Having it start up in 0.2s instead of 0.5s makes a difference for such interactive cases.
The reason we're not switching completely to Mouse is that it's trivial to maintain compatibility with both as this posting illustrates.
The test suite is now run with both implementations so we'll notice right away if we do something incompatible with Mouse & can fix it.