New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
switch from MooX::Types::MooseLike to Type::Tiny #1120
Conversation
At the moment all types are exported so would be good to restrict imports in consumers. |
@@ -36,7 +36,7 @@ sub supported_engines { [ qw<logger serializer session template> ] } | |||
|
|||
has _factory => ( | |||
is => 'ro', | |||
isa => Object['Dancer2::Core::Factory'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type::Standard's Object type throws an exception when used like this since Object doesn't check isa.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you suggest instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been changed to InstanceOf['Dancer2::Core::Factory']
There is still room for improvement since some of the Dancer2 types are not inlined but I'm happy with this PR as it stands right now. What I don't like: Dancer2::Core::Types exports all types which is needed for backwards compatibility especially for session/plugin/... code outside core. Perhaps this could be addressed later with a deprecation warning and eventual switch to exporting nothing by default. Once switched to Type::Tiny we can start to take advantage of coercions defined within Core::Types rather than having coercion defined in attribute of consuming class. Something to consider for later. |
perf.pl improvements I've seen are approx -1.8% for Type::Tiny (no XS) and -2.7% for Type::Tiny::XS |
Today I ran 20 runs of perf tests against all three on a different system from previous tests and am still seeing improvements though not so large: -1.11% for Type::Tiny (no XS) and -2.3% for Type::Tiny::XS. So definitely looks like a worthy change on a performance basis. |
Full details of most recent perf tests...
|
This looks good. For my own sake, all my types are done with Type::Tiny family, so it would be good for D2 to be the same. |
All looks pretty sane to me! I'm a little concerned that some more helpful exception messages, referring to the type that was required, are now more generic - for e.g. from the tests:
However, it shouldn't be too difficult to find out what the constraint is. Some other stuff is clearer, though, and overall it looks cleaner and nicer, and your benchmarks show it to be faster too, which is always nice, so I'm in favour (especially if it also then allows the type-based captures discussed elsewhere!). |
@bigpresh
so compared to |
and there is more as referenced in an earlier comment...
whereas |
@SysPete already convinced me about Type::Tiny in our Interchange projects, so 👍 |
@bigpresh I've updated tests now so expected regexp includes the type name. |
Ah, nice one, thanks for the responses - great to see that the errors are as helpful, or even more so, than they were before! |
@SysPete Great work! (as usual...) 👍 from me. @bigpresh, the errors we will see for the type checks are for us, not for the user, and they should:
|
Looks like we have +1 * 2 - anyone have any objections? I'd really like to see this one merged (needed for #1127 for starters). |
+1. Do it :)
|
Extra modules are mentioned in |
On 03/04/16 11:41, Sawyer X wrote:
|
Bring it on! |
was using MooX::Types::MooseLike::Base directly.
- inline ReadableFilePath and WritableFilePath using quote_sub - use Enum to simplify Dancer2Method and Dancer2HTTPMethod - use InstanceOf for abbreviated class types for core dancer objects instead of blessed+ref
Merged, thanks! 👍 |
[ BUG FIXES ] * GH #1165, #1167: Copy is_behind_proxy attribute into new request on forward. (Russell Jenkins) [ ENHANCEMENTS ] * GH #1120: Move from MooX::Types::MooseLike to Type::Tiny for performance. (Peter Mottram) * GH #1145, #1164: Replace Class::Load with Module::Runtime (Sawyer X) * GH #1159, #1163: Make template keyword global. (Sawyer X, Russell Jenkins) [ DOCUMENTATION ] * GH #1158: List both static and shared modules in Apache's deploy instructions. (Varadinsky)
[ BUG FIXES ] * Fix memory leak in plugins. (Sawyer X) * GH #1180, #1220: Revert (most of) GH #1120. Change back to using MooX::Types::MooseLike until issues around Type::Tiny are resolved. Peter (@SysPete) Mottram * GH #1192: Decode body|query|request_parameters (Peter Mottram) * GH #1224: Plugins defined with :PluginKeyword attribute are now exported. (Yanick Champoux) * GH #1226: Plugins can now call the DSL of the app via $self->dsl (Sawyer X) [ ENHANCEMENTS ] * PR #1223: Add YAML::XS to Recommends (Peter Mottram) * PR #1117: If installed, use HTTP::XSCookies and all cookie operations will be faster (Peter Mottram) * PR #1228: Allow register_plugin() to pass @_ properly (Sawyer X) * PR #1231: Plugins can now call the syntax of plugins they loaded (Sawyer X) [ DOCUMENTATION ] * PR #1151: Note that config is immutable after first read (Peter Mottram) * PR #1222: Update list of files generated by `dancer2 -a`, make name of sample app consistent (Daniel Perrett)
Dumbbench perf script shows around 4% improvement in speed and I guess things will be even better for more complex routes.