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

cache env lookups in the precompile process #48251

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 9 additions & 3 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1466,7 +1466,12 @@ For more details regarding code loading, see the manual sections on [modules](@r
"""
function require(into::Module, mod::Symbol)
@lock require_lock begin
LOADING_CACHE[] = LoadingCache()
reset_loading_cache = true
if LOADING_CACHE[] !== nothing
reset_loading_cache = false
else
LOADING_CACHE[] = LoadingCache()
end
try
uuidkey_env = identify_package_env(into, String(mod))
# Core.println("require($(PkgId(into)), $mod) -> $uuidkey_env")
Expand Down Expand Up @@ -1504,7 +1509,7 @@ function require(into::Module, mod::Symbol)
end
return _require_prelocked(uuidkey, env)
finally
LOADING_CACHE[] = nothing
reset_loading_cache && (LOADING_CACHE[] = nothing)
end
end
end
Expand Down Expand Up @@ -1886,6 +1891,8 @@ function include_package_for_output(pkg::PkgId, input::String, depot_path::Vecto
append!(empty!(Base.LOAD_PATH), load_path)
ENV["JULIA_LOAD_PATH"] = join(load_path, Sys.iswindows() ? ';' : ':')
set_active_project(nothing)
empty!(Base.EXT_DORMITORY) # If we have a custom sysimage with `EXT_DORMITORY` prepopulated
Base.LOADING_CACHE[] = Base.LoadingCache() # cache env lookups in precompile process
Base._track_dependencies[] = true
get!(Base.PkgOrigin, Base.pkgorigins, pkg).path = input
append!(empty!(Base._concrete_dependencies), concrete_deps)
Expand Down Expand Up @@ -1956,7 +1963,6 @@ function create_expr_cache(pkg::PkgId, input::String, output::String, output_o::
"w", stdout)
# write data over stdin to avoid the (unlikely) case of exceeding max command line size
write(io.in, """
empty!(Base.EXT_DORMITORY) # If we have a custom sysimage with `EXT_DORMITORY` prepopulated
Base.include_package_for_output($(pkg_str(pkg)), $(repr(abspath(input))), $(repr(depot_path)), $(repr(dl_load_path)),
$(repr(load_path)), $deps, $(repr(source_path(nothing))))
""")
Expand Down