Skip to content

Commit 8c07013

Browse files
authored
Tweak precompiles for reduced Requires/Revise latency (#37574)
1 parent 3028ade commit 8c07013

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

base/experimental.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ Closest candidates are:
220220
To insulate yourself against changes, consider putting any registrations inside an
221221
`if isdefined(Base.Experimental, :register_error_hint) ... end` block.
222222
"""
223-
function register_error_hint(handler, exct::Type)
224-
list = get!(()->[], _hint_handlers, exct)
223+
function register_error_hint(@nospecialize(handler), @nospecialize(exct::Type))
224+
list = get!(Vector{Any}, _hint_handlers, exct)
225225
push!(list, handler)
226226
return nothing
227227
end

contrib/generate_precompile.jl

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,18 @@ UP_ARROW = "\e[A"
1515
DOWN_ARROW = "\e[B"
1616

1717
hardcoded_precompile_statements = """
18-
@assert precompile(Tuple{typeof(Base.stale_cachefile), String, String})
19-
@assert precompile(Tuple{typeof(push!), Set{Module}, Module})
20-
@assert precompile(Tuple{typeof(push!), Set{Method}, Method})
21-
@assert precompile(Tuple{typeof(push!), Set{Base.PkgId}, Base.PkgId})
22-
@assert precompile(Tuple{typeof(getindex), Dict{Base.PkgId,String}, Base.PkgId})
23-
@assert precompile(Tuple{typeof(setindex!), Dict{String,Base.PkgId}, Base.PkgId, String})
18+
# used by Revise.jl
19+
@assert precompile(Tuple{typeof(Base.parse_cache_header), String})
20+
@assert precompile(Tuple{typeof(pushfirst!), Vector{Any}, Function})
21+
# used by Requires.jl
2422
@assert precompile(Tuple{typeof(get!), Type{Vector{Function}}, Dict{Base.PkgId,Vector{Function}}, Base.PkgId})
23+
@assert precompile(Tuple{typeof(haskey), Dict{Base.PkgId,Vector{Function}}, Base.PkgId})
24+
@assert precompile(Tuple{typeof(delete!), Dict{Base.PkgId,Vector{Function}}, Base.PkgId})
25+
@assert precompile(Tuple{typeof(push!), Vector{Function}, Function})
26+
# miscellaneous
27+
@assert precompile(Tuple{typeof(Base.require), Base.PkgId})
2528
@assert precompile(Tuple{typeof(isassigned), Core.SimpleVector, Int})
26-
@assert precompile(Tuple{typeof(pushfirst!), Vector{Any}, Function})
27-
@assert precompile(Tuple{typeof(Base.parse_cache_header), String})
29+
@assert precompile(Tuple{typeof(Base.Experimental.register_error_hint), Any, Type})
2830
"""
2931

3032
precompile_script = """
@@ -43,6 +45,13 @@ f(x) = x03
4345
f(1,2)
4446
[][1]
4547
cd("complet_path\t\t$CTRL_C
48+
# Used by JuliaInterpreter
49+
push!(Set{Module}(), Main)
50+
push!(Set{Method}(), first(methods(collect)))
51+
# Used by Revise
52+
(setindex!(Dict{String,Base.PkgId}(), Base.PkgId(Base), "file.jl"))["file.jl"]
53+
(setindex!(Dict{Base.PkgId,String}(), "file.jl", Base.PkgId(Base)))[Base.PkgId(Base)]
54+
get(Base.pkgorigins, Base.PkgId(Base), nothing)
4655
"""
4756

4857
julia_exepath() = joinpath(Sys.BINDIR, Base.julia_exename())
@@ -100,6 +109,15 @@ if FileWatching !== nothing
100109
"""
101110
end
102111

112+
Libdl = get(Base.loaded_modules,
113+
Base.PkgId(Base.UUID("8f399da3-3557-5675-b5ff-fb832c97cbdb"), "Libdl"),
114+
nothing)
115+
if Libdl !== nothing
116+
hardcoded_precompile_statements *= """
117+
precompile(Tuple{typeof(Libc.Libdl.dlopen), String})
118+
"""
119+
end
120+
103121
function generate_precompile_statements()
104122
start_time = time_ns()
105123
debug_output = devnull # or stdout

0 commit comments

Comments
 (0)