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

Add a few precompiles for faster startup #185

Merged
merged 1 commit into from
Sep 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions src/Revise.jl
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ Wait for one or more of the files registered in `Revise.watched_files[dirname]`
modified, and then queue the corresponding files on [`Revise.revision_queue`](@ref).
This is generally called within an `@async`.
"""
function revise_dir_queued(dirname)
@noinline function revise_dir_queued(dirname)
if !isdir(dirname)
sleep(0.1) # in case git has done a delete/replace cycle
if !isfile(dirname)
Expand Down Expand Up @@ -749,6 +749,23 @@ function macroreplace!(ex::Expr, filename)
end
macroreplace!(s, filename) = s

@noinline function run_backend(backend)
while true
tls = task_local_storage()
tls[:SOURCE_PATH] = nothing
ast, show_value = take!(backend.repl_channel)
if show_value == -1
# exit flag
break
end
# Process revisions
revise(backend)
# Now eval the input
REPL.eval_user_input(ast, backend)
end
nothing
end

"""
steal_repl_backend(backend = Base.active_repl_backend)

Expand All @@ -762,21 +779,7 @@ function steal_repl_backend(backend = Base.active_repl_backend)
fetch(backend.backend_task)
# restart a new backend that differs only by processing the
# revision queue before evaluating each user input
backend.backend_task = @async begin
while true
tls = task_local_storage()
tls[:SOURCE_PATH] = nothing
ast, show_value = take!(backend.repl_channel)
if show_value == -1
# exit flag
break
end
# Process revisions
revise(backend)
# Now eval the input
REPL.eval_user_input(ast, backend)
end
end
backend.backend_task = @async run_backend(backend)
end
nothing
end
Expand Down Expand Up @@ -862,4 +865,7 @@ Base.push!(wl::WatchList, filename) = push!(wl.trackedfiles, filename)
WatchList() = WatchList(systime(), Set{String}())
Base.in(file, wl::WatchList) = in(file, wl.trackedfiles)

include("precompile.jl")
_precompile_()

end # module
3 changes: 2 additions & 1 deletion src/pkgs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ function watch_package(id::PkgId)
@async _watch_package(id)
end

function _watch_package(id::PkgId)
@noinline function _watch_package(id::PkgId)
modsym = Symbol(id.name)
if modsym ∈ dont_watch_pkgs
if modsym ∉ silence_pkgs
Expand All @@ -208,4 +208,5 @@ function _watch_package(id::PkgId)
end
files = parse_pkg_files(id)
init_watching(files)
nothing
end
15 changes: 15 additions & 0 deletions src/precompile.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function _precompile_()
ccall(:jl_generating_output, Cint, ()) == 1 || return nothing

precompile(Tuple{typeof(setindex!), typeof(fileinfos), FileInfo, String})
precompile(Tuple{typeof(setindex!), typeof(module2files), Vector{String}, Symbol})
precompile(Tuple{typeof(setindex!), typeof(watched_files), WatchList, String})
precompile(Tuple{typeof(haskey), typeof(watched_files), String})

precompile(Tuple{typeof(_watch_package), Base.PkgId})
precompile(Tuple{typeof(revise_dir_queued), String})
precompile(Tuple{typeof(run_backend), REPL.REPLBackend})
precompile(Tuple{typeof(steal_repl_backend), REPL.REPLBackend})

return nothing
end