Skip to content
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

Merged
merged 1 commit into from
Nov 9, 2019
Merged

more latency improvements for #33615 #33779

merged 1 commit into from
Nov 9, 2019

Conversation

JeffBezanson
Copy link
Member

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.

@KristofferC KristofferC mentioned this pull request Nov 7, 2019
19 tasks
@JeffBezanson JeffBezanson merged commit 6eebbbe into master Nov 9, 2019
@JeffBezanson JeffBezanson deleted the jb/more33615 branch November 9, 2019 16:38
JeffBezanson added a commit that referenced this pull request Nov 9, 2019
KristofferC pushed a commit that referenced this pull request Apr 11, 2020
@@ -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
Copy link
Member

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

Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:latency Compiler latency
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants