Specialize TupleCombinations::fold#775
Merged
Philippe-Cholet merged 6 commits intoOct 27, 2023
Merged
Conversation
25fceae to
0e15566
Compare
`I::Item` and `A` are the same so the "where condition" is not really changed, but it is apparently needed here. We fold `c` then for each item of `iter`, we fold the cloned `iter`. The `while let` loop should probably be converted to `fold` somehow later (if possible) but the core logic is done and it is already really faster.
0e15566 to
21004ed
Compare
Member
Author
|
Maybe I should merge EDIT: It would be 6% slower. |
phimuemue
approved these changes
Oct 26, 2023
Member
phimuemue
left a comment
There was a problem hiding this comment.
Hi @Philippe-Cholet, sorry for the delay. Nice that's is already faster. Feel free to merge if you want.
Is this specialization already tested in our specialization tests?
Member
Author
|
As mentionned in the too big message, the specialization test was previously added (by me). |
Merged
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.
Related to #755.
This is so much faster that I'm wandering if I'm missing something here!
I previously added the specialization test: a9aaeb4
I'm unsure we can fold the
while letloop as we need to cloneiterat every step of it.Both attempts below successfully pass the tests but are not faster.
Maybe there is a solution involving
std::cell::???but I'm not familiar enough with this, are you?I tried with
itertools::rciterbut it was 60% slower (andRcmeans theuse_allocfeature). And with a basicRcIter::foldspecialization, I even had an (expected) error at runtime.I eventually found a way to rely on
iter.foldusingunsafeonly (to hold&mut Iand&Iat the same time) but it's the same performance as the currentfoldspecialization.I'm not familiar with unsafe Rust so it might just be dumb in the first place.