Skip to content

Commit

Permalink
help load time regression in #33615 (#33757)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored Nov 5, 2019
1 parent 3608c84 commit ba4f858
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 22 deletions.
2 changes: 1 addition & 1 deletion base/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ setproperty!(x::Type, f::Symbol, v) = setfield!(x, f, v)
getproperty(x::Tuple, f::Int) = getfield(x, f)
setproperty!(x::Tuple, f::Int, v) = setfield!(x, f, v) # to get a decent error

getproperty(Core.@nospecialize(x), f::Symbol) = getfield(x, f)
getproperty(x, f::Symbol) = getfield(x, f)
setproperty!(x, f::Symbol, v) = setfield!(x, f, convert(fieldtype(typeof(x), f), v))

include("coreio.jl")
Expand Down
4 changes: 3 additions & 1 deletion base/compiler/tfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ function instanceof_tfunc(@nospecialize(t))
t′ = unwrap_unionall(t)
t′′, isexact = instanceof_tfunc(t′)
tr = rewrap_unionall(t′′, t)
if t′′ isa DataType && !has_free_typevars(tr)
# 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
# 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
2 changes: 1 addition & 1 deletion base/essentials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ true
function convert end

convert(::Type{Union{}}, x) = throw(MethodError(convert, (Union{}, x)))
convert(::Type{Any}, @nospecialize(x)) = x
convert(::Type{Any}, x) = x
convert(::Type{T}, x::T) where {T} = x
convert(::Type{Type}, x::Type) = x # the ssair optimizer is strongly dependent on this method existing to avoid over-specialization
# in the absence of inlining-enabled
Expand Down
2 changes: 1 addition & 1 deletion base/linked_list.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function list_deletefirst!(q::InvasiveLinkedList{T}, val::T) where T
head_next = head.next
while head_next !== val
head = head_next
head_next = head.next
head_next = head.next::Union{T, Nothing}
end
if q.tail::T === val
head.next = nothing
Expand Down
4 changes: 3 additions & 1 deletion base/promotion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ function typejoin(@nospecialize(a), @nospecialize(b))
if ai === bi || (isa(ai,Type) && isa(bi,Type) && ai <: bi && bi <: ai)
aprimary = aprimary{ai}
else
pushfirst!(vars, aprimary.var)
# pushfirst!(vars, aprimary.var)
_growbeg!(vars, 1)
arrayset(false, vars, aprimary.var, 1)
aprimary = aprimary.body
end
end
Expand Down
25 changes: 18 additions & 7 deletions base/strings/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,30 @@ function sprint(f::Function, args...; context=nothing, sizehint::Integer=0)
String(resize!(s.data, s.size))
end

tostr_sizehint(x) = 8
tostr_sizehint(x::AbstractString) = lastindex(x)
tostr_sizehint(x::Union{String,SubString{String}}) = sizeof(x)
tostr_sizehint(x::Float64) = 20
tostr_sizehint(x::Float32) = 12
# CategoricalArrays extends this
function tostr_sizehint end

function _str_sizehint(x)
if x isa Float64
return 20
elseif x isa Float32
return 12
elseif x isa String || x isa SubString{String}
return sizeof(x)
elseif x isa Char
return ncodeunits(x)
else
return 8
end
end

function print_to_string(xs...)
if isempty(xs)
return ""
end
siz::Int = 0
for x in xs
siz += tostr_sizehint(x)
siz += _str_sizehint(x)
end
# specialized for performance reasons
s = IOBuffer(sizehint=siz)
Expand All @@ -135,7 +146,7 @@ function string_with_env(env, xs...)
end
siz::Int = 0
for x in xs
siz += tostr_sizehint(x)
siz += _str_sizehint(x)
end
# specialized for performance reasons
s = IOBuffer(sizehint=siz)
Expand Down
4 changes: 2 additions & 2 deletions base/task.jl
Original file line number Diff line number Diff line change
Expand Up @@ -545,10 +545,10 @@ function schedule(t::Task, @nospecialize(arg); error=false)
t.state === :runnable || Base.error("schedule: Task not runnable")
if error
t.queue === nothing || Base.list_deletefirst!(t.queue, t)
t.exception = arg
setfield!(t, :exception, arg)
else
t.queue === nothing || Base.error("schedule: Task not runnable")
t.result = arg
setfield!(t, :result, arg)
end
enq_work(t)
return t
Expand Down
4 changes: 2 additions & 2 deletions base/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ end

## printing with color ##

const text_colors = AnyDict(
const text_colors = Dict{Union{Symbol,Int},String}(
:black => "\033[30m",
:red => "\033[31m",
:green => "\033[32m",
Expand Down Expand Up @@ -334,7 +334,7 @@ for i in 0:255
text_colors[i] = "\033[38;5;$(i)m"
end

const disable_text_style = AnyDict(
const disable_text_style = Dict{Symbol,String}(
:bold => "\033[22m",
:underline => "\033[24m",
:blink => "\033[25m",
Expand Down
2 changes: 1 addition & 1 deletion stdlib/Distributed/src/Distributed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Base: getindex, wait, put!, take!, fetch, isready, push!, length,
hash, ==, kill, close, isopen, showerror

# imports for use
using Base: Process, Semaphore, JLOptions, AnyDict, buffer_writes, @sync_add,
using Base: Process, Semaphore, JLOptions, buffer_writes, @sync_add,
VERSION_STRING, binding_module, atexit, julia_exename,
julia_cmd, AsyncGenerator, acquire, release, invokelatest,
shell_escape_posixly, uv_error, something, notnothing, isbuffered
Expand Down
4 changes: 2 additions & 2 deletions stdlib/Distributed/src/cluster.jl
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ function addprocs(manager::ClusterManager; kwargs...)
end

function addprocs_locked(manager::ClusterManager; kwargs...)
params = merge(default_addprocs_params(), AnyDict(kwargs))
params = merge(default_addprocs_params(), Dict{Symbol,Any}(kwargs))
topology(Symbol(params[:topology]))

if PGRP.topology !== :all_to_all
Expand Down Expand Up @@ -510,7 +510,7 @@ function set_valid_processes(plist::Array{Int})
end
end

default_addprocs_params() = AnyDict(
default_addprocs_params() = Dict{Symbol,Any}(
:topology => :all_to_all,
:dir => pwd(),
:exename => joinpath(Sys.BINDIR, julia_exename()),
Expand Down
6 changes: 3 additions & 3 deletions stdlib/Distributed/src/remotecall.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

abstract type AbstractRemoteRef end

"""
client_refs
Expand All @@ -8,9 +10,7 @@ Tracks whether a particular `AbstractRemoteRef`
The `client_refs` lock is also used to synchronize access to `.refs` and associated `clientset` state.
"""
const client_refs = WeakKeyDict{Any, Nothing}() # used as a WeakKeySet

abstract type AbstractRemoteRef end
const client_refs = WeakKeyDict{AbstractRemoteRef, Nothing}() # used as a WeakKeySet

"""
Future(w::Int, rrid::RRID, v::Union{Some, Nothing}=nothing)
Expand Down

2 comments on commit ba4f858

@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.