Skip to content

Commit

Permalink
more latency improvements for #33615 (#33779)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored Nov 9, 2019
1 parent 7212602 commit 6eebbbe
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1557,7 +1557,7 @@ function hcat(V::Vector{T}...) where T
throw(DimensionMismatch("vectors must have same lengths"))
end
end
return [ V[j][i]::T for i=1:length(V[1]), j=1:length(V) ]
return T[ V[j][i] for i=1:length(V[1]), j=1:length(V) ]
end

function vcat(arrays::Vector{T}...) where T
Expand Down
4 changes: 4 additions & 0 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,8 @@ function abstract_call(@nospecialize(f), fargs::Union{Nothing,Vector{Any}}, argt
return ret
end
return Any
elseif f === Tuple && la == 2 && !isconcretetype(widenconst(argtypes[2]))
return Tuple
elseif is_return_type(f)
rt_rt = return_type_tfunc(argtypes, vtypes, sv)
if rt_rt !== nothing
Expand Down Expand Up @@ -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
end

atype = argtypes_to_type(argtypes)
Expand Down
4 changes: 1 addition & 3 deletions base/compiler/tfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ function instanceof_tfunc(@nospecialize(t))
t′ = unwrap_unionall(t)
t′′, isexact = instanceof_tfunc(t′)
tr = rewrap_unionall(t′′, t)
# Note: adding the <:Tuple upper bound in NamedTuple was part of the load time
# regression in #33615.
if t′′ isa DataType && !has_free_typevars(tr) && t′′.name !== NamedTuple_typename
if t′′ isa DataType && !has_free_typevars(tr)
# a real instance must be within the declared bounds of the type,
# so we can intersect with the original wrapper.
tr = typeintersect(tr, t′′.name.wrapper)
Expand Down
23 changes: 15 additions & 8 deletions base/methodshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ function arg_decl_parts(m::Method)
for t in tv
show_env = ImmutableDict(show_env, :unionall_env => t)
end
decls = Any[argtype_decl(show_env, argnames[i], sig, i, m.nargs, m.isva)
decls = Tuple{String,String}[argtype_decl(show_env, argnames[i], sig, i, m.nargs, m.isva)
for i = 1:m.nargs]
else
decls = Any[("", "") for i = 1:length(sig.parameters)]
decls = Tuple{String,String}[("", "") for i = 1:length(sig.parameters::SimpleVector)]
end
return tv, decls, file, line
end
Expand Down Expand Up @@ -183,9 +183,11 @@ function show(io::IO, m::Method)
ft = unwrap_unionall(ft0)
d1 = decls[1]
if sig === Tuple
print(io, m.name)
decls = Any[(), ("...", "")]
elseif ft <: Function && isa(ft, DataType) &&
# Builtin
print(io, m.name, "(...) in ", m.module)
return
end
if ft <: Function && isa(ft, DataType) &&
isdefined(ft.name.module, ft.name.mt.name) &&
# TODO: more accurate test? (tn.name === "#" name)
ft0 === typeof(getfield(ft.name.module, ft.name.mt.name))
Expand All @@ -201,7 +203,7 @@ function show(io::IO, m::Method)
print(io, "(", d1[1], "::", d1[2], ")")
end
print(io, "(")
join(io, [isempty(d[2]) ? d[1] : d[1]*"::"*d[2] for d in decls[2:end]],
join(io, String[isempty(d[2]) ? d[1] : d[1]*"::"*d[2] for d in decls[2:end]],
", ", ", ")
kwargs = kwarg_decl(m)
if !isempty(kwargs)
Expand Down Expand Up @@ -259,7 +261,7 @@ function show_method_table(io::IO, ms::MethodList, max::Int=-1, header::Bool=tru
if max==-1 || n<max
n += 1
println(io)
print(io, "[$(n)] ")
print(io, "[$n] ")
show(io, meth)
file, line = updated_methodloc(meth)
push!(LAST_SHOWN_LINE_INFOS, (string(file), line))
Expand Down Expand Up @@ -340,6 +342,11 @@ function show(io::IO, ::MIME"text/html", m::Method)
ft0 = sig.parameters[1]
ft = unwrap_unionall(ft0)
d1 = decls[1]
if sig === Tuple
# Builtin
print(io, m.name, "(...) in ", m.module)
return
end
if ft <: Function && isa(ft, DataType) &&
isdefined(ft.name.module, ft.name.mt.name) &&
ft0 === typeof(getfield(ft.name.module, ft.name.mt.name))
Expand All @@ -355,7 +362,7 @@ function show(io::IO, ::MIME"text/html", m::Method)
print(io, "(", d1[1], "::<b>", d1[2], "</b>)")
end
print(io, "(")
join(io, [isempty(d[2]) ? d[1] : d[1]*"::<b>"*d[2]*"</b>"
join(io, String[isempty(d[2]) ? d[1] : d[1]*"::<b>"*d[2]*"</b>"
for d in decls[2:end]], ", ", ", ")
kwargs = kwarg_decl(m)
if !isempty(kwargs)
Expand Down
8 changes: 4 additions & 4 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,8 @@ show(io::IO, @nospecialize(x)) = show_default(io, x)
show_default(io::IO, @nospecialize(x)) = _show_default(io, inferencebarrier(x))

function _show_default(io::IO, @nospecialize(x))
t = typeof(x)::DataType
show(io, t)
t = typeof(x)
show(io, inferencebarrier(t))
print(io, '(')
nf = nfields(x)
nb = sizeof(x)
Expand Down Expand Up @@ -1135,7 +1135,7 @@ function show_generator(io, ex, indent)
end

function valid_import_path(@nospecialize ex)
return Meta.isexpr(ex, :(.)) && length(ex.args) > 0 && all(a->isa(a,Symbol), ex.args)
return Meta.isexpr(ex, :(.)) && length((ex::Expr).args) > 0 && all(a->isa(a,Symbol), (ex::Expr).args)
end

function show_import_path(io::IO, ex)
Expand Down Expand Up @@ -1514,7 +1514,7 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int)

elseif (head === :import || head === :using) && nargs == 1 &&
(valid_import_path(args[1]) ||
(Meta.isexpr(args[1], :(:)) && length(args[1].args) > 1 && all(valid_import_path, args[1].args)))
(Meta.isexpr(args[1], :(:)) && length((args[1]::Expr).args) > 1 && all(valid_import_path, (args[1]::Expr).args)))
print(io, head)
print(io, ' ')
first = true
Expand Down

4 comments on commit 6eebbbe

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

Please sign in to comment.