aligned (and faster) uniq impls + less wrapping#5830
Merged
kares merged 7 commits intojruby:masterfrom Aug 14, 2019
Merged
Conversation
re-using RubyHash internals (wout double hashing) seems nice
we do not need to fill a hash and than go on deleting entries rely on Hash ordering + make Hash always map to ary's values
... confirming previous work made sense (at least for now): ``` ---------------------------------------------------------------------- total: 30.678190sec user system total real Array#uniq (size: 8) [5000000x] 2.138970 0.000000 2.138970 ( 2.139309) Array#uniq (size: 32) [5000000x] 5.358952 0.000000 5.358952 ( 5.359636) Array#uniq(&block) (size: 8) [5000000x] 3.634595 0.000000 3.634595 ( 3.635386) Enumerable#uniq (size: 8) [5000000x] 4.194265 0.000000 4.194265 ( 4.195012) Enumerable#uniq (size: 32) [5000000x] 9.900353 0.000000 9.900353 ( 9.902616) Enumerable#uniq(&block) (size: 8) [5000000x] 5.433238 0.000000 5.433238 ( 5.434582) ``` ``` ---------------------------------------------------------------------- total: 39.150000sec user system total real Array#uniq (size: 8) [5000000x] 1.360000 0.000000 1.360000 ( 1.331043) Array#uniq (size: 32) [5000000x] 4.130000 0.000000 4.130000 ( 4.100323) Array#uniq(&block) (size: 8) [5000000x] 2.920000 0.010000 2.930000 ( 2.867646) Enumerable#uniq (size: 8) [5000000x] 5.080000 0.010000 5.090000 ( 5.031277) Enumerable#uniq (size: 32) [5000000x] 15.420000 0.040000 15.460000 ( 15.222436) Enumerable#uniq(&block) (size: 8) [5000000x] 7.330000 0.030000 7.360000 ( 7.235881) ``` ``` ---------------------------------------------------------------------- total: 19.930000sec user system total real Array#uniq (size: 8) [5000000x] 1.160000 0.020000 1.180000 ( 1.161547) Array#uniq (size: 32) [5000000x] 3.330000 0.010000 3.340000 ( 3.314024) Array#uniq(&block) (size: 8) [5000000x] 2.600000 0.000000 2.600000 ( 2.587071) Enumerable#uniq (size: 8) [5000000x] 1.910000 0.000000 1.910000 ( 1.844716) Enumerable#uniq (size: 32) [5000000x] 5.090000 0.010000 5.100000 ( 5.077093) Enumerable#uniq(&block) (size: 8) [5000000x] 3.380000 0.000000 3.380000 ( 3.301146) ```
This file contains hidden or 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
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.
noticed a lot of unnecessary single element array wrapping at Enumerable's impls
... this could be aided with a simple override on the (native)
BlockCallbackthe most interesting piece is doing less work on
Array#uniq(and alsoEnumerable#uniq)also the
Enumerableis still faster to have on the native end, numbers :MRI 2.5.7
current JRuby (9.2.8.0)
this PR