Skip to content

Commit 45e0925

Browse files
KristofferCKristofferCtopolarity
authored
shield _artifact_str function behind a world age barrier (#58957)
We already do this for `require` in Base loading, it probably makes sense to do this here as well, as invalidating this function easily adds +1s in load time for a jll. Avoids the big load time penalty from loading IntelOpenMP_jll in #57436 (comment). Before: ``` julia> @time using ModelingToolkit 6.546844 seconds (16.09 M allocations: 938.530 MiB, 11.13% gc time, 16.35% compilation time: 12% of which was recompilation) ``` After: ``` julia> @time using ModelingToolkit 5.637914 seconds (8.26 M allocations: 533.694 MiB, 11.47% gc time, 3.11% compilation time: 17% of which was recompilation) ``` --------- Co-authored-by: KristofferC <kristoffer.carlsson@juliacomputing.com> Co-authored-by: Cody Tapscott <84105208+topolarity@users.noreply.github.com>
1 parent a58dc52 commit 45e0925

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

stdlib/Artifacts/src/Artifacts.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,14 @@ function jointail(dir, tail)
543543
end
544544

545545
function _artifact_str(__module__, artifacts_toml, name, path_tail, artifact_dict, hash, platform, ::Val{LazyArtifacts}) where LazyArtifacts
546+
world = Base._require_world_age[]
547+
if world == typemax(UInt)
548+
world = Base.get_world_counter()
549+
end
550+
return Base.invoke_in_world(world, __artifact_str, __module__, artifacts_toml, name, path_tail, artifact_dict, hash, platform, Val(LazyArtifacts))::String
551+
end
552+
553+
function __artifact_str(__module__, artifacts_toml, name, path_tail, artifact_dict, hash, platform, ::Val{LazyArtifacts}) where LazyArtifacts
546554
pkg = Base.PkgId(__module__)
547555
if pkg.uuid !== nothing
548556
# Process overrides for this UUID, if we know what it is
@@ -565,7 +573,8 @@ function _artifact_str(__module__, artifacts_toml, name, path_tail, artifact_dic
565573
if nameof(LazyArtifacts) in (:Pkg, :Artifacts, :PkgArtifacts)
566574
Base.depwarn("using Pkg instead of using LazyArtifacts is deprecated", :var"@artifact_str", force=true)
567575
end
568-
return jointail(LazyArtifacts.ensure_artifact_installed(string(name), meta, artifacts_toml; platform), path_tail)
576+
path_base = (@invokelatest LazyArtifacts.ensure_artifact_installed(string(name), meta, artifacts_toml; platform))::String
577+
return jointail(path_base, path_tail)
569578
end
570579
error("Artifact $(repr(name)) is a lazy artifact; package developers must call `using LazyArtifacts` in $(__module__) before using lazy artifacts.")
571580
end

0 commit comments

Comments
 (0)