-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
Large number of invalidations by this package and seems to really slow down certain jll loads #77
Comments
|
Can you give the trees layout of invalidations that occur |
Full tree below, looks like much of the boolean logic. This is Static 0.7.6 and FFTW 1.5.0 btw. Replace FFTW with anything else that loads a JLL and seems to be similar (I had tried SpecialFunctions too). Fwiw, theres only 6 (not ~2000) invalidations when I do this on 1.7. Maybe I should file this on julialang? (you guys tell me, I really don't know)
|
|
I'm willing to bet that many of these originate from Pkg using an anonymous function that doesn't infer Bool as the return type. |
This is what I get on master julia> trees = invalidation_trees(invalidations)
3-element Vector{SnoopCompile.MethodInvalidations}:
inserting split(i::NDIndex, V::Val) @ Static ~/.julia/packages/Static/sVI3g/src/Static.jl:858 invalidated:
backedges: 1: superseding split(t, V::Val) @ Base.IteratorsMD multidimensional.jl:480 with MethodInstance for Base.IteratorsMD.split(::Any, ::Val{0}) (1 children)
inserting to_indices(A, inds, I::Tuple{AbstractArray{NDIndex{N, J}}, Vararg{Any}}) where {N, J} @ Static ~/.julia/packages/Static/sVI3g/src/Static.jl:922 invalidated:
backedges: 1: superseding to_indices(A, inds, I::Tuple{Any, Vararg{Any}}) @ Base indices.jl:352 with MethodInstance for to_indices(::AbstractArray, ::Any, ::Tuple{Any, CartesianIndex{0}}) (2 children)
inserting ifelse(::False, x, y) @ Static ~/.julia/packages/Static/sVI3g/src/Static.jl:88 invalidated:
mt_backedges: 1: signature Tuple{typeof(ifelse), Any, AbstractFloat, AbstractFloat} triggered MethodInstance for Base._fast(::typeof(max), ::AbstractFloat, ::AbstractFloat) (0 children)
2: signature Tuple{typeof(ifelse), Any, AbstractFloat, AbstractFloat} triggered MethodInstance for Base._fast(::typeof(min), ::AbstractFloat, ::AbstractFloat) (0 children)
3: signature Tuple{typeof(ifelse), Any, DateTime, Any} triggered MethodInstance for max(::DateTime, ::Any) (0 children)
4: signature Tuple{typeof(ifelse), Any, Union{Float16, Float32, Float64}, Union{Float16, Float32, Float64}} triggered MethodInstance for Base._extrema_rf(::Tuple{T, T}, ::Tuple{T, T}) where T<:Union{Float16, Float32, Float64} (34 children)
29 mt_cache
Still not great but a lot more manageable. |
Running things downstream, life seems to go on without them just fine. Found in SciML/DifferentialEquations.jl#786 and #77, these methods contribute to a ton of recompilation. Methods that cause lots of compilation but aren't used? Bye bye. Users of Static.jl can just manually handle `!`. It's safe because it just throws an error otherwise. We can put it in an FAQ if it's that much of an issue. But this is definitely not worth causing seconds of JIT lag downstream.
#78 will cut out the biggest one. None of the packages I tested downstream actually used it (i.e. no LoopVectorization etc.), so it seems fine to just cut. |
julia> using SnoopCompileCore; invalidations = @snoopr(using Static); using SnoopCompile
julia> trees = invalidation_trees(invalidations);
julia> using Pkg
julia> ftrees = filtermod(Pkg, trees)
SnoopCompile.MethodInvalidations[]
julia> using Tar
julia> ftrees = filtermod(Tar, trees)
1-element Vector{SnoopCompile.MethodInvalidations}:
inserting !(::False) in Static at /home/hendrik/.julia/packages/Static/sVI3g/src/Static.jl:427 invalidated:
mt_backedges: 1: signature Tuple{typeof(!), Any} triggered MethodInstance for Tar.var"#read_tarball#47"(::Vector{UInt8}, ::Base.DevNull, ::typeof(Tar.read_tarball), ::Tar.var"#26#28"{Vector{UInt8}, Bool, Bool, Base.Process, String}, ::Function, ::Base.Process) (2 children)
2: signature Tuple{typeof(!), Any} triggered MethodInstance for Tar.var"#read_tarball#47"(::Vector{UInt8}, ::Base.DevNull, ::typeof(Tar.read_tarball), ::Function, ::Function, ::Base.Process) (48 children) Could it also be that some code in Tar.jl is invalidated - and JLLs are shipped as compressed tarballs? |
Sadly, that's not the only reason (tested locally with my fixes to Tar.jl). It's getting better but there are still many invalidations. |
Looks like we can fix this soon in Julia 1.8 - maybe 1.8.2? With some recent (partially unmerged PRs) to Tar.jl and Pkg.jl (available in my branch https://github.com/ranocha/julia/tree/hr/wip) as well as JuliaLang/julia#46661 on top of the current julia> import Pkg; Pkg.activate(temp=true); Pkg.add(["Static", "FFTW_jll"])
julia> @time_imports using FFTW_jll
18.1 ms Preferences
0.3 ms JLLWrappers
49.6 ms FFTW_jll 4.16% compilation time
julia> @time_imports using Static
0.2 ms IfElse
16.2 ms Static and julia> import Pkg; Pkg.activate(temp=true); Pkg.add(["Static", "FFTW_jll"])
julia> @time_imports using Static
0.1 ms IfElse
19.1 ms Static
julia> @time_imports using FFTW_jll
17.4 ms Preferences
0.3 ms JLLWrappers
2.4 ms FFTW_jll 76.98% compilation time |
Note: julia> using SnoopCompile
julia> trees = invalidation_trees(invalidations)
2-element Vector{SnoopCompile.MethodInvalidations}:
inserting +(x::Ptr, ::StaticInt{N}) where N @ Static ~/.julia/dev/Static/src/Static.jl:443 invalidated:
mt_backedges: 1: signature Tuple{typeof(+), Ptr{UInt16}, Any} triggered MethodInstance for Base._copyfrompacked!(::Ptr, ::Ptr{UInt16}) (1 children)
2: signature Tuple{typeof(+), Ptr{Tuple{UInt8, UInt8}}, Any} triggered MethodInstance for Base._copyfrompacked!(::Ptr, ::Ptr{Tuple{UInt8, UInt8}}) (1 children)
3: signature Tuple{typeof(+), Ptr{UInt8}, Any} triggered MethodInstance for Base.GMP.var"#string#4"(::Int64, ::Integer, ::typeof(string), ::BigInt) (3 children)
inserting convert(::Type{T}, N::Union{StaticBool{N}, StaticFloat64{N}, StaticInt{N}} where N) where T<:Number @ Static ~/.julia/dev/Static/src/Static.jl:420 invalidated:
backedges: 1: superseding convert(::Type{T}, x::Number) where T<:Number @ Base number.jl:7 with MethodInstance for convert(::Type{T} where T<:Real, ::Real) (2 children)
2: superseding convert(::Type{T}, x::Number) where T<:Number @ Base number.jl:7 with MethodInstance for convert(::Type{Int64}, ::Real) (5 children)
3: superseding convert(::Type{T}, x::T) where T<:Number @ Base number.jl:6 with MethodInstance for convert(::Type{T}, ::Real) where T<:Real (26 children) and thus with #128 we're down to one invalidation tree with SciML/CommonWorldInvalidations.jl#2 |
0 invalidations now with other changes, so I'll call this solved. |
Found this while hunting this. I don't know if its alot or a little of that (this stuff way above my paygrade tbh), but thought I'd report.
On 1.8, using FFTW as an example of something that loads a jll:
@time_imports using Static, FFTW
vs@time_imports using FFTW
you get:vs
Also:
is ~ 2000 invalidations,
The text was updated successfully, but these errors were encountered: