-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Faster promoting arithmetic #21067
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
Faster promoting arithmetic #21067
Conversation
Reference: #21065
How about this instead: --- a/base/promotion.jl
+++ b/base/promotion.jl
@@ -171,6 +171,7 @@ promote_result{T,S}(::Type{T},::Type{S},::Type{Bottom},::Type{Bottom}) = (@_pure
promote() = ()
promote(x) = (x,)
function promote{T,S}(x::T, y::S)
+ @_inline_meta
(convert(promote_type(T,S),x), convert(promote_type(T,S),y))
end
promote_typeof(x) = (@_pure_meta; typeof(x)) |
I wondered about that. There are occasionally weird things that can happen performance-wise when you change the "level" that gets inlined (e.g., JuliaImages/ImageCore.jl#26). But I guess with nanosoldier there is little reason not to try and find out what happens. |
Let's ask @nanosoldier |
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @jrevels |
It seems like it would be better to fix |
IIUC, that is being fixed for 0.6 and this is a minimal PR towards 0.5.2? |
This shouldn't this be a PR against the 0.5 branch rather than master? |
Sort of. Forced inlining of |
@nanosoldier |
-(x::Number, y::Number) = -(promote(x,y)...) | ||
/(x::Number, y::Number) = /(promote(x,y)...) | ||
function +(x::Number, y::Number) | ||
xp, yp = promote(x, y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these changes necessary in addition to the inlining of promote
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I really don't like having to expand these like this – it's very ugly and we've never had to do so before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Certainly much less important with #21069. The main problem is that as we implement more abstractions, the inlining heuristics sometimes seem to fail to realize how simple something really is. I don't think we can exclude the possibility that we're noticing problems that we didn't notice before.
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @jrevels |
So maybe inlining |
Now that's what I'd call an uninspiring benchmark result. I expected some regressions, but that really took the idea and ran with it. |
I'd be content with #21069 alone, if it is backportable. It's certainly the most far-reaching of the solutions. Adding the first commit is another 35% faster on this particular benchmark; let's see what others think of whether that's worth it. |
Reference: #21065. The main reason to introduce this is so that it can be backported to 0.5; perhaps on 0.6 there can be a deeper solution. I could re-file this explicitly against
release-0.5
if that's preferable.