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
Major optimisations: 2x faster! #1
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- avoid assigning undef to $value that is already undef - reorganize code paths to avoid checking the definedness of $value when we know we haven't set the value
Add more tests. The change in coverage is not visible on the Devel::Cover report for the current code. But that will change with the refactoring to come...
The __is_a sub is replaced by a closure built from the $must_be specification.
The code is slightly slower for the scalar $must_be case (as we now transform that case in the array case with a single element), but simpler to read/maintain as closures are built in a single place.
The must_be compiler benefits to Sub::Exporter.
@rjbs Ping! |
Thanks! Applied and released. |
dolmen
added a commit
to dolmen/p5-Moose
that referenced
this pull request
Mar 30, 2016
Because it has a major optimisations: rjbs/Data-OptList#1
dolmen
added a commit
to dolmen/p5-Dist-Zilla
that referenced
this pull request
Apr 21, 2016
Because it is faster. See rjbs/Data-OptList#1
rjbs
pushed a commit
to rjbs/Dist-Zilla
that referenced
this pull request
Apr 21, 2016
Because it is faster. See rjbs/Data-OptList#1
dolmen
added a commit
to dolmen/p5-Moose
that referenced
this pull request
Apr 22, 2016
Because it is faster. See rjbs/Data-OptList#1.
karenetheridge
pushed a commit
to moose/Moose
that referenced
this pull request
Apr 30, 2016
Because it is faster. See rjbs/Data-OptList#1.
mephinet
pushed a commit
to mephinet/Moose
that referenced
this pull request
Nov 24, 2017
Because it is faster. See rjbs/Data-OptList#1.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While profiling Dist::Zilla with Devel::NYTProf I noticed that Data::OptList is heavily used. For example when building the Data-OptList distribution,
mkopt
is called 2704 times (from Moose and Sub::Exporter) andmkopt_hash
237 times (called by Sub::Exporter).So here is a set of MAJOR optimisations:
$must_be
parameter is compiled into a closure (this benefits to Sub::Exporter)This will give a boost to any Moose application!
Some statistics (second line is with my optimisations):
perl -d:NYTProf -S dzil test
PERL5LIB="$PWD/lib" perl -d:NYTProf -ME='$Data::OptList::VERSION="0.110"' -S dzil test
Cc: @karenetheridge @dagolden @kentfredric @autarch @doy @sartak @shadowcat-mst