Skip to content

Invalidations with `getindex`

Hey there, I'm on a kick to try and reduce TTFX for FinanceModels.jl 😄

In tracking invalidations, this method seems to have the most invalidations that occur:

julia> @time using AccessorsExtra
  0.459855 seconds (1.70 M allocations: 104.331 MiB, 3.31% gc time, 71.32% compilation time: 99% of which was recompilation)

In a fresh session (I followed https://timholy.github.io/SnoopCompile.jl/stable/snoopr/#A-more-complex-example)

julia> using Revise

julia> using SnoopCompileCore

(@v1.9) pkg> add AccessorsExtra
   Resolving package versions...
    Updating `~/.julia/environments/v1.9/Project.toml`
  [33016aad] + AccessorsExtra v0.1.55
  No Changes to `~/.julia/environments/v1.9/Manifest.toml`
Precompiling project...
  2 dependencies successfully precompiled in 2 seconds. 247 already precompiled.

julia> invalidations = @snoopr using AccessorsExtra;

julia> using SnoopCompile

julia> trees = invalidation_trees(invalidations);

julia> trees[end] # the one with the most invalidations
inserting getindex(a, i::FlexIx) @ AccessorsExtra ~/.julia/packages/AccessorsExtra/aXKc9/src/flexix.jl:5 invalidated:
   mt_backedges: 1: signature Tuple{typeof(getindex), Base.Broadcast.Broadcasted, Any} triggered MethodInstance for Base.Broadcast.copyto_nonleaf!(::Array, ::Base.Broadcast.Broadcasted, ::Base.OneTo, ::Int64, ::Int64) (0 children)
                 2: signature Tuple{typeof(getindex), Base.Broadcast.Broadcasted, Any} triggered MethodInstance for Base.Broadcast.copyto_nonleaf!(::BitArray, ::Base.Broadcast.Broadcasted, ::Base.OneTo, ::Int64, ::Int64) (0 children)
                 3: signature Tuple{typeof(getindex), Base.Broadcast.Broadcasted, Any} triggered MethodInstance for Base.Broadcast.copyto_nonleaf!(::Any, ::Base.Broadcast.Broadcasted, ::Base.OneTo, ::Any, ::Int64) (2 children)
   backedges: 1: superseding getindex(::Type{T}, vals...) where T @ Base array.jl:399 with MethodInstance for getindex(::DataType, ::Any) (1 children)
              2: superseding getindex(d::IdDict{K, V}, key) where {K, V} @ Base iddict.jl:106 with MethodInstance for getindex(::IdDict{Type, Union{Missing, Vector{Tuple{LineNumberNode, Expr}}}}, ::Any) (1 children)
              3: superseding getindex(h::Dict{K, V}, key) where {K, V} @ Base dict.jl:482 with MethodInstance for getindex(::Dict{Symbol, Nothing}, ::Any) (1 children)
              4: superseding getindex(h::Dict{K, V}, key) where {K, V} @ Base dict.jl:482 with MethodInstance for getindex(::Dict{Symbol, DataPipes.NoPrevArg}, ::Any) (1 children)
              5: superseding getindex(::Type{Any}, vals...) @ Base array.jl:415 with MethodInstance for getindex(::Type{Any}, ::Any, ::Vararg{Any}) (2 children)
              6: superseding getindex(::Type{Any}, vals...) @ Base array.jl:415 with MethodInstance for getindex(::Type{Any}, ::Vararg{Any}) (2 children)
              7: superseding getindex(h::Dict{K, V}, key) where {K, V} @ Base dict.jl:482 with MethodInstance for getindex(::Dict{Symbol, Symbol}, ::Any) (2 children)
              8: superseding getindex(d::IdDict{K, V}, key) where {K, V} @ Base iddict.jl:106 with MethodInstance for getindex(::IdDict{Any, Any}, ::Any) (19 children)
              9: superseding getindex(::Type{Any}, vals...) @ Base array.jl:415 with MethodInstance for getindex(::Type{Any}, ::Any) (5689 children)
   6 mt_cache
Edited by Alec Loudenback
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information