-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
append_c_digits
: typeassert Int
to improve inference
#57950
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
KristofferC
merged 1 commit into
JuliaLang:master
from
nsajko:invalidations__append_c_digits__typeassert_Int__right_bitshift
Apr 1, 2025
Merged
append_c_digits
: typeassert Int
to improve inference
#57950
KristofferC
merged 1 commit into
JuliaLang:master
from
nsajko:invalidations__append_c_digits__typeassert_Int__right_bitshift
Apr 1, 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
Should make the sysimage more resistant to method invalidation.
Eliminates all (47 on current struct I <: Integer end
function Base.:(>>)(::I, ::UInt8) end
function Base.:(>>)(::I, ::Int) end Reproduce with: ./julia -E 'using SnoopCompileCore; i = (@snoop_invalidations (struct I <: Integer end; function Base.:(>>)(::I, ::UInt8) end; function Base.:(>>)(::I, ::Int) end)); using SnoopCompile; length(uinvalidated(i))' The eliminated invalidations: {
"method": ">>(::Main.RawInvalidations.I, ::Int64) @ Main.RawInvalidations ~/invalidations/script/reproducer.jl:34",
"reason": "inserting",
"mt_backedges": [
],
"backedges": [
{
"method_instance": {
"method": ">>(x::Integer, c::Int64) @ Base operators.jl:761",
"method_instance": "MethodInstance for >>(::Integer, ::Int64)"
},
"children": [
{
"method_instance": {
"method": ">>(x::Integer, c::Integer) @ Base operators.jl:752",
"method_instance": "MethodInstance for >>(::Integer, ::UInt8)"
},
"children": [
]
},
{
"method_instance": {
"method": ">>(x::Integer, c::Integer) @ Base operators.jl:752",
"method_instance": "MethodInstance for >>(::Integer, ::UInt8)"
},
"children": [
]
}
]
}
],
"mt_cache": [
],
"mt_disable": [
]
} {
"method": ">>(::Main.RawInvalidations.I, ::UInt8) @ Main.RawInvalidations ~/invalidations/script/reproducer.jl:34",
"reason": "inserting",
"mt_backedges": [
{
"type": "Tuple{typeof(>>), Any, UInt8}",
"tree": {
"method_instance": {
"method": "append_c_digits(olength::Int64, digits::Unsigned, buf, pos::Int64) @ Base intfuncs.jl:843",
"method_instance": "MethodInstance for Base.append_c_digits(::Int64, ::Unsigned, ::Memory{UInt8}, ::Int64)"
},
"children": [
{
"method_instance": {
"method": "append_c_digits_fast(olength::Int64, digits::Unsigned, buf, pos::Int64) @ Base intfuncs.jl:871",
"method_instance": "MethodInstance for Base.append_c_digits_fast(::Int64, ::Unsigned, ::Memory{UInt8}, ::Int64)"
},
"children": [
]
},
{
"method_instance": {
"method": "append_nine_digits(digits::Unsigned, buf, pos::Int64) @ Base intfuncs.jl:860",
"method_instance": "MethodInstance for Base.append_nine_digits(::Unsigned, ::Memory{UInt8}, ::Int64)"
},
"children": [
{
"method_instance": {
"method": "append_c_digits_fast(olength::Int64, digits::Unsigned, buf, pos::Int64) @ Base intfuncs.jl:871",
"method_instance": "MethodInstance for Base.append_c_digits_fast(::Int64, ::Unsigned, ::Memory{UInt8}, ::Int64)"
},
"children": [
{
"method_instance": {
"method": "dec(x::Unsigned, pad::Int64, neg::Bool) @ Base intfuncs.jl:889",
"method_instance": "MethodInstance for Base.dec(::Unsigned, ::Int64, ::Bool)"
},
"children": [
]
}
]
}
]
}
]
}
}
],
"backedges": [
{
"method_instance": {
"method": ">>(x::Integer, c::Integer) @ Base operators.jl:752",
"method_instance": "MethodInstance for >>(::Integer, ::UInt8)"
},
"children": [
{
"method_instance": {
"method": "append_c_digits(olength::Int64, digits::Unsigned, buf, pos::Int64) @ Base intfuncs.jl:843",
"method_instance": "MethodInstance for Base.append_c_digits(::Int64, ::Unsigned, ::Memory{UInt8}, ::Int64)"
},
"children": [
]
}
]
}
],
"mt_cache": [
],
"mt_disable": [
]
} |
Why can't this be inferred? |
This was referenced Mar 31, 2025
topolarity
approved these changes
Apr 1, 2025
julia> code_typed(Base.divrem, (Unsigned, typeof(0x64)))
1-element Vector{Any}:
CodeInfo(
1 ─ %1 = Base.divrem(x, y, Base.RoundToZero)::Tuple{Any, Any}
└── return %1
) => Tuple{Any, Any} |
|
Yes, a lot of inference runs with abstract types. |
KristofferC
pushed a commit
that referenced
this pull request
Apr 4, 2025
Makes the sysimage more resistant to method invalidation, when defining a new `Integer` subtype with a right bitshift method. (cherry picked from commit 69a22cf)
51 tasks
KristofferC
pushed a commit
that referenced
this pull request
Apr 4, 2025
Makes the sysimage more resistant to method invalidation, when defining a new `Integer` subtype with a right bitshift method. (cherry picked from commit 69a22cf)
KristofferC
pushed a commit
that referenced
this pull request
Jun 4, 2025
Makes the sysimage more resistant to method invalidation, when defining a new `Integer` subtype with a right bitshift method. (cherry picked from commit 69a22cf)
KristofferC
pushed a commit
that referenced
this pull request
Jun 5, 2025
Makes the sysimage more resistant to method invalidation, when defining a new `Integer` subtype with a right bitshift method. (cherry picked from commit 69a22cf)
KristofferC
pushed a commit
that referenced
this pull request
Jul 3, 2025
Makes the sysimage more resistant to method invalidation, when defining a new `Integer` subtype with a right bitshift method. (cherry picked from commit 69a22cf)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
backport 1.10
Change should be backported to the 1.10 release
display and printing
Aesthetics and correctness of printed representations of objects.
invalidations
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.
Makes the sysimage more resistant to method invalidation, when defining a new
Integer
subtype with a right bitshift method.