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

PropertyDicts' Base.convert causes a bunch of invalidations #5

Closed
pankgeorg opened this issue Mar 29, 2022 · 2 comments
Closed

PropertyDicts' Base.convert causes a bunch of invalidations #5

pankgeorg opened this issue Mar 29, 2022 · 2 comments

Comments

@pankgeorg
Copy link

pankgeorg commented Mar 29, 2022

According to SnoopCompile, these lines https://github.com/JuliaCollections/PropertyDicts.jl/blob/master/src/PropertyDicts.jl#L21-L24 - (specfically convert(::Type{T}, d::PropertyDicts.PropertyDict) where T) cause ~400 invalidations (mt_backedges). Mainly methods that look like convert(SpecificType, Any)

The backedges are

 backedges: 1: superseding convert(::Type{T}, x::AbstractDict) where T<:AbstractDict in Base at abstractdict.jl:522 with MethodInstance for convert(::Type{Dict{Char, Any}}, ::AbstractDict) (1 children)
│                  2: superseding convert(::Type{T}, x::AbstractDict) where T<:AbstractDict in Base at abstractdict.jl:522 with MethodInstance for convert(::Type{Dict{String, Any}}, ::AbstractDict) (1 children)
│                  3: superseding convert(::Type{T}, x::AbstractDict) where T<:AbstractDict in Base at abstractdict.jl:522 with MethodInstance for convert(::Type{Dict{Symbol, Any}}, ::AbstractDict) (9 children)
│                  4: superseding convert(::Type{Any}, x) in Base at essentials.jl:204 with MethodInstance for convert(::Type{Any}, ::Any) (1435 children)

Edit: This seems to be a known "issue" invenia/Intervals.jl#144

@timholy
Copy link
Member

timholy commented Mar 29, 2022

The one on line 21 should be deleted because it is redundant with the fallback. If possible, the best answer is to ascend these triggers and figure out whether the code that is getting invalidated can be made more inferrable.

@pankgeorg
Copy link
Author

pankgeorg commented Mar 31, 2022

I'm not sure what that ascend means - is it something that I'll need to run in the ~400 functions that get invalidated? Here are the 20 last with the most children:

│                     363: signature Tuple{typeof(convert), Type{Symbol}, Any} triggered MethodInstance for setindex!(::IdDict{Module, Symbol}, ::Any, ::Any) (5 children)
│                     364: signature Tuple{typeof(convert), Type{Base.SHA1}, Any} triggered MethodInstance for convert(::Type{Union{Nothing, Base.SHA1}}, ::Any) (5 children)
│                     365: signature Tuple{typeof(convert), Union{Type{String}, Type{Pkg.Types.PackageSpec}}, Any} triggered MethodInstance for (::Base.var"#cvt1#1"{Tuple{Pkg.Types.PackageSpec, String}, _A} where _A)(::Int64) (5 children)
│                     366: signature Tuple{typeof(convert), Type{Base.StackTraces.StackFrame}, Any} triggered MethodInstance for _simplify_include_frames(::Vector{Any}) (6 children)
│                     367: signature Tuple{typeof(convert), Type{Downloads.Response}, Any} triggered MethodInstance for Downloads.RequestError(::String, ::UInt32, ::SubString{String}, ::Any) (7 children)
│                     368: signature Tuple{typeof(convert), Type{Union{Downloads.RequestError, Downloads.Response}}, Any} triggered MethodInstance for var"#request#5"(::Nothing, ::IOStream, ::Nothing, ::Vector{Pair{String, String}}, ::Float64, ::Pkg.PlatformEngines.var"#13#15"{Base.TTY}, ::Bool, ::Bool, ::Nothing, ::typeof(Downloads.request), ::String) (7 children)
│                     369: signature Tuple{typeof(convert), Type{Symbol}, Any} triggered MethodInstance for Base.ImmutableDict{Symbol, Any}(::Base.ImmutableDict{Symbol, Any}, ::Any, ::Any) (9 children)
│                     370: signature Tuple{typeof(convert), Type{Core.MethodTable}, Any} triggered MethodInstance for Base.MethodList(::Vector{Method}, ::Any) (9 children)
│                     371: signature Tuple{typeof(convert), Type{REPL.LineEdit.HistoryProvider}, Any} triggered MethodInstance for REPL.LineEdit.HistoryPrompt(::Any) (9 children)
│                     372: signature Tuple{typeof(convert), Type{Symbol}, Any} triggered MethodInstance for Base.StackTraces.StackFrame(::Any, ::Any, ::Any, ::Core.CodeInfo, ::Bool, ::Bool, ::Int64) (15 children)
│                     373: signature Tuple{typeof(convert), Type{REPL.AbstractREPL}, Any} triggered MethodInstance for convert(::Type{Union{Nothing, REPL.AbstractREPL}}, ::Any) (19 children)
│                     374: signature Tuple{typeof(convert), Type{Base.PkgId}, Any} triggered MethodInstance for setindex!(::IdDict{Module, Base.PkgId}, ::Any, ::Any) (21 children)
│                     375: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for convert(::Type{Union{Nothing, String}}, ::Any) (28 children)
│                     376: signature Tuple{typeof(convert), Type{Union{Downloads.RequestError, Downloads.Response}}, Any} triggered MethodInstance for var"#request#5"(::Nothing, ::IOStream, ::Nothing, ::Vector{Pair{String, String}}, ::Float64, ::Pkg.PlatformEngines.var"#14#16", ::Bool, ::Bool, ::Nothing, ::typeof(Downloads.request), ::String) (41 children)
│                     377: signature Tuple{typeof(convert), Type{Module}, Any} triggered MethodInstance for convert(::Type{Union{Nothing, Module}}, ::Any) (58 children)
│                     378: signature Tuple{typeof(convert), Type{Union{Core.CodeInfo, Core.MethodInstance}}, Any} triggered MethodInstance for convert(::Type{Union{Nothing, Core.CodeInfo, Core.MethodInstance}}, ::Any) (69 children)
│                     379: signature Tuple{typeof(convert), Type{AbstractVector{var"#s813"} where var"#s813"}, Any} triggered MethodInstance for DataFrames.TransformationResult(::Vector{Int64}, ::Any, ::Symbol, ::Bool) (72 children)
│                     380: signature Tuple{typeof(convert), Type{Symbol}, Any} triggered MethodInstance for merge(::NamedTuple{(), Tuple{}}, ::Base.Iterators.Pairs) (76 children)
│                     381: signature Tuple{typeof(convert), Type{REPL.LineEdit.ModeState}, Any} triggered MethodInstance for setindex!(::IdDict{REPL.LineEdit.TextInterface, REPL.LineEdit.ModeState}, ::Any, ::Any) (83 children)
│                     382: signature Tuple{typeof(convert), Type{Symbol}, Any} triggered MethodInstance for Pair{Symbol, Any}(::Any, ::Any) (97 children)
ubuntu@eleni-ubuntu-ec2:~/JuliaTeamJH$ julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.7.2 (2022-02-06)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using SnoopCompileCore
julia> invalidations = @snoopr using PropertyDicts
julia> using SnoopCompile; length(uinvalidated(invalidations))
1347

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

2 participants