-
Notifications
You must be signed in to change notification settings - Fork 14
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
@inline
with traits
#79
Comments
Thanks for the report! I assume you don't have an idea on how to fix this? From the macroexpand it looks like with either order the julia> @macroexpand @inline @traitfn f(x::::TT) = 1
quote
begin
#= /home/mauro/julia/dot-julia-dev/SimpleTraits/src/SimpleTraits.jl:331 =#
(f(x::var"##261") where var"##261") = begin
#= /home/mauro/julia/dot-julia-dev/SimpleTraits/src/SimpleTraits.jl:331 =#
$(Expr(:meta, :inline))
#= /home/mauro/julia/dot-julia-dev/SimpleTraits/src/SimpleTraits.jl:331 =#
f(SimpleTraits.trait(TT{var"##261"}), x)
end
end
begin
$(Expr(:meta, :doc))
(f(::Type{TT{var"##261"}}, x::var"##261"; ) where var"##261") = begin
$(Expr(:meta, :inline))
#= REPL[5]:1 =#
1
end
end
end
julia> @macroexpand @traitfn @inline f(x::::TT) = 1
quote
begin
#= /home/mauro/julia/dot-julia-dev/SimpleTraits/src/SimpleTraits.jl:331 =#
(f(x::var"##259") where var"##259") = begin
#= /home/mauro/julia/dot-julia-dev/SimpleTraits/src/SimpleTraits.jl:331 =#
$(Expr(:meta, :inline))
#= /home/mauro/julia/dot-julia-dev/SimpleTraits/src/SimpleTraits.jl:331 =#
f(SimpleTraits.trait(TT{var"##259"}), x)
end
end
begin
$(Expr(:meta, :doc))
(f(::Type{TT{var"##259"}}, x::var"##259"; ) where var"##259") = begin
$(Expr(:meta, :inline))
#= REPL[4]:1 =#
1
end
end
end For your example the |
I haven't looked. Thanks for checking! Profiling the test in that |
Hm, runtime dispatch, that is even worse than not inlining! |
In JuliaArrays/GetindexArrays.jl#3 (comment) I identified an issue in which SimpleTraits caused a nearly 5x performance hit. SimpleTraits was confirmed to be the source because changes like
to ImageAxes.jl (and several more similar changes) give the faster performance. I assume the problem is that the
@inline
annotation is not being applied, but I am unsure. I tried swapping the orders of@traitfn
and@inline
but it didn't seem to help.The text was updated successfully, but these errors were encountered: