Avoid most boxes in precompilation code#57986
Merged
KristofferC merged 3 commits intomasterfrom Apr 7, 2025
Merged
Conversation
Member
|
Is there a visible performance or latency benefit from this? Just curious. |
Member
Author
|
I've seen invalidations from some things that are fixed here, for example: Also, if you check what signatures are compiled on a I should check that these are gone with this PR though. |
Member
|
Prevents the following method instances in the sysimage from being invalidated: {
"method_instance": {
"method": "(var\"#monitor_std\"::Base.Precompilation.var\"#monitor_std#18#_precompilepkgs##26\")(single_requested_pkg, ::Base.Precompilation.var\"#monitor_std#_precompilepkgs##25\", pkg_config, pipe) @ Base.Precompilation precompilation.jl:762",
"method_instance": "MethodInstance for (::Base.Precompilation.var\"#monitor_std#18#_precompilepkgs##26\"{Bool, Set{Tuple{Base.PkgId, Pair{Cmd, Base.CacheFlags}}}, Dict{Tuple{Base.PkgId, Pair{Cmd, Base.CacheFlags}}, IOBuffer}, String, ReentrantLock, Base.Precompilation.var\"#color_string#_precompilepkgs##0\"{Bool}})(::Bool, ::Base.Precompilation.var\"#monitor_std#_precompilepkgs##25\"{Base.Precompilation.var\"#monitor_std#18#_precompilepkgs##26\"{Bool, Set{Tuple{Base.PkgId, Pair{Cmd, Base.CacheFlags}}}, Dict{Tuple{Base.PkgId, Pair{Cmd, Base.CacheFlags}}, IOBuffer}, String, ReentrantLock, Base.Precompilation.var\"#color_string#_precompilepkgs##0\"{Bool}}}, ::Tuple{Base.PkgId, Pair{Cmd, Base.CacheFlags}}, ::Pipe)"
},
"children": [
]
}{
"method_instance": {
"method": "(var\"#monitor_std\"::Base.Precompilation.var\"#monitor_std#18#_precompilepkgs##26\")(single_requested_pkg, ::Base.Precompilation.var\"#monitor_std#_precompilepkgs##25\", pkg_config, pipe) @ Base.Precompilation precompilation.jl:762",
"method_instance": "MethodInstance for (::Base.Precompilation.var\"#monitor_std#18#_precompilepkgs##26\"{Bool, Set{Tuple{Base.PkgId, Pair{Cmd, Base.CacheFlags}}}, Dict{Tuple{Base.PkgId, Pair{Cmd, Base.CacheFlags}}, IOBuffer}, String, ReentrantLock, Base.Precompilation.var\"#color_string#_precompilepkgs##0\"{Bool}})(::Bool, ::Base.Precompilation.var\"#monitor_std#_precompilepkgs##25\"{Base.Precompilation.var\"#monitor_std#18#_precompilepkgs##26\"{Bool, Set{Tuple{Base.PkgId, Pair{Cmd, Base.CacheFlags}}}, Dict{Tuple{Base.PkgId, Pair{Cmd, Base.CacheFlags}}, IOBuffer}, String, ReentrantLock, Base.Precompilation.var\"#color_string#_precompilepkgs##0\"{Bool}}}, ::Tuple{Base.PkgId, Pair{Cmd, Base.CacheFlags}}, ::Pipe)"
},
"children": [
]
}{
"method_instance": {
"method": "(var\"#monitor_std\"::Base.Precompilation.var\"#monitor_std#18#_precompilepkgs##26\")(single_requested_pkg, ::Base.Precompilation.var\"#monitor_std#_precompilepkgs##25\", pkg_config, pipe) @ Base.Precompilation precompilation.jl:762",
"method_instance": "MethodInstance for (::Base.Precompilation.var\"#monitor_std#18#_precompilepkgs##26\"{Bool, Set{Tuple{Base.PkgId, Pair{Cmd, Base.CacheFlags}}}, Dict{Tuple{Base.PkgId, Pair{Cmd, Base.CacheFlags}}, IOBuffer}, String, ReentrantLock, Base.Precompilation.var\"#color_string#_precompilepkgs##0\"{Bool}})(::Bool, ::Base.Precompilation.var\"#monitor_std#_precompilepkgs##25\"{Base.Precompilation.var\"#monitor_std#18#_precompilepkgs##26\"{Bool, Set{Tuple{Base.PkgId, Pair{Cmd, Base.CacheFlags}}}, Dict{Tuple{Base.PkgId, Pair{Cmd, Base.CacheFlags}}, IOBuffer}, String, ReentrantLock, Base.Precompilation.var\"#color_string#_precompilepkgs##0\"{Bool}}}, ::Tuple{Base.PkgId, Pair{Cmd, Base.CacheFlags}}, ::Pipe)"
},
"children": [
{
"method_instance": {
"method": "kwcall(::NamedTuple, ::Base.Precompilation.var\"#monitor_std#_precompilepkgs##25\", pkg_config, pipe) @ Base.Precompilation precompilation.jl:762",
"method_instance": "MethodInstance for Core.kwcall(::@NamedTuple{single_requested_pkg::Bool}, ::Base.Precompilation.var\"#monitor_std#_precompilepkgs##25\"{Base.Precompilation.var\"#monitor_std#18#_precompilepkgs##26\"{Bool, Set{Tuple{Base.PkgId, Pair{Cmd, Base.CacheFlags}}}, Dict{Tuple{Base.PkgId, Pair{Cmd, Base.CacheFlags}}, IOBuffer}, String, ReentrantLock, Base.Precompilation.var\"#color_string#_precompilepkgs##0\"{Bool}}}, ::Tuple{Base.PkgId, Pair{Cmd, Base.CacheFlags}}, ::Pipe)"
},
"children": [
]
}
]
}Full data: These sysimage invalidations happen on master when running the following code as a user: struct S <: AbstractString end
function Base.thisind(::S, ::Int) end |
…d may get invalidated when new `displaysize` methods is added (line in REPL)
51 tasks
KristofferC
added a commit
that referenced
this pull request
Apr 9, 2025
- Use `local` where variable names accidentally overlapped and caused
boxes
- Use `@lock` to avoid closures
- Move out some recursive closures to top-level normal function to avoid
boxing them
- Use explicit boxes (`Ref`) instead of relying on the typeassert on the
`Core.Box` because it it hard to determine if a `Core.Box` is benign or
not.
- Only assign to `io` once to avoid boxing it.
- Type assert some `Tuple{Int, Int}` on `IO`.
The two remaining boxes after this is `t_print` and `monitor_std`.
(cherry picked from commit 4a3eba3)
Merged
Merged
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
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.
localwhere variable names accidentally overlapped and caused boxes@lockto avoid closuresRef) instead of relying on the typeassert on theCore.Boxbecause it it hard to determine if aCore.Boxis benign or not.ioonce to avoid boxing it.The two remaining boxes after this is
t_printandmonitor_std.