-
-
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
manually inline setfield! in Stateful popfirst! #27685
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I kinda hope that this PR is ugly enough that someone just fixes the underlying issue, heh. Is the overhead here due to the |
Looks like the union splitting prevents the inlining from happening? Manual union splitting a la diff --git a/base/iterators.jl b/base/iterators.jl
index 1ce2d65264..8eb8cfdd2b 100644
--- a/base/iterators.jl
+++ b/base/iterators.jl
@@ -1075,7 +1075,12 @@ convert(::Type{Stateful}, itr) = Stateful(itr)
throw(EOFError())
else
val, state = vs
- s.nextvalstate = iterate(s.itr, state)
+ nvs = iterate(s.itr, state)
+ if nvs === nothing
+ s.nextvalstate = nvs
+ else
+ s.nextvalstate = nvs
+ end
s.taken += 1
return val
end is as effective as this PR (and as ugly). |
@nanosoldier |
Your benchmark job has completed - no performance regressions were detected. A full report can be found here. cc @ararslan |
👍 |
I suspect the main advantage is from removing the call to We could also look into making the definition of Stateful more efficient by improving its memory layout and/or removing the LookAhead support. |
Yes, IIRC the convert call showed up as significant on the profile print. So what do we do here now, just merge or change to Martin's version or something else? |
For the record: I don't think "my version" is to be preferred. I justed posted it because I found it remarkable that it makes the difference for inlining or not. |
Let's merge this now to have updated performance stats, whenever inference or whatever system needs to deal with this becomes smart enough, it can be revisited. |
Fixes #27030 (comment)