Skip to content
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

Reduce number of invalidations #1

Open
nalimilan opened this issue Mar 1, 2022 · 0 comments
Open

Reduce number of invalidations #1

nalimilan opened this issue Mar 1, 2022 · 0 comments

Comments

@nalimilan
Copy link
Owner

nalimilan commented Mar 1, 2022

SnoopCompile indicates that most of invalidations are due to overwriting Base._promote_typesubtract which ideally wouldn't be needed, see JuliaLang/julia#38241) and from convert(::Type{Any}, x::TypedMissing), which I added to fix a method ambiguity. Maybe these could be alleviated if Base defined methods for AbstractMissing so that we don't have to redefine them.

julia> using SnoopCompile

julia> inv = @snoopr using TypedMissings

julia> invalidation_trees(inv)
9-element Vector{SnoopCompile.MethodInvalidations}:
 inserting isless(x::Missing, y::TypedMissing) in TypedMissings at /home/milan/.julia/dev/TypedMissings/src/TypedMissings.jl:260 invalidated:
   backedges: 1: superseding isless(::Missing, ::Any) in Base at missing.jl:87 with MethodInstance for isless(::Missing, ::Any) (1 children)
   43 mt_cache

 inserting *(d::Union{AbstractChar, AbstractString}, x::TypedMissing) in TypedMissings at /home/milan/.julia/dev/TypedMissings/src/TypedMissings.jl:407 invalidated:
   mt_backedges: 1: signature Tuple{typeof(*), String, Any} triggered MethodInstance for Logging.default_metafmt(::Base.CoreLogging.LogLevel, ::Any, ::Any, ::Any, ::Any, ::Any) (0 children)
                 2: signature Tuple{typeof(*), String, Any} triggered MethodInstance for Pkg.Registry.var"#update#54"(::IO, ::Bool, ::typeof(Pkg.Registry.update), ::Vector{Pkg.Registry.RegistrySpec}) (2 children)

 inserting ==(x::TypedMissing, ::Any) in TypedMissings at /home/milan/.julia/dev/TypedMissings/src/TypedMissings.jl:236 invalidated:
   backedges: 1: superseding ==(x, y) in Base at Base.jl:119 with MethodInstance for ==(::Any, ::Task) (1 children)
              2: superseding ==(x, y) in Base at Base.jl:119 with MethodInstance for ==(::Any, ::Base.UUID) (1 children)
              3: superseding ==(x, y) in Base at Base.jl:119 with MethodInstance for ==(::Any, ::Symbol) (6 children)

 inserting ==(::Any, y::TypedMissing) in TypedMissings at /home/milan/.julia/dev/TypedMissings/src/TypedMissings.jl:237 invalidated:
   backedges: 1: superseding ==(x, y) in Base at Base.jl:119 with MethodInstance for ==(::Base.UUID, ::Any) (1 children)
              2: superseding ==(x, y) in Base at Base.jl:119 with MethodInstance for ==(::Module, ::Any) (1 children)
              3: superseding ==(x, y) in Base at Base.jl:119 with MethodInstance for ==(::Method, ::Any) (1 children)
              4: superseding ==(x, y) in Base at Base.jl:119 with MethodInstance for ==(::Core.TypeName, ::Any) (2 children)
              5: superseding ==(x, y) in Base at Base.jl:119 with MethodInstance for ==(::Symbol, ::Any) (4 children)

 inserting isequal(x::TypedMissing, y) in TypedMissings at /home/milan/.julia/dev/TypedMissings/src/TypedMissings.jl:247 invalidated:
   backedges: 1: superseding isequal(x, y) in Base at operators.jl:140 with MethodInstance for isequal(::Any, ::Task) (3 children)
              2: superseding isequal(x, y) in Base at operators.jl:140 with MethodInstance for isequal(::Any, ::Base.UUID) (4 children)
              3: superseding isequal(x, y) in Base at operators.jl:140 with MethodInstance for isequal(::Any, ::Symbol) (89 children)

 inserting isequal(x, y::TypedMissing) in TypedMissings at /home/milan/.julia/dev/TypedMissings/src/TypedMissings.jl:248 invalidated:
   backedges: 1: superseding isequal(x, y) in Base at operators.jl:140 with MethodInstance for isequal(::Base.UUID, ::Any) (3 children)
              2: superseding isequal(x, y) in Base at operators.jl:140 with MethodInstance for isequal(::Module, ::Any) (4 children)
              3: superseding isequal(x, y) in Base at operators.jl:140 with MethodInstance for isequal(::Method, ::Any) (23 children)
              4: superseding isequal(x, y) in Base at operators.jl:140 with MethodInstance for isequal(::Symbol, ::Any) (33 children)
              5: superseding isequal(x, y) in Base at operators.jl:140 with MethodInstance for isequal(::Core.TypeName, ::Any) (68 children)

 inserting ismissing(::TypedMissing) in TypedMissings at /home/milan/.julia/dev/TypedMissings/src/TypedMissings.jl:154 invalidated:
   backedges: 1: superseding ismissing(x) in Base at essentials.jl:828 with MethodInstance for ismissing(::Any) (225 children)

 inserting convert(::Type{Any}, x::TypedMissing) in TypedMissings at /home/milan/.julia/dev/TypedMissings/src/TypedMissings.jl:226 invalidated:
   backedges: 1: superseding convert(::Type{Any}, x) in Base at essentials.jl:217 with MethodInstance for convert(::Type{Any}, ::Any) (534 children)

 deleting _promote_typesubtract(a) in Base at promotion.jl:162 invalidated:
   backedges:  1: superseding _promote_typesubtract(a) in Base at promotion.jl:162 with MethodInstance for Base._promote_typesubtract(::Type{Nothing}) (1 children)
               2: superseding _promote_typesubtract(a) in Base at promotion.jl:162 with MethodInstance for Base._promote_typesubtract(::Type{DataType}) (1 children)
               3: superseding _promote_typesubtract(a) in Base at promotion.jl:162 with MethodInstance for Base._promote_typesubtract(::Type{Vector{String}}) (1 children)
               4: superseding _promote_typesubtract(a) in Base at promotion.jl:162 with MethodInstance for Base._promote_typesubtract(::Type{NamedTuple{(:name, :uuid), _A}} where _A<:Tuple{Union{Nothing, String}, Union{Nothing, Base.UUID}}) (1 children)
               5: superseding _promote_typesubtract(a) in Base at promotion.jl:162 with MethodInstance for Base._promote_typesubtract(::Type{Symbol}) (2 children)
               6: superseding _promote_typesubtract(a) in Base at promotion.jl:162 with MethodInstance for Base._promote_typesubtract(::Type{Bool}) (2 children)
               7: superseding _promote_typesubtract(a) in Base at promotion.jl:162 with MethodInstance for Base._promote_typesubtract(::Type{Tuple{Symbol, Symbol}}) (2 children)
               8: superseding _promote_typesubtract(a) in Base at promotion.jl:162 with MethodInstance for Base._promote_typesubtract(::Type{<:Tuple}) (2 children)
               9: superseding _promote_typesubtract(a) in Base at promotion.jl:162 with MethodInstance for Base._promote_typesubtract(::Type{Union{}}) (3 children)
              10: superseding _promote_typesubtract(a) in Base at promotion.jl:162 with MethodInstance for Base._promote_typesubtract(::Type{Tuple{String, VersionNumber}}) (3 children)
              11: superseding _promote_typesubtract(a) in Base at promotion.jl:162 with MethodInstance for Base._promote_typesubtract(::Type{Dates.DateTime}) (3 children)
              12: superseding _promote_typesubtract(a) in Base at promotion.jl:162 with MethodInstance for Base._promote_typesubtract(::Type{Module}) (4 children)
              13: superseding _promote_typesubtract(a) in Base at promotion.jl:162 with MethodInstance for Base._promote_typesubtract(::Type) (5 children)
              14: superseding _promote_typesubtract(a) in Base at promotion.jl:162 with MethodInstance for Base._promote_typesubtract(::Type{Tuple{String, Nothing}}) (7 children)
              15: superseding _promote_typesubtract(a) in Base at promotion.jl:162 with MethodInstance for Base._promote_typesubtract(::Type{Any}) (8 children)
              16: superseding _promote_typesubtract(a) in Base at promotion.jl:162 with MethodInstance for Base._promote_typesubtract(::Type{Float64}) (10 children)
              17: superseding _promote_typesubtract(a) in Base at promotion.jl:162 with MethodInstance for Base._promote_typesubtract(::Type{Base.UUID}) (18 children)
              18: superseding _promote_typesubtract(a) in Base at promotion.jl:162 with MethodInstance for Base._promote_typesubtract(::Type{String}) (36 children)
              19: superseding _promote_typesubtract(a) in Base at promotion.jl:162 with MethodInstance for Base._promote_typesubtract(::DataType) (37 children)
              20: superseding _promote_typesubtract(a) in Base at promotion.jl:162 with MethodInstance for Base._promote_typesubtract(::Type{Expr}) (49 children)
              21: superseding _promote_typesubtract(a) in Base at promotion.jl:162 with MethodInstance for Base._promote_typesubtract(::Any) (406 children)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant