-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Iterator performance #6137
Comments
It seems like Jeff needs to merge #3796. Perhaps you can confirm? |
fwiw i saw something like this with enumerate yesterday (i failed to reproduce it in a simple test and moved on, but it fits the pattern above). |
I thought #3796 might help. |
Thanks @vtjnash - just reading the (long) history of this baby. Should I make changes to my code, or should the inlining changes just work? |
It probably would, but the biggest issue is probably allocating tuples. We will have to improve that; you can't just inline everything into everything. |
@JeffBezanson picked it. Small improvement (maybe). Are there any changes afoot for tuple allocation? Is this an optimisation/fusing problem though - this seems to be delegated to LLVM currently. FYI:
|
Updated performance: IterWrapper has been optimised away (yay) but others have not moved:
|
This has improved. Note that there was a type instability in your Base.next(s::IterStutter, st) = begin
(oldvalue, state) = st
... With those changes, this benchmark now shows:
LLVM now completely removes the benchmarking loops on all but the last two iterators. I think this can probably be closed — even in the cases where LLVM doesn't totally remove the loop the performance is quite reasonable for summing 1000000 elements (~5ns per loop). |
I'm finding that there is a large performance overhead with relatively simple iterators. I find that when I start modify state, I get into trouble by a couple of orders:
Output:
The raw v IterWrapper performance is understandable as the former is an
AbstractArray
. But the jump in allocation/time from IterWrapper to IterAddOne / IterStateHack..?I'm essentially wanting to do far more complex iterators since I work with them rather than arrays. In some cases worse than Python, this leads me to think there's something wrong with my approach.
Thoughts?
The text was updated successfully, but these errors were encountered: