-
-
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
more latency improvements for #33615 #33779
Conversation
6d32187
to
6cb0aa7
Compare
@@ -842,6 +844,8 @@ function abstract_call(@nospecialize(f), fargs::Union{Nothing,Vector{Any}}, argt | |||
end | |||
elseif length(argtypes) == 2 && istopfunction(f, :typename) | |||
return typename_static(argtypes[2]) | |||
elseif max_methods > 1 && istopfunction(f, :copyto!) | |||
max_methods = 1 |
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.
This can be a bit unfortunate for the common return copyto!(dest, src)
construct (or otherwise using the return value instead of dest
, as in foo!(copyto!(dest, src))
) with typeof(dest)
known but typeof(src)
unknown. All matching methods of copyto!
should be inferable as typeof(dest)
, but that won't help. If only all those places had used copyto!(dest, src); return dest
...
Since #35965, this e.g. also affects the Array
constructor:
julia> code_typed(Vector{Any}, Tuple{Vector}; optimize=false)
1-element Vector{Any}:
CodeInfo(
1 ─ %1 = Core.apply_type(Base.Array, $(Expr(:static_parameter, 1)), $(Expr(:static_parameter, 2)))::Core.Const(Vector{Any}, false)
│ %2 = Base.size(x)::Tuple{Int64}
│ %3 = (%1)(Base.undef, %2)::Vector{Any}
│ %4 = Base.copyto_axcheck!(%3, x)::Any
└── return %4
) => Any
Just increasing this to 2 restores
julia> code_typed(Vector{Any}, Tuple{Vector}; optimize=false)
1-element Vector{Any}:
CodeInfo(
1 ─ %1 = Core.apply_type(Base.Array, $(Expr(:static_parameter, 1)), $(Expr(:static_parameter, 2)))::Core.Const(Vector{Any}, false)
│ %2 = Base.size(x)::Tuple{Int64}
│ %3 = (%1)(Base.undef, %2)::Vector{Any}
│ %4 = Base.copyto_axcheck!(%3, x)::Vector{Any}
└── return %4
) => Vector{Any}
Not sure whether we should
- live with this
- undo this change (or at least bump max_methods to at least 2)
- audit all call sites of
copyto!
to not use the return value
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.
FWIW, The copyto!
method from #35965 should be removable with denizyuret/Knet.jl@bd7c162
I hit some more unpleasant delays after using Atom and CSV, e.g. in showing method lists and entering the Pkg prompt. This fixes them. It also allows rolling back one of the hacks in #33757.