-
-
Notifications
You must be signed in to change notification settings - Fork 37
peakflops: make eltype a static parameter of the method
#1253
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
peakflops: make eltype a static parameter of the method
#1253
Conversation
|
The change eliminates all invalidations in the sysimage from running this code as a user: struct I <: Integer end
function Base.Int8(::I) end
function Base.UInt8(::I) endReproducer: ./julia -E 'using SnoopCompileCore; i = (@snoop_invalidations (struct I <: Integer end; function Base.Int8(::I) end; function Base.UInt8(::I) end)); using SnoopCompile; length(uinvalidated(i))'The eliminated invalidations: {
"invalidation_count": 8,
"trees": [
{
"method": "Int8(::Main.RawInvalidations.I) @ Main.RawInvalidations ~/invalidations/script/reproducer.jl:11",
"reason": "inserting",
"mt_backedges": [
{
"type": "Tuple{Type{Int8}, Integer}",
"tree": {
"method_instance": {
"method": "convert(::Type{T}, x::Number) where T<:Number @ Base number.jl:7",
"method_instance": "MethodInstance for convert(::Type{Int8}, ::Integer)"
},
"children": [
{
"method_instance": {
"method": "fill!(a::Union{Array{Int8}, Array{UInt8}}, x::Integer) @ Base array.jl:430",
"method_instance": "MethodInstance for fill!(::Union{Matrix{Int8}, Matrix{UInt8}}, ::Integer)"
},
"children": [
{
"method_instance": {
"method": "ones(::Type{T}, dims::NTuple{N, Integer}) where {T, N} @ Base array.jl:594",
"method_instance": "MethodInstance for ones(::DataType, ::Tuple{Int64, Int64})"
},
"children": [
{
"method_instance": {
"method": "ones(::Type{T}, dims::Union{Integer, AbstractUnitRange}...) where T @ Base array.jl:591",
"method_instance": "MethodInstance for ones(::DataType, ::Int64, ::Int64)"
},
"children": [
{
"method_instance": {
"method": "var\"#peakflops#332\"(eltype::DataType, ntrials::Integer, parallel::Bool, ::typeof(LinearAlgebra.peakflops), n::Integer) @ LinearAlgebra ~/tmp/jl/jl/master-69a22cf4bc/share/julia/stdlib/v1.13/LinearAlgebra/src/LinearAlgebra.jl:753",
"method_instance": "MethodInstance for LinearAlgebra.var\"#peakflops#332\"(::DataType, ::Int64, ::Bool, ::typeof(LinearAlgebra.peakflops), ::Int64)"
},
"children": [
]
},
{
"method_instance": {
"method": "var\"#peakflops#332\"(eltype::DataType, ntrials::Integer, parallel::Bool, ::typeof(LinearAlgebra.peakflops), n::Integer) @ LinearAlgebra ~/tmp/jl/jl/master-69a22cf4bc/share/julia/stdlib/v1.13/LinearAlgebra/src/LinearAlgebra.jl:753",
"method_instance": "MethodInstance for LinearAlgebra.var\"#peakflops#332\"(::DataType, ::Int64, ::Bool, ::typeof(LinearAlgebra.peakflops), ::Int64)"
},
"children": [
]
},
{
"method_instance": {
"method": "var\"#peakflops#332\"(eltype::DataType, ntrials::Integer, parallel::Bool, ::typeof(LinearAlgebra.peakflops), n::Integer) @ LinearAlgebra ~/tmp/jl/jl/master-69a22cf4bc/share/julia/stdlib/v1.13/LinearAlgebra/src/LinearAlgebra.jl:753",
"method_instance": "MethodInstance for LinearAlgebra.var\"#peakflops#332\"(::DataType, ::Int64, ::Bool, ::typeof(LinearAlgebra.peakflops), ::Int64)"
},
"children": [
]
},
{
"method_instance": {
"method": "var\"#peakflops#332\"(eltype::DataType, ntrials::Integer, parallel::Bool, ::typeof(LinearAlgebra.peakflops), n::Integer) @ LinearAlgebra ~/tmp/jl/jl/master-69a22cf4bc/share/julia/stdlib/v1.13/LinearAlgebra/src/LinearAlgebra.jl:753",
"method_instance": "MethodInstance for LinearAlgebra.var\"#peakflops#332\"(::DataType, ::Int64, ::Bool, ::typeof(LinearAlgebra.peakflops), ::Int64)"
},
"children": [
{
"method_instance": {
"method": "peakflops(n::Integer; eltype, ntrials, parallel) @ LinearAlgebra ~/tmp/jl/jl/master-69a22cf4bc/share/julia/stdlib/v1.13/LinearAlgebra/src/LinearAlgebra.jl:753",
"method_instance": "MethodInstance for LinearAlgebra.peakflops(::Int64)"
},
"children": [
]
},
{
"method_instance": {
"method": "peakflops(n::Integer; eltype, ntrials, parallel) @ LinearAlgebra ~/tmp/jl/jl/master-69a22cf4bc/share/julia/stdlib/v1.13/LinearAlgebra/src/LinearAlgebra.jl:753",
"method_instance": "MethodInstance for LinearAlgebra.peakflops(::Int64)"
},
"children": [
{
"method_instance": {
"method": "peakflops(; ...) @ LinearAlgebra ~/tmp/jl/jl/master-69a22cf4bc/share/julia/stdlib/v1.13/LinearAlgebra/src/LinearAlgebra.jl:753",
"method_instance": "MethodInstance for LinearAlgebra.peakflops()"
},
"children": [
]
}
]
}
]
}
]
}
]
}
]
}
]
}
}
],
"backedges": [
],
"mt_cache": [
],
"mt_disable": [
]
},
{
"method": "UInt8(::Main.RawInvalidations.I) @ Main.RawInvalidations ~/invalidations/script/reproducer.jl:12",
"reason": "inserting",
"mt_backedges": [
{
"type": "Tuple{Type{UInt8}, Integer}",
"tree": {
"method_instance": {
"method": "convert(::Type{T}, x::Number) where T<:Number @ Base number.jl:7",
"method_instance": "MethodInstance for convert(::Type{UInt8}, ::Integer)"
},
"children": [
{
"method_instance": {
"method": "fill!(a::Union{Array{Int8}, Array{UInt8}}, x::Integer) @ Base array.jl:430",
"method_instance": "MethodInstance for fill!(::Union{Matrix{Int8}, Matrix{UInt8}}, ::Integer)"
},
"children": [
]
}
]
}
}
],
"backedges": [
],
"mt_cache": [
],
"mt_disable": [
]
}
]
} |
|
Is this called when the sysimage is created? I don't see where (and that is required AFAIU to cause invalidations). |
|
No idea why I suspect that any method callable without arguments gets precompiled. No idea where this is implemented, if so. |
Otherwise `eltype` is inferred as merely `DataType`. Too bad that constprop doesn't fix this on its own. This makes the sysimage more resistant to invalidation.
|
Fixed the merge conflict. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1253 +/- ##
==========================================
- Coverage 92.03% 91.97% -0.06%
==========================================
Files 34 34
Lines 15459 15471 +12
==========================================
+ Hits 14227 14230 +3
- Misses 1232 1241 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
bump |
|
The change looks ok to me |
Otherwise
eltypeis inferred as merelyDataType. Too bad that constprop doesn't fix this on its own.This will make the sysimage more resistant to invalidation, once JuliaLang/julia updates LinearAlgebra.