-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
rust doesn't optimize closure in scan iterator #11084
Copy link
Copy link
Closed
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.P-lowLow priorityLow priority
Metadata
Metadata
Assignees
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.P-lowLow priorityLow priority
Type
Fields
Give feedbackNo fields configured for issues without a type.
Good evening. I ran across a missed optimization I was trying to convert
std::result::collectinto usingFromIteratator. My initial version usediter::Scan, but it proved to be 2 times slower than at--opt-level=3than the original implementation. I also created a custom iterator that doesn't have the closure, and it compiles down to the same speed as the originalstd::result::collect. I'm guessing llvm isn't able to inline the closure for some reason.I've gathered up this test in a gist. Note that in this example, the
Scan1::size_hint()is different than thestd::iter::Scan::size_hint()method.cc @thestinger