-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
work around some closure capture boxing inference issues in loading #59367
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
Merged
adienes
merged 4 commits into
JuliaLang:master
from
nsajko:loading-__require_prelocked-closure_captures_inference_invalidations
Aug 26, 2025
Merged
work around some closure capture boxing inference issues in loading #59367
adienes
merged 4 commits into
JuliaLang:master
from
nsajko:loading-__require_prelocked-closure_captures_inference_invalidations
Aug 26, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The only method of the `__require_prelocked` function in `Base` gets compiled with bad inference for two variables, `path` and `reasons`, which get pessimistically boxed (and inferred as `Any`), even though both of them are only assigned to once across both the method and the closure within (neither is assigned to within the closure). My guess for what causes this would be either of these, or the combination: * (mis)use of GOTO * `try`-`catch` The least demanding way to work around the issue is adding a `let` around the closure, as advised in the Performance tips. That is what this change does. This change should fix several bad inference results within method instances such as `__require_prelocked(::PkgId, ::Nothing)` and `__require_prelocked(::PkgId, ::String)`. Consequently, the sysimage should become less vulnerable to invalidation happening when loading certain packages.
These invalidations in particular are eliminated: Click to expand
{
"method_instance": {
"method": "joinpath(paths::AbstractString...) @ Base.Filesystem path.jl:346",
"method_instance": "MethodInstance for joinpath(::String, ::AbstractString)"
},
"children": [
{
"method_instance": {
"method": "_include_dependency!(dep_list::Vector{Any}, track_dependencies::Bool, mod::Module, _path::AbstractString, track_content::Bool, path_may_be_dir::Bool) @ Base loading.jl:2246",
"method_instance": "MethodInstance for Base._include_dependency!(::Vector{Any}, ::Bool, ::Module, ::AbstractString, ::Bool, ::Bool)"
},
"children": [
{
"method_instance": {
"method": "var\"#_include_dependency#900\"(track_content::Bool, path_may_be_dir::Bool, ::typeof(Base._include_dependency), mod::Module, _path::AbstractString) @ Base loading.jl:2241",
"method_instance": "MethodInstance for Base.var\"#_include_dependency#900\"(::Bool, ::Bool, ::typeof(Base._include_dependency), ::Module, ::AbstractString)"
},
"children": [
{
"method_instance": {
"method": "_include_dependency(mod::Module, _path::AbstractString; track_content, path_may_be_dir) @ Base loading.jl:2241",
"method_instance": "MethodInstance for Base._include_dependency(::Module, ::AbstractString)"
},
"children": [
{
"method_instance": {
"method": "_include(mapexpr::Function, mod::Module, _path::AbstractString) @ Base loading.jl:2913",
"method_instance": "MethodInstance for Base._include(::typeof(identity), ::Module, ::AbstractString)"
},
"children": [
{
"method_instance": {
"method": "include(mod::Module, _path::AbstractString) @ Base Base.jl:308",
"method_instance": "MethodInstance for Base.include(::Module, ::AbstractString)"
},
"children": [
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
{
"method_instance": {
"method": "_require_prelocked(uuidkey::Base.PkgId, env) @ Base loading.jl:2477",
"method_instance": "MethodInstance for Base._require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
{
"method_instance": {
"method": "__require(into::Module, mod::Symbol) @ Base loading.jl:2367",
"method_instance": "MethodInstance for Base.__require(::Module, ::Symbol)"
},
"children": [
]
},
{
"method_instance": {
"method": "_require_prelocked(uuidkey::Base.PkgId) @ Base loading.jl:2477",
"method_instance": "MethodInstance for Base._require_prelocked(::Base.PkgId)"
},
"children": [
{
"method_instance": {
"method": "__require(uuidkey::Base.PkgId) @ Base loading.jl:2476",
"method_instance": "MethodInstance for Base.__require(::Base.PkgId)"
},
"children": [
]
},
{
"method_instance": {
"method": "require_stdlib(package_uuidkey::Base.PkgId, ext::Union{Nothing, String}, from::Module) @ Base loading.jl:2775",
"method_instance": "MethodInstance for Base.require_stdlib(::Base.PkgId, ::Nothing, ::Module)"
},
"children": [
]
},
{
"method_instance": {
"method": "require_stdlib(package_uuidkey::Base.PkgId, ext::Union{Nothing, String}, from::Module) @ Base loading.jl:2775",
"method_instance": "MethodInstance for Base.require_stdlib(::Base.PkgId, ::String, ::Module)"
},
"children": [
]
},
{
"method_instance": {
"method": "run_extension_callbacks(extid::Base.ExtensionId) @ Base loading.jl:1576",
"method_instance": "MethodInstance for Base.run_extension_callbacks(::Base.ExtensionId)"
},
"children": [
{
"method_instance": {
"method": "(::Base.var\"#retry_load_extensions##0#retry_load_extensions##1\")(extid) @ Base loading.jl:1640",
"method_instance": "MethodInstance for (::Base.var\"#retry_load_extensions##0#retry_load_extensions##1\")(::Base.ExtensionId)"
},
"children": [
{
"method_instance": {
"method": "filter!(f, a::AbstractVector) @ Base array.jl:2999",
"method_instance": "MethodInstance for filter!(::Base.var\"#retry_load_extensions##0#retry_load_extensions##1\", ::Vector{Base.ExtensionId})"
},
"children": [
{
"method_instance": {
"method": "retry_load_extensions() @ Base loading.jl:1633",
"method_instance": "MethodInstance for Base.retry_load_extensions()"
},
"children": [
]
}
]
}
]
},
{
"method_instance": {
"method": "run_extension_callbacks(pkgid::Base.PkgId) @ Base loading.jl:1601",
"method_instance": "MethodInstance for Base.run_extension_callbacks(::Base.PkgId)"
},
"children": [
{
"method_instance": {
"method": "run_package_callbacks(modkey::Base.PkgId) @ Base loading.jl:1433",
"method_instance": "MethodInstance for Base.run_package_callbacks(::Base.PkgId)"
},
"children": [
{
"method_instance": {
"method": "_require_from_serialized(uuidkey::Base.PkgId, path::String, ocachepath::Union{Nothing, String}, sourcepath::String) @ Base loading.jl:2721",
"method_instance": "MethodInstance for Base._require_from_serialized(::Base.PkgId, ::String, ::Nothing, ::String)"
},
"children": [
]
},
{
"method_instance": {
"method": "_require_from_serialized(uuidkey::Base.PkgId, path::String, ocachepath::Union{Nothing, String}, sourcepath::String) @ Base loading.jl:2721",
"method_instance": "MethodInstance for Base._require_from_serialized(::Base.PkgId, ::String, ::String, ::String)"
},
"children": [
]
},
{
"method_instance": {
"method": "_require_prelocked(uuidkey::Base.PkgId, env) @ Base loading.jl:2477",
"method_instance": "MethodInstance for Base._require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "_require_prelocked(uuidkey::Base.PkgId, env) @ Base loading.jl:2477",
"method_instance": "MethodInstance for Base._require_prelocked(::Base.PkgId, ::String)"
},
"children": [
]
},
{
"method_instance": {
"method": "_tryrequire_from_serialized(modkey::Base.PkgId, build_id::UInt128) @ Base loading.jl:1933",
"method_instance": "MethodInstance for Base._tryrequire_from_serialized(::Base.PkgId, ::UInt128)"
},
"children": [
]
},
{
"method_instance": {
"method": "require_stdlib(package_uuidkey::Base.PkgId, ext::Union{Nothing, String}, from::Module) @ Base loading.jl:2775",
"method_instance": "MethodInstance for Base.require_stdlib(::Base.PkgId, ::Nothing, ::Module)"
},
"children": [
]
},
{
"method_instance": {
"method": "require_stdlib(package_uuidkey::Base.PkgId, ext::Union{Nothing, String}, from::Module) @ Base loading.jl:2775",
"method_instance": "MethodInstance for Base.require_stdlib(::Base.PkgId, ::String, ::Module)"
},
"children": [
]
},
{
"method_instance": {
"method": "var\"#_require_search_from_serialized#898\"(reasons, DEPOT_PATH::Vector{String}, ::typeof(Base._require_search_from_serialized), pkg::Base.PkgId, sourcepath::String, build_id::UInt128, stalecheck::Bool) @ Base loading.jl:1999",
"method_instance": "MethodInstance for Base.var\"#_require_search_from_serialized#898\"(::Any, ::Vector{String}, ::typeof(Base._require_search_from_serialized), ::Base.PkgId, ::String, ::UInt128, ::Bool)"
},
"children": [
{
"method_instance": {
"method": "kwcall(::NamedTuple, ::typeof(Base._require_search_from_serialized), pkg::Base.PkgId, sourcepath::String, build_id::UInt128, stalecheck::Bool) @ Base loading.jl:1999",
"method_instance": "MethodInstance for Core.kwcall(::NamedTuple{(:reasons,), <:Tuple{Any}}, ::typeof(Base._require_search_from_serialized), ::Base.PkgId, ::String, ::UInt128, ::Bool)"
},
"children": [
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
{
"method_instance": {
"method": "_require_prelocked(uuidkey::Base.PkgId, env) @ Base loading.jl:2477",
"method_instance": "MethodInstance for Base._require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
{
"method_instance": {
"method": "_require_prelocked(uuidkey::Base.PkgId) @ Base loading.jl:2477",
"method_instance": "MethodInstance for Base._require_prelocked(::Base.PkgId)"
},
"children": [
{
"method_instance": {
"method": "require_stdlib(package_uuidkey::Base.PkgId, ext::Union{Nothing, String}, from::Module) @ Base loading.jl:2775",
"method_instance": "MethodInstance for Base.require_stdlib(::Base.PkgId, ::Nothing, ::Module)"
},
"children": [
{
"method_instance": {
"method": "require_stdlib(package_uuidkey::Base.PkgId) @ Base loading.jl:2774",
"method_instance": "MethodInstance for Base.require_stdlib(::Base.PkgId)"
},
"children": [
{
"method_instance": {
"method": "init_stdio(handle::Ptr{Nothing}) @ Base stream.jl:290",
"method_instance": "MethodInstance for Base.init_stdio(::Ptr{Nothing})"
},
"children": [
{
"method_instance": {
"method": "_reinit_stdio() @ Base libuv.jl:147",
"method_instance": "MethodInstance for Base._reinit_stdio()"
},
"children": [
{
"method_instance": {
"method": "reinit_stdio() @ Base libuv.jl:144",
"method_instance": "MethodInstance for Base.reinit_stdio()"
},
"children": [
{
"method_instance": {
"method": "__init__() @ Base Base.jl:370",
"method_instance": "MethodInstance for Base.__init__()"
},
"children": [
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
{
"method_instance": {
"method": "_require_prelocked(uuidkey::Base.PkgId, env) @ Base loading.jl:2477",
"method_instance": "MethodInstance for Base._require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
{
"method_instance": {
"method": "_require_prelocked(uuidkey::Base.PkgId) @ Base loading.jl:2477",
"method_instance": "MethodInstance for Base._require_prelocked(::Base.PkgId)"
},
"children": [
{
"method_instance": {
"method": "require_stdlib(package_uuidkey::Base.PkgId, ext::Union{Nothing, String}, from::Module) @ Base loading.jl:2775",
"method_instance": "MethodInstance for Base.require_stdlib(::Base.PkgId, ::Nothing, ::Module)"
},
"children": [
{
"method_instance": {
"method": "require_stdlib(package_uuidkey::Base.PkgId) @ Base loading.jl:2774",
"method_instance": "MethodInstance for Base.require_stdlib(::Base.PkgId)"
},
"children": [
{
"method_instance": {
"method": "load_InteractiveUtils(mod::Module) @ Base client.jl:399",
"method_instance": "MethodInstance for Base.load_InteractiveUtils(::Module)"
},
"children": [
{
"method_instance": {
"method": "load_InteractiveUtils() @ Base client.jl:399",
"method_instance": "MethodInstance for Base.load_InteractiveUtils()"
},
"children": [
{
"method_instance": {
"method": "exec_options(opts) @ Base client.jl:234",
"method_instance": "MethodInstance for Base.exec_options(::Base.JLOptions)"
},
"children": [
{
"method_instance": {
"method": "_start() @ Base client.jl:556",
"method_instance": "MethodInstance for Base._start()"
},
"children": [
]
}
]
},
{
"method_instance": {
"method": "run_main_repl(interactive::Bool, quiet::Bool, banner::Symbol, history_file::Bool) @ Base client.jl:501",
"method_instance": "MethodInstance for Base.run_main_repl(::Bool, ::Bool, ::Symbol, ::Bool)"
},
"children": [
{
"method_instance": {
"method": "repl_main(::Any) @ Base client.jl:593",
"method_instance": "MethodInstance for Base.repl_main(::Vector{String})"
},
"children": [
{
"method_instance": {
"method": "_start() @ Base client.jl:556",
"method_instance": "MethodInstance for Base._start()"
},
"children": [
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
{
"method_instance": {
"method": "_require_prelocked(uuidkey::Base.PkgId, env) @ Base loading.jl:2477",
"method_instance": "MethodInstance for Base._require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
{
"method_instance": {
"method": "_require_prelocked(uuidkey::Base.PkgId) @ Base loading.jl:2477",
"method_instance": "MethodInstance for Base._require_prelocked(::Base.PkgId)"
},
"children": [
{
"method_instance": {
"method": "require_stdlib(package_uuidkey::Base.PkgId, ext::Union{Nothing, String}, from::Module) @ Base loading.jl:2775",
"method_instance": "MethodInstance for Base.require_stdlib(::Base.PkgId, ::Nothing, ::Module)"
},
"children": [
{
"method_instance": {
"method": "require_stdlib(package_uuidkey::Base.PkgId) @ Base loading.jl:2774",
"method_instance": "MethodInstance for Base.require_stdlib(::Base.PkgId)"
},
"children": [
{
"method_instance": {
"method": "load_REPL() @ Base client.jl:415",
"method_instance": "MethodInstance for Base.load_REPL()"
},
"children": [
{
"method_instance": {
"method": "run_main_repl(interactive::Bool, quiet::Bool, banner::Symbol, history_file::Bool) @ Base client.jl:501",
"method_instance": "MethodInstance for Base.run_main_repl(::Bool, ::Bool, ::Symbol, ::Bool)"
},
"children": [
]
}
]
}
]
}
]
}
]
}
]
}
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
{
"method_instance": {
"method": "_require_prelocked(uuidkey::Base.PkgId, env) @ Base loading.jl:2477",
"method_instance": "MethodInstance for Base._require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
{
"method_instance": {
"method": "_require_prelocked(uuidkey::Base.PkgId) @ Base loading.jl:2477",
"method_instance": "MethodInstance for Base._require_prelocked(::Base.PkgId)"
},
"children": [
{
"method_instance": {
"method": "require_stdlib(package_uuidkey::Base.PkgId, ext::Union{Nothing, String}, from::Module) @ Base loading.jl:2775",
"method_instance": "MethodInstance for Base.require_stdlib(::Base.PkgId, ::Nothing, ::Module)"
},
"children": [
{
"method_instance": {
"method": "require_stdlib(package_uuidkey::Base.PkgId) @ Base loading.jl:2774",
"method_instance": "MethodInstance for Base.require_stdlib(::Base.PkgId)"
},
"children": [
{
"method_instance": {
"method": "open(h::RawFD) @ Base stream.jl:330",
"method_instance": "MethodInstance for open(::RawFD)"
},
"children": [
]
}
]
}
]
}
]
}
]
}
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
{
"method_instance": {
"method": "_require_prelocked(uuidkey::Base.PkgId, env) @ Base loading.jl:2477",
"method_instance": "MethodInstance for Base._require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
{
"method_instance": {
"method": "_require_prelocked(uuidkey::Base.PkgId) @ Base loading.jl:2477",
"method_instance": "MethodInstance for Base._require_prelocked(::Base.PkgId)"
},
"children": [
{
"method_instance": {
"method": "require_stdlib(package_uuidkey::Base.PkgId, ext::Union{Nothing, String}, from::Module) @ Base loading.jl:2775",
"method_instance": "MethodInstance for Base.require_stdlib(::Base.PkgId, ::Nothing, ::Module)"
},
"children": [
{
"method_instance": {
"method": "require_stdlib(package_uuidkey::Base.PkgId) @ Base loading.jl:2774",
"method_instance": "MethodInstance for Base.require_stdlib(::Base.PkgId)"
},
"children": [
{
"method_instance": {
"method": "var\"#runtests#875\"(ncores::Int64, exit_on_error::Bool, revise::Bool, propagate_project::Bool, seed::Union{Nothing, Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}, julia_args::Cmd, ::typeof(Base.runtests), tests) @ Base util.jl:694",
"method_instance": "MethodInstance for Base.var\"#runtests#875\"(::Int64, ::Bool, ::Bool, ::Bool, ::Nothing, ::Cmd, ::typeof(Base.runtests), ::Vector{String})"
},
"children": [
{
"method_instance": {
"method": "runtests(tests; ncores, exit_on_error, revise, propagate_project, seed, julia_args) @ Base util.jl:694",
"method_instance": "MethodInstance for Base.runtests(::Vector{String})"
},
"children": [
{
"method_instance": {
"method": "runtests(; ...) @ Base util.jl:694",
"method_instance": "MethodInstance for Base.runtests()"
},
"children": [
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::String)"
},
"children": [
{
"method_instance": {
"method": "_require_prelocked(uuidkey::Base.PkgId, env) @ Base loading.jl:2477",
"method_instance": "MethodInstance for Base._require_prelocked(::Base.PkgId, ::String)"
},
"children": [
{
"method_instance": {
"method": "__require(into::Module, mod::Symbol) @ Base loading.jl:2367",
"method_instance": "MethodInstance for Base.__require(::Module, ::Symbol)"
},
"children": [
]
}
]
}
]
}
]
}
]
},
{
"method_instance": {
"method": "var\"#_require_search_from_serialized#898\"(reasons, DEPOT_PATH::Vector{String}, ::typeof(Base._require_search_from_serialized), pkg::Base.PkgId, sourcepath::String, build_id::UInt128, stalecheck::Bool) @ Base loading.jl:1999",
"method_instance": "MethodInstance for Base.var\"#_require_search_from_serialized#898\"(::Dict{String, Int64}, ::Vector{String}, ::typeof(Base._require_search_from_serialized), ::Base.PkgId, ::String, ::UInt128, ::Bool)"
},
"children": [
{
"method_instance": {
"method": "kwcall(::NamedTuple, ::typeof(Base._require_search_from_serialized), pkg::Base.PkgId, sourcepath::String, build_id::UInt128, stalecheck::Bool) @ Base loading.jl:1999",
"method_instance": "MethodInstance for Core.kwcall(::@NamedTuple{reasons::Dict{String, Int64}}, ::typeof(Base._require_search_from_serialized), ::Base.PkgId, ::String, ::UInt128, ::Bool)"
},
"children": [
]
}
]
},
{
"method_instance": {
"method": "var\"#_require_search_from_serialized#898\"(reasons, DEPOT_PATH::Vector{String}, ::typeof(Base._require_search_from_serialized), pkg::Base.PkgId, sourcepath::String, build_id::UInt128, stalecheck::Bool) @ Base loading.jl:1999",
"method_instance": "MethodInstance for Base.var\"#_require_search_from_serialized#898\"(::Nothing, ::Vector{String}, ::typeof(Base._require_search_from_serialized), ::Base.PkgId, ::String, ::UInt128, ::Bool)"
},
"children": [
{
"method_instance": {
"method": "_require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128, stalecheck::Bool; reasons, DEPOT_PATH) @ Base loading.jl:1999",
"method_instance": "MethodInstance for Base._require_search_from_serialized(::Base.PkgId, ::String, ::UInt128, ::Bool)"
},
"children": [
{
"method_instance": {
"method": "(::Base.var\"#__require_prelocked##0#__require_prelocked##1\")() @ Base loading.jl:2657",
"method_instance": "MethodInstance for (::Base.var\"#__require_prelocked##0#__require_prelocked##1\"{Base.PkgId})()"
},
"children": [
{
"method_instance": {
"method": "var\"#maybe_cachefile_lock#919\"(stale_age, ::typeof(Base.maybe_cachefile_lock), f, pkg::Base.PkgId, srcpath::String) @ Base loading.jl:3872",
"method_instance": "MethodInstance for Base.var\"#maybe_cachefile_lock#919\"(::Int64, ::typeof(Base.maybe_cachefile_lock), ::Base.var\"#__require_prelocked##0#__require_prelocked##1\"{Base.PkgId}, ::Base.PkgId, ::String)"
},
"children": [
{
"method_instance": {
"method": "maybe_cachefile_lock(f, pkg::Base.PkgId, srcpath::String; stale_age) @ Base loading.jl:3872",
"method_instance": "MethodInstance for Base.maybe_cachefile_lock(::Base.var\"#__require_prelocked##0#__require_prelocked##1\"{Base.PkgId}, ::Base.PkgId, ::String)"
},
"children": [
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::String)"
},
"children": [
]
}
]
}
]
}
]
},
{
"method_instance": {
"method": "_tryrequire_from_serialized(modkey::Base.PkgId, build_id::UInt128) @ Base loading.jl:1933",
"method_instance": "MethodInstance for Base._tryrequire_from_serialized(::Base.PkgId, ::UInt128)"
},
"children": [
{
"method_instance": {
"method": "_tryrequire_from_serialized(pkg::Base.PkgId, path::String, ocachepath::Union{Nothing, String}) @ Base loading.jl:1959",
"method_instance": "MethodInstance for Base._tryrequire_from_serialized(::Base.PkgId, ::String, ::Nothing)"
},
"children": [
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::String)"
},
"children": [
]
},
{
"method_instance": {
"method": "_require_from_serialized(uuidkey::Base.PkgId, path::String, ocachepath::Union{Nothing, String}, sourcepath::String) @ Base loading.jl:2721",
"method_instance": "MethodInstance for Base._require_from_serialized(::Base.PkgId, ::String, ::Nothing, ::String)"
},
"children": [
]
}
]
},
{
"method_instance": {
"method": "_tryrequire_from_serialized(pkg::Base.PkgId, path::String, ocachepath::Union{Nothing, String}) @ Base loading.jl:1959",
"method_instance": "MethodInstance for Base._tryrequire_from_serialized(::Base.PkgId, ::String, ::String)"
},
"children": [
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::String)"
},
"children": [
]
},
{
"method_instance": {
"method": "_require_from_serialized(uuidkey::Base.PkgId, path::String, ocachepath::Union{Nothing, String}, sourcepath::String) @ Base loading.jl:2721",
"method_instance": "MethodInstance for Base._require_from_serialized(::Base.PkgId, ::String, ::String, ::String)"
},
"children": [
]
}
]
}
]
}
]
},
{
"method_instance": {
"method": "kwcall(::NamedTuple, ::typeof(Base._require_search_from_serialized), pkg::Base.PkgId, sourcepath::String, build_id::UInt128, stalecheck::Bool) @ Base loading.jl:1999",
"method_instance": "MethodInstance for Core.kwcall(::@NamedTuple{DEPOT_PATH::Vector{String}}, ::typeof(Base._require_search_from_serialized), ::Base.PkgId, ::String, ::UInt128, ::Bool)"
},
"children": [
{
"method_instance": {
"method": "require_stdlib(package_uuidkey::Base.PkgId, ext::Union{Nothing, String}, from::Module) @ Base loading.jl:2775",
"method_instance": "MethodInstance for Base.require_stdlib(::Base.PkgId, ::Nothing, ::Module)"
},
"children": [
]
},
{
"method_instance": {
"method": "require_stdlib(package_uuidkey::Base.PkgId, ext::Union{Nothing, String}, from::Module) @ Base loading.jl:2775",
"method_instance": "MethodInstance for Base.require_stdlib(::Base.PkgId, ::Nothing, ::Module)"
},
"children": [
]
},
{
"method_instance": {
"method": "require_stdlib(package_uuidkey::Base.PkgId, ext::Union{Nothing, String}, from::Module) @ Base loading.jl:2775",
"method_instance": "MethodInstance for Base.require_stdlib(::Base.PkgId, ::Nothing, ::Module)"
},
"children": [
]
},
{
"method_instance": {
"method": "require_stdlib(package_uuidkey::Base.PkgId, ext::Union{Nothing, String}, from::Module) @ Base loading.jl:2775",
"method_instance": "MethodInstance for Base.require_stdlib(::Base.PkgId, ::Nothing, ::Module)"
},
"children": [
]
},
{
"method_instance": {
"method": "require_stdlib(package_uuidkey::Base.PkgId, ext::Union{Nothing, String}, from::Module) @ Base loading.jl:2775",
"method_instance": "MethodInstance for Base.require_stdlib(::Base.PkgId, ::Nothing, ::Module)"
},
"children": [
]
},
{
"method_instance": {
"method": "require_stdlib(package_uuidkey::Base.PkgId, ext::Union{Nothing, String}, from::Module) @ Base loading.jl:2775",
"method_instance": "MethodInstance for Base.require_stdlib(::Base.PkgId, ::Nothing, ::Module)"
},
"children": [
{
"method_instance": {
"method": "require_stdlib(package_uuidkey::Base.PkgId) @ Base loading.jl:2774",
"method_instance": "MethodInstance for Base.require_stdlib(::Base.PkgId)"
},
"children": [
{
"method_instance": {
"method": "profile_printing_listener(cond::Base.AsyncCondition) @ Base Base.jl:331",
"method_instance": "MethodInstance for Base.profile_printing_listener(::Base.AsyncCondition)"
},
"children": [
{
"method_instance": {
"method": "(::Base.var\"#start_profile_listener##0#start_profile_listener##1\")() @ Base Base.jl:354",
"method_instance": "MethodInstance for (::Base.var\"#start_profile_listener##0#start_profile_listener##1\"{Base.AsyncCondition})()"
},
"children": [
]
}
]
}
]
}
]
},
{
"method_instance": {
"method": "require_stdlib(package_uuidkey::Base.PkgId, ext::Union{Nothing, String}, from::Module) @ Base loading.jl:2775",
"method_instance": "MethodInstance for Base.require_stdlib(::Base.PkgId, ::String, ::Module)"
},
"children": [
]
}
]
}
]
}
]
}
]
},
{
"method_instance": {
"method": "run_extension_callbacks(pkgid::Base.PkgId) @ Base loading.jl:1601",
"method_instance": "MethodInstance for Base.run_extension_callbacks(::Base.PkgId)"
},
"children": [
{
"method_instance": {
"method": "run_package_callbacks(modkey::Base.PkgId) @ Base loading.jl:1433",
"method_instance": "MethodInstance for Base.run_package_callbacks(::Base.PkgId)"
},
"children": [
{
"method_instance": {
"method": "_require_prelocked(uuidkey::Base.PkgId, env) @ Base loading.jl:2477",
"method_instance": "MethodInstance for Base._require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "require_stdlib(package_uuidkey::Base.PkgId, ext::Union{Nothing, String}, from::Module) @ Base loading.jl:2775",
"method_instance": "MethodInstance for Base.require_stdlib(::Base.PkgId, ::Nothing, ::Module)"
},
"children": [
]
}
]
}
]
},
{
"method_instance": {
"method": "run_extension_callbacks(pkgid::Base.PkgId) @ Base loading.jl:1601",
"method_instance": "MethodInstance for Base.run_extension_callbacks(::Base.PkgId)"
},
"children": [
{
"method_instance": {
"method": "run_package_callbacks(modkey::Base.PkgId) @ Base loading.jl:1433",
"method_instance": "MethodInstance for Base.run_package_callbacks(::Base.PkgId)"
},
"children": [
{
"method_instance": {
"method": "_require_prelocked(uuidkey::Base.PkgId, env) @ Base loading.jl:2477",
"method_instance": "MethodInstance for Base._require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "require_stdlib(package_uuidkey::Base.PkgId, ext::Union{Nothing, String}, from::Module) @ Base loading.jl:2775",
"method_instance": "MethodInstance for Base.require_stdlib(::Base.PkgId, ::Nothing, ::Module)"
},
"children": [
]
}
]
}
]
},
{
"method_instance": {
"method": "run_extension_callbacks(pkgid::Base.PkgId) @ Base loading.jl:1601",
"method_instance": "MethodInstance for Base.run_extension_callbacks(::Base.PkgId)"
},
"children": [
{
"method_instance": {
"method": "run_package_callbacks(modkey::Base.PkgId) @ Base loading.jl:1433",
"method_instance": "MethodInstance for Base.run_package_callbacks(::Base.PkgId)"
},
"children": [
{
"method_instance": {
"method": "_require_prelocked(uuidkey::Base.PkgId, env) @ Base loading.jl:2477",
"method_instance": "MethodInstance for Base._require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "require_stdlib(package_uuidkey::Base.PkgId, ext::Union{Nothing, String}, from::Module) @ Base loading.jl:2775",
"method_instance": "MethodInstance for Base.require_stdlib(::Base.PkgId, ::Nothing, ::Module)"
},
"children": [
]
}
]
}
]
},
{
"method_instance": {
"method": "run_extension_callbacks(pkgid::Base.PkgId) @ Base loading.jl:1601",
"method_instance": "MethodInstance for Base.run_extension_callbacks(::Base.PkgId)"
},
"children": [
{
"method_instance": {
"method": "run_package_callbacks(modkey::Base.PkgId) @ Base loading.jl:1433",
"method_instance": "MethodInstance for Base.run_package_callbacks(::Base.PkgId)"
},
"children": [
{
"method_instance": {
"method": "_require_prelocked(uuidkey::Base.PkgId, env) @ Base loading.jl:2477",
"method_instance": "MethodInstance for Base._require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "require_stdlib(package_uuidkey::Base.PkgId, ext::Union{Nothing, String}, from::Module) @ Base loading.jl:2775",
"method_instance": "MethodInstance for Base.require_stdlib(::Base.PkgId, ::Nothing, ::Module)"
},
"children": [
]
}
]
}
]
},
{
"method_instance": {
"method": "run_extension_callbacks(pkgid::Base.PkgId) @ Base loading.jl:1601",
"method_instance": "MethodInstance for Base.run_extension_callbacks(::Base.PkgId)"
},
"children": [
{
"method_instance": {
"method": "run_package_callbacks(modkey::Base.PkgId) @ Base loading.jl:1433",
"method_instance": "MethodInstance for Base.run_package_callbacks(::Base.PkgId)"
},
"children": [
{
"method_instance": {
"method": "_require_prelocked(uuidkey::Base.PkgId, env) @ Base loading.jl:2477",
"method_instance": "MethodInstance for Base._require_prelocked(::Base.PkgId, ::Nothing)"
},
"children": [
]
},
{
"method_instance": {
"method": "require_stdlib(package_uuidkey::Base.PkgId, ext::Union{Nothing, String}, from::Module) @ Base loading.jl:2775",
"method_instance": "MethodInstance for Base.require_stdlib(::Base.PkgId, ::Nothing, ::Module)"
},
"children": [
]
}
]
}
]
}
]
}
]
}
]
}
]
},
{
"method_instance": {
"method": "__require_prelocked(pkg::Base.PkgId, env) @ Base loading.jl:2600",
"method_instance": "MethodInstance for Base.__require_prelocked(::Base.PkgId, ::String)"
},
"children": [
]
}
]
}
]
}
]
}
]
}
]
}
]
} Before this change, on struct S <: AbstractString end
function Base.thisind(::S, ::Int) end |
KristofferC
approved these changes
Aug 25, 2025
Some tests fail due to a network error. |
cross ref: #15276 |
…es_inference_invalidations
…es_inference_invalidations
KristofferC
pushed a commit
that referenced
this pull request
Sep 1, 2025
…59367) The only method of the `__require_prelocked` function in `Base` gets compiled with bad inference for two variables, `path` and `reasons`, which get pessimistically boxed (and inferred as `Any`), even though both of them are only assigned to once across both the method and the closure within (neither is assigned to within the closure). My guess for what causes this would be either of these, or the combination: * (mis)use of GOTO * `try`-`catch` The least demanding way to work around the issue is adding a `let` around the closure, as advised in the Performance tips. That is what this change does. This change should fix several bad inference results within method instances such as `__require_prelocked(::PkgId, ::Nothing)` and `__require_prelocked(::PkgId, ::String)`. Consequently, the sysimage should become less vulnerable to invalidation happening when loading certain packages. (cherry picked from commit 547f858)
KristofferC
pushed a commit
that referenced
this pull request
Sep 2, 2025
…59367) The only method of the `__require_prelocked` function in `Base` gets compiled with bad inference for two variables, `path` and `reasons`, which get pessimistically boxed (and inferred as `Any`), even though both of them are only assigned to once across both the method and the closure within (neither is assigned to within the closure). My guess for what causes this would be either of these, or the combination: * (mis)use of GOTO * `try`-`catch` The least demanding way to work around the issue is adding a `let` around the closure, as advised in the Performance tips. That is what this change does. This change should fix several bad inference results within method instances such as `__require_prelocked(::PkgId, ::Nothing)` and `__require_prelocked(::PkgId, ::String)`. Consequently, the sysimage should become less vulnerable to invalidation happening when loading certain packages. (cherry picked from commit 547f858)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The only method of the
__require_prelocked
function inBase
gets compiled with bad inference for two variables,path
andreasons
, which get pessimistically boxed (and inferred asAny
), even though both of them are only assigned to once across both the method and the closure within (neither is assigned to within the closure).My guess for what causes this would be either of these, or the combination:
(mis)use of GOTO
try
-catch
The least demanding way to work around the issue is adding a
let
around the closure, as advised in the Performance tips. That is what this change does.This change should fix several bad inference results within method instances such as
__require_prelocked(::PkgId, ::Nothing)
and__require_prelocked(::PkgId, ::String)
. Consequently, the sysimage should become less vulnerable to invalidation happening when loading certain packages.