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

Use snoopcompile to more aggressively precompile Gadfly #1280

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

non-Jedi
Copy link
Contributor

@non-Jedi non-Jedi commented Apr 23, 2019

Contributor checklist:

  • I've updated the documentation to reflect these changes
  • I've added an entry to NEWS.md
  • I've added and/or updated the unit tests
  • I've run the regression tests
  • I've squash'ed or fixup'ed junk commits with git-rebase
  • I've built the docs and confirmed these changes don't cause new errors

This PR builds on #1278 primarily so that I can benchmark more accurately; please only look at e9733d6 as part of this PR. The precompile.jl script was generated mostly using https://github.com/timholy/SnoopCompile.jl with some manual intervention on my part when it had trouble because of Requires.jl usage. I think the results below speak for themselves. We may be able to get a similar speedup by applying a similar procedure to Compose.

compare_3470acc_e9733d6

There's two clusters because we can't apply SnoopCompile to tests using DataFrames very well since it's behind Requires.jl.

That's over a 15% reduction overall, and obviously it's much more significant for the tests where it's most effective.

This gives a marginal improvement on speed and memory use during first
plot, but the biggest benefit is that it makes the code easier to read
and the profiling significantly easier to grok.
Comparing nothing by value (==, =!) rather than by identity (===, !==)
or by type (isnothing) can have negative consequences on code
speed. This commit changes all nothing comparisons to use the
isnothing utility added in Julia 1.1 and Compat 2.1.
@non-Jedi
Copy link
Contributor Author

non-Jedi commented Apr 23, 2019

@timholy do you know if the segfault seen here in CI on Julia 1.0.3 a known problem with the SnoopCompile/1.0 combination? I must admit that the precompile statements generated are a bit of a black box to me, and I didn't see any mention of this problem in the SnoopCompile repo.

@non-Jedi
Copy link
Contributor Author

non-Jedi commented Apr 23, 2019

After further evaluation, the wins here aren't nearly as clearcut as I had hoped. The gains to drawing time are almost entirely offset by using Gadfly now taking 4 seconds longer.

usingtimeboxplot

So if you're not using DataFrames, your time to first plot improves by a relatively significant margin with this PR. If you are, it actually gets worse. :/

@timholy
Copy link
Collaborator

timholy commented Apr 23, 2019

The segfault is definitely not expected. But that would seem to be a Julia bug. I'd consider trying to binary-search-comment out blocks until you identify the line that's causing it.

A couple of usage tips: when I first wrote SnoopCompile, I didn't fully understand that the relevant time to measure was inference time rather than the core compiler's time (only type-inferred code gets cached, not native code). So the strategy I use now is to measure inference time (requires julia 1.2) with some cutoff, e.g., tmin = 0.01. Currently I just craft the precompile file manually in most cases, since I typically find that only a few functions account for most of the time. If you precompile a smaller set you may not get the segfault.

Also, function signatures like ##78##79 imply anonymous functions. Those may not have the same name each time. I thought I was eliminating those from precompile, but clearly some are getting through. You might just try a search on ## and delete those lines.

The gains won't be very large until something like JuliaLang/julia#31466 gets merged. There are just too many methods that fail to get cached with the way julia currently does this.

@bjarthur
Copy link
Member

worth noting that we used to precompile but stripped it out as it didn't make that much difference. definitely worth revisiting though, especially in light of tim's new strategy to focus on inference time.

should also reference #921

@Moelf
Copy link

Moelf commented Oct 17, 2020

is this still set to be done?
1.5.2 and latest release

julia -e "using Gadfly; display(plot(y=rand(10)))"  30.53s user 0.78s system 101% cpu 30.931 total

@timholy
Copy link
Collaborator

timholy commented Oct 17, 2020

I assume it still needs someone to tackle it. A few tips I've learned in the interim:

@nalimilan
Copy link
Contributor

For reference, CategoricalArrays 0.9 should trigger far fewer invalidations, see JuliaData/CategoricalArrays.jl#310.

@bjarthur
Copy link
Member

bjarthur commented Feb 7, 2021

the invalidations are now down to 375 (from ~1850) on Gadfly and Compose master using julia 1.6-rc1. this is with no Gadfly-specific effort to actually reduce them. all of the "backedges" (as indicated with "superseding") are some other package invalidating Base. i don't think there's anything we can change in Gadfly to fix those. (am i wrong about that?). not sure how to look into "mt_backedges" (as indicated with "signature"), as ascend doesn't seem to work on them.

julia> using SnoopCompileCore

julia> invalidations = @snoopr using Gadfly;

julia> using SnoopCompile

julia> length(uinvalidated(invalidations))
375

julia> trees = invalidation_trees(invalidations)
insert_backedges for MethodInstance for (::Rmath_jll.var"#1#2")(::Any)
22-element Vector{SnoopCompile.MethodInvalidations}:
 inserting convert(::Type{var"#s4"} where var"#s4"<:Tuple, comp::ChainRulesCore.Composite{var"#s3", var"#s2"} where {var"#s3", var"#s2"<:Tuple}) in ChainRulesCore at /Users/arthurb/.julia/packages/ChainRulesCore/eBwSt/src/differentials/composite.jl:68 invalidated:
   mt_backedges: 1: signature Tuple{typeof(convert), Type{Tuple{DataType, DataType, DataType}}, Any} triggered MethodInstance for Pair{DataType, Tuple{DataType, DataType, DataType}}(::Any, ::Any) (0 children)
                 2: signature Tuple{typeof(convert), Type{NTuple{8, DataType}}, Any} triggered MethodInstance for Pair{DataType, NTuple{8, DataType}}(::Any, ::Any) (0 children)
                 3: signature Tuple{typeof(convert), Type{NTuple{7, DataType}}, Any} triggered MethodInstance for Pair{DataType, NTuple{7, DataType}}(::Any, ::Any) (0 children)
                 4: signature Tuple{typeof(convert), Type{Tuple{Symbol, Any, Symbol, Symbol}}, Any} triggered MethodInstance for setindex!(::Vector{Tuple{Symbol, Any, Symbol, Symbol}}, ::Any, ::Int64) (0 children)
                 5: signature Tuple{typeof(convert), Type{Tuple{Base.UUID, String}}, Any} triggered MethodInstance for setindex!(::Vector{Tuple{Base.UUID, String}}, ::Any, ::Int64) (0 children)
                 6: signature Tuple{typeof(convert), Type{Tuple{Any, String}}, Any} triggered MethodInstance for setindex!(::Vector{Tuple{Any, String}}, ::Any, ::Int64) (0 children)

 inserting getproperty(::StaticArrays.SOneTo{n}, s::Symbol) where n in StaticArrays at /Users/arthurb/.julia/packages/StaticArrays/NTbHj/src/SOneTo.jl:57 invalidated:
   backedges: 1: superseding getproperty(x, f::Symbol) in Base at Base.jl:33 with MethodInstance for getproperty(::AbstractUnitRange, ::Symbol) (1 children)
   10 mt_cache

 inserting in(key, v::Base.KeySet{K, T}) where {K, T<:(OrderedCollections.OrderedDict{K, V} where V)} in OrderedCollections at /Users/arthurb/.julia/packages/OrderedCollections/Vaq3d/src/ordered_dict.jl:394 invalidated:
   backedges: 1: superseding in(k, v::Base.KeySet) in Base at abstractdict.jl:69 with MethodInstance for in(::Char, ::Base.KeySet) (2 children)

 inserting convert(::Type{Union{Nothing, S}}, x::CategoricalArrays.CategoricalValue) where S<:Union{AbstractChar, AbstractString, Number} in CategoricalArrays at /Users/arthurb/.julia/packages/CategoricalArrays/YxMoo/src/value.jl:77 invalidated:
   backedges: 1: superseding convert(::Type{T}, x) where T>:Nothing in Base at some.jl:36 with MethodInstance for convert(::Type{Union{Nothing, String}}, ::Any) (2 children)
   3 mt_cache

 inserting similar(A::AbstractArray, ::Type{T}, inds::Tuple{Union{Integer, AbstractUnitRange}, Vararg{Union{Integer, AbstractUnitRange}, N} where N}) where T in OffsetArrays at /Users/arthurb/.julia/packages/OffsetArrays/PdMCN/src/OffsetArrays.jl:252 invalidated:
   mt_backedges: 1: signature Tuple{typeof(similar), Vector{Symbol}, Type{Symbol}, Tuple{Union{Integer, AbstractUnitRange}}} triggered MethodInstance for similar(::Vector{Symbol}, ::Type{Symbol}, ::Union{Integer, AbstractUnitRange}) (0 children)
                 2: signature Tuple{typeof(similar), Vector{Symbol}, Type{Symbol}, Tuple{Union{Integer, AbstractUnitRange}}} triggered MethodInstance for similar(::Vector{Symbol}, ::Type{Symbol}, ::Tuple{Union{Integer, Base.OneTo}}) (2 children)

 inserting any(f::Function, a::StaticArrays.StaticArray; dims) in StaticArrays at /Users/arthurb/.julia/packages/StaticArrays/NTbHj/src/mapreduce.jl:265 invalidated:
   backedges: 1: superseding any(f::Function, a::AbstractArray; dims) in Base at reducedim.jl:883 with MethodInstance for any(::typeof(ismissing), ::AbstractArray) (1 children)
              2: superseding any(f, itr) in Base at reduce.jl:871 with MethodInstance for any(::typeof(ismissing), ::Any) (1 children)
   3 mt_cache

 inserting (::Type{SA})(a::StaticArrays.StaticArray) where SA<:StaticArrays.SizedArray in StaticArrays at /Users/arthurb/.julia/packages/StaticArrays/NTbHj/src/convert.jl:6 invalidated:
   backedges: 1: superseding Union{}(a...) in Core at boot.jl:247 with MethodInstance for Union{}(::AbstractArray) (2 children)
   1 mt_cache

 inserting (::Type{SA})(a::AbstractArray) where SA<:StaticArrays.StaticArray in StaticArrays at /Users/arthurb/.julia/packages/StaticArrays/NTbHj/src/convert.jl:7 invalidated:
   backedges: 1: superseding Union{}(a...) in Core at boot.jl:247 with MethodInstance for Union{}(::Vector{var"#s120"} where var"#s120"<:Union{Float32, Float64}) (2 children)

 inserting (::Type{var"#s2"} where var"#s2"<:FixedPointNumbers.FixedPoint)(x::AbstractChar) in FixedPointNumbers at /Users/arthurb/.julia/packages/FixedPointNumbers/HAGk2/src/FixedPointNumbers.jl:60 invalidated:
   backedges: 1: superseding (::Type{T})(x::AbstractChar) where T<:Union{AbstractChar, Number} in Base at char.jl:50 with MethodInstance for (::Type{K} where K<:Char)(::Char) (2 children)
   1 mt_cache

 inserting Base.IteratorSize(::Type{T} where T<:DataStructures.AbstractIncludeLast) in DataStructures at /Users/arthurb/.julia/packages/DataStructures/ixwFs/src/container_loops.jl:88 invalidated:
   backedges: 1: superseding Base.IteratorSize(::Type) in Base at generator.jl:91 with MethodInstance for Base.IteratorSize(::Type{var"#s444"} where {T, var"#s444"<:LinearAlgebra.Factorization{T}}) (3 children)
   122 mt_cache

 inserting similar(A::AbstractRange, ::Type{Union{Missing, CategoricalArrays.CategoricalValue{T, R} where R<:Integer}}, dims::Tuple{Vararg{Int64, N}}) where {T, N} in CategoricalArrays at /Users/arthurb/.julia/packages/CategoricalArrays/YxMoo/src/array.jl:677 invalidated:
   backedges: 1: superseding similar(a::AbstractArray, ::Type{T}, dims::Tuple{Vararg{Int64, N}}) where {T, N} in Base at abstractarray.jl:744 with MethodInstance for similar(::UnitRange{Int64}, ::Type, ::Tuple{Int64}) (3 children)

 inserting similar(A::AbstractRange, ::Type{CategoricalArrays.CategoricalValue{T, R}}, dims::Tuple{Vararg{Int64, N}}) where {T, R, N} in CategoricalArrays at /Users/arthurb/.julia/packages/CategoricalArrays/YxMoo/src/array.jl:668 invalidated:
   backedges: 1: superseding similar(a::AbstractArray, ::Type{T}, dims::Tuple{Vararg{Int64, N}}) where {T, N} in Base at abstractarray.jl:744 with MethodInstance for similar(::UnitRange{Int64}, ::DataType, ::Tuple{Int64}) (3 children)

 inserting similar(::Type{T}, shape::Tuple{Union{Integer, AbstractUnitRange}, Vararg{Union{Integer, AbstractUnitRange}, N} where N}) where T<:AbstractArray in OffsetArrays at /Users/arthurb/.julia/packages/OffsetArrays/PdMCN/src/OffsetArrays.jl:276 invalidated:
   mt_backedges: 1: signature Tuple{typeof(similar), Type{Array{Any, _A}} where _A, Tuple{Union{Integer, AbstractUnitRange}}} triggered MethodInstance for similar(::Type{Array{Any, _A}}, ::Union{Integer, AbstractUnitRange}) where _A (0 children)
                 2: signature Tuple{typeof(similar), Type{Array{String, _A}} where _A, Tuple{Union{Integer, AbstractUnitRange}}} triggered MethodInstance for similar(::Type{Array{String, _A}}, ::Union{Integer, AbstractUnitRange}) where _A (0 children)
                 3: signature Tuple{typeof(similar), Type{Array{Expr, _A}} where _A, Tuple{Union{Integer, AbstractUnitRange}}} triggered MethodInstance for similar(::Type{Array{Expr, _A}}, ::Union{Integer, AbstractUnitRange}) where _A (0 children)
                 4: signature Tuple{typeof(similar), Type{Array{Any, _A}} where _A, Tuple{Union{Integer, AbstractUnitRange}}} triggered MethodInstance for similar(::Type{Array{Any, _A}}, ::Tuple{Union{Integer, Base.OneTo}}) where _A (2 children)
                 5: signature Tuple{typeof(similar), Type{Array{String, _A}} where _A, Tuple{Union{Integer, AbstractUnitRange}}} triggered MethodInstance for similar(::Type{Array{String, _A}}, ::Tuple{Union{Integer, Base.OneTo}}) where _A (2 children)
                 6: signature Tuple{typeof(similar), Type{Array{Expr, _A}} where _A, Tuple{Union{Integer, AbstractUnitRange}}} triggered MethodInstance for similar(::Type{Array{Expr, _A}}, ::Tuple{Union{Integer, Base.OneTo}}) where _A (2 children)

 inserting similar(A::Vector{T} where T, ::Type{CategoricalArrays.CategoricalValue{T, R}}, dims::Tuple{Vararg{Int64, N}}) where {T, R, N} in CategoricalArrays at /Users/arthurb/.julia/packages/CategoricalArrays/YxMoo/src/array.jl:668 invalidated:
   mt_backedges: 1: signature Tuple{typeof(similar), Vector{T} where T, DataType, Tuple{Union{Integer, AbstractUnitRange}}} triggered MethodInstance for similar(::Vector{T} where T, ::DataType, ::Union{Integer, AbstractUnitRange}) (0 children)
                 2: signature Tuple{typeof(similar), Vector{T} where T, DataType, Tuple{Union{Integer, AbstractUnitRange}}} triggered MethodInstance for similar(::Vector{T} where T, ::DataType, ::Tuple{Union{Integer, Base.OneTo}}) (2 children)
   backedges: 1: superseding similar(a::Array, T::Type, dims::Tuple{Vararg{Int64, N}}) where N in Base at array.jl:358 with MethodInstance for similar(::Vector{Pair{DataType, Function}}, ::DataType, ::Tuple{Int64}) (1 children)
              2: superseding similar(a::Array, T::Type, dims::Tuple{Vararg{Int64, N}}) where N in Base at array.jl:358 with MethodInstance for similar(::Vector{Any}, ::DataType, ::Tuple{Int64}) (1 children)
              3: superseding similar(a::Array, T::Type, dims::Tuple{Vararg{Int64, N}}) where N in Base at array.jl:358 with MethodInstance for similar(::Vector{T} where T, ::DataType, ::Tuple{Int64}) (4 children)

 inserting isassigned(a::StaticArrays.StaticArray, i::Int64...) in StaticArrays at /Users/arthurb/.julia/packages/StaticArrays/NTbHj/src/abstractarray.jl:30 invalidated:
   backedges: 1: superseding isassigned(a::AbstractArray, i::Integer...) in Base at abstractarray.jl:505 with MethodInstance for isassigned(::AbstractVecOrMat{T} where T, ::Int64, ::Int64) (8 children)

 inserting axes(A::OffsetArrays.OffsetArray, d) in OffsetArrays at /Users/arthurb/.julia/packages/OffsetArrays/PdMCN/src/OffsetArrays.jl:236 invalidated:
   backedges: 1: superseding axes(A::AbstractArray{T, N}, d) where {T, N} in Base at abstractarray.jl:68 with MethodInstance for axes(::AbstractVecOrMat{T} where T, ::Int64) (14 children)
   1 mt_cache

 inserting *(::ChainRulesCore.One, b) in ChainRulesCore at /Users/arthurb/.julia/packages/ChainRulesCore/eBwSt/src/differential_arithmetic.jl:98 invalidated:
   mt_backedges: 1: signature Tuple{typeof(*), Any, String} triggered MethodInstance for promptf() (0 children)
                 2: signature Tuple{typeof(*), Any, String} triggered MethodInstance for var"#precompile#195"(::Bool, ::Bool, ::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(Pkg.API.precompile), ::Pkg.Types.Context) (15 children)
   25 mt_cache

 inserting convert(::Type{S}, x::CategoricalArrays.CategoricalValue) where S<:Union{AbstractChar, AbstractString, Number} in CategoricalArrays at /Users/arthurb/.julia/packages/CategoricalArrays/YxMoo/src/value.jl:73 invalidated:
   mt_backedges:  1: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{DataType, String}(::Any, ::Any) (0 children)
                  2: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#112#165"}(::Any, ::Any) (0 children)
                  3: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#113#166"}(::Any, ::Any) (0 children)
                  4: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#114#167"}(::Any, ::Any) (0 children)
                  5: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#115#168"}(::Any, ::Any) (0 children)
                  6: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#116#169"}(::Any, ::Any) (0 children)
                  7: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#117#170"}(::Any, ::Any) (0 children)
                  8: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#118#171"}(::Any, ::Any) (0 children)
                  9: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#119#172"}(::Any, ::Any) (0 children)
                 10: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#120#173"}(::Any, ::Any) (0 children)
                 11: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#121#174"}(::Any, ::Any) (0 children)
                 12: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#122#175"}(::Any, ::Any) (0 children)
                 13: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#123#176"}(::Any, ::Any) (0 children)
                 14: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#124#177"}(::Any, ::Any) (0 children)
                 15: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#125#178"}(::Any, ::Any) (0 children)
                 16: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#126#179"}(::Any, ::Any) (0 children)
                 17: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#127#180"}(::Any, ::Any) (0 children)
                 18: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#128#181"}(::Any, ::Any) (0 children)
                 19: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#129#182"}(::Any, ::Any) (0 children)
                 20: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#130#183"}(::Any, ::Any) (0 children)
                 21: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#131#184"}(::Any, ::Any) (0 children)
                 22: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#132#185"}(::Any, ::Any) (0 children)
                 23: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#133#186"}(::Any, ::Any) (0 children)
                 24: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#134#187"}(::Any, ::Any) (0 children)
                 25: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#135#188"}(::Any, ::Any) (0 children)
                 26: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#136#189"}(::Any, ::Any) (0 children)
                 27: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#137#190"}(::Any, ::Any) (0 children)
                 28: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#138#191"}(::Any, ::Any) (0 children)
                 29: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#139#192"}(::Any, ::Any) (0 children)
                 30: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#140#193"}(::Any, ::Any) (0 children)
                 31: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#141#194"}(::Any, ::Any) (0 children)
                 32: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#142#195"}(::Any, ::Any) (0 children)
                 33: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#143#196"}(::Any, ::Any) (0 children)
                 34: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#144#197"}(::Any, ::Any) (0 children)
                 35: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#145#198"}(::Any, ::Any) (0 children)
                 36: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#146#199"}(::Any, ::Any) (0 children)
                 37: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#147#200"}(::Any, ::Any) (0 children)
                 38: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#148#201"}(::Any, ::Any) (0 children)
                 39: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#149#202"}(::Any, ::Any) (0 children)
                 40: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#150#203"}(::Any, ::Any) (0 children)
                 41: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#151#204"}(::Any, ::Any) (0 children)
                 42: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#152#205"}(::Any, ::Any) (0 children)
                 43: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#153#206"}(::Any, ::Any) (0 children)
                 44: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#154#207"}(::Any, ::Any) (0 children)
                 45: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#155#208"}(::Any, ::Any) (0 children)
                 46: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#156#209"}(::Any, ::Any) (0 children)
                 47: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#157#210"}(::Any, ::Any) (0 children)
                 48: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#158#211"}(::Any, ::Any) (0 children)
                 49: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#159#212"}(::Any, ::Any) (0 children)
                 50: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#160#213"}(::Any, ::Any) (0 children)
                 51: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#161#214"}(::Any, ::Any) (0 children)
                 52: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#215#225"}(::Any, ::Any) (0 children)
                 53: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#216#226"}(::Any, ::Any) (0 children)
                 54: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#217#227"}(::Any, ::Any) (0 children)
                 55: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#218#228"}(::Any, ::Any) (0 children)
                 56: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#219#229"}(::Any, ::Any) (0 children)
                 57: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#220#230"}(::Any, ::Any) (0 children)
                 58: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#221#231"}(::Any, ::Any) (0 children)
                 59: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#222#232"}(::Any, ::Any) (0 children)
                 60: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#223#233"}(::Any, ::Any) (0 children)
                 61: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#224#234"}(::Any, ::Any) (0 children)
                 62: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#235#243"}(::Any, ::Any) (0 children)
                 63: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#236#244"}(::Any, ::Any) (0 children)
                 64: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#237#245"}(::Any, ::Any) (0 children)
                 65: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#238#246"}(::Any, ::Any) (0 children)
                 66: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, REPL.LineEdit.var"#239#247"}(::Any, ::Any) (0 children)
                 67: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, typeof(Downloads.Curl.status_2xx_ok)}(::Any, ::Any) (0 children)
                 68: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Pair{String, typeof(Downloads.Curl.status_zero_ok)}(::Any, ::Any) (0 children)
                 69: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for setindex!(::Dict{String, Function}, ::Any, ::Any) (0 children)
                 70: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for setindex!(::Vector{String}, ::Any, ::Int64) (0 children)
                 71: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for convert(::Type{Union{Nothing, String}}, ::Any) (0 children)
                 72: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Test.Fail(::Symbol, ::Any, ::Any, ::Bool, ::LineNumberNode) (0 children)
                 73: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for setindex!(::Dict{String, Any}, ::Any, ::Any) (0 children)
                 74: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for push!(::Vector{String}, ::Any) (0 children)
                 75: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for setindex!(::Dict{String, Union{Base.SHA1, String}}, ::Any, ::Any) (0 children)
                 76: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for setindex!(::Dict{String, Vector{String}}, ::Any, ::Any) (0 children)
                 77: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for setindex!(::Dict{String, Base.UUID}, ::Base.UUID, ::Any) (0 children)
                 78: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for setindex!(::Dict{String, String}, ::Any, ::Any) (0 children)
                 79: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for (::Base.var"#cvt1#1"{Tuple{Pkg.Types.PackageSpec, String}, _A} where _A)(::Int64) (0 children)
                 80: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for setindex!(::IdDict{Any, String}, ::Any, ::Any) (1 children)
                 81: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Test.Error(::Symbol, ::Any, ::Any, ::Nothing, ::LineNumberNode) (1 children)
                 82: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Test.Error(::Symbol, ::Any, ::Any, ::Any, ::LineNumberNode) (1 children)
                 83: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for setindex!(::Dict{String, String}, ::Any, ::String) (1 children)
                 84: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for REPL.LineEdit.PrefixSearchState(::Any, ::Any, ::Any, ::Any) (1 children)
                 85: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for REPL.LineEditREPL(::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any) (1 children)
                 86: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for (::Base.var"#cvt1#1"{Tuple{String, String}, _A} where _A)(::Int64) (3 children)
                 87: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for (::Base.var"#cvt1#1"{Tuple{Base.UUID, String, String, VersionNumber}, _A} where _A)(::Int64) (3 children)
                 88: 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)

 inserting convert(::Type{var"#s4"} where var"#s4"<:Dict, comp::ChainRulesCore.Composite{var"#s3", var"#s2"} where {var"#s3"<:Dict, var"#s2"<:Dict}) in ChainRulesCore at /Users/arthurb/.julia/packages/ChainRulesCore/eBwSt/src/differentials/composite.jl:69 invalidated:
   mt_backedges: 1: signature Tuple{typeof(convert), Type{Dict{String, Any}}, Any} triggered MethodInstance for setindex!(::Dict{Base.BinaryPlatforms.AbstractPlatform, Dict{String, Any}}, ::Any, ::Base.BinaryPlatforms.Platform) (0 children)
                 2: signature Tuple{typeof(convert), Type{Dict{Symbol, Any}}, Any} triggered MethodInstance for setindex!(::IdDict{Function, Dict{Symbol, Any}}, ::Any, ::Any) (8 children)
                 3: signature Tuple{typeof(convert), Type{Dict{Char, Any}}, Any} triggered MethodInstance for REPL.LineEdit.Prompt(::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any) (18 children)

 inserting similar(A::Vector{T} where T, ::Type{CategoricalArrays.CategoricalValue{T, R} where R<:Integer}) where T in CategoricalArrays at /Users/arthurb/.julia/packages/CategoricalArrays/YxMoo/src/array.jl:671 invalidated:
   backedges: 1: superseding similar(a::Vector{T}, S::Type) where T in Base at array.jl:355 with MethodInstance for similar(::Vector{_A} where _A, ::Type) (27 children)
   2 mt_cache

 inserting similar(A::Vector{T} where T, ::Type{CategoricalArrays.CategoricalValue{T, R} where R<:Integer}, dims::Tuple{Vararg{Int64, N}}) where {T, N} in CategoricalArrays at /Users/arthurb/.julia/packages/CategoricalArrays/YxMoo/src/array.jl:671 invalidated:
   mt_backedges: 1: signature Tuple{typeof(similar), Vector{T} where T, Type, Tuple{Union{Integer, AbstractUnitRange}}} triggered MethodInstance for similar(::Vector{T} where T, ::Type{T}, ::Union{Integer, AbstractUnitRange}) where T (0 children)
                 2: signature Tuple{typeof(similar), Vector{T} where T, Type, Tuple{Union{Integer, AbstractUnitRange}}} triggered MethodInstance for similar(::Vector{T} where T, ::Type{T}, ::Tuple{Union{Integer, Base.OneTo}}) where T (2 children)
   backedges: 1: superseding similar(a::Array, T::Type, dims::Tuple{Vararg{Int64, N}}) where N in Base at array.jl:358 with MethodInstance for similar(::Vector{Any}, ::Type, ::Tuple{Int64}) (3 children)
              2: superseding similar(a::Array, T::Type, dims::Tuple{Vararg{Int64, N}}) where N in Base at array.jl:358 with MethodInstance for similar(::Vector{Pair{DataType, Function}}, ::Type, ::Tuple{Int64}) (3 children)
              3: superseding similar(a::Array, T::Type, dims::Tuple{Vararg{Int64, N}}) where N in Base at array.jl:358 with MethodInstance for similar(::Vector{Pair{DataType, Function}}, ::Type, ::Tuple{Int64}) (5 children)
              4: superseding similar(a::Array, T::Type, dims::Tuple{Vararg{Int64, N}}) where N in Base at array.jl:358 with MethodInstance for similar(::Vector{Any}, ::Type, ::Tuple{Int64}) (5 children)
              5: superseding similar(a::Array, T::Type, dims::Tuple{Vararg{Int64, N}}) where N in Base at array.jl:358 with MethodInstance for similar(::Vector{T} where T, ::Type, ::Tuple{Int64}) (30 children)
   23 mt_cache

 inserting similar(::Type{T}, dims::Tuple{Vararg{Int64, N}} where N) where {U, T<:(Array{Union{Missing, CategoricalArrays.CategoricalValue{U, R} where R<:Integer}, N} where N)} in CategoricalArrays at /Users/arthurb/.julia/packages/CategoricalArrays/YxMoo/src/array.jl:688 invalidated:
   mt_backedges: 1: signature Tuple{typeof(similar), Type{Array{_A, _B}} where {_A, _B}, Tuple{Union{Integer, AbstractUnitRange}}} triggered MethodInstance for similar(::Type{Array{_A, _B}}, ::Union{Integer, AbstractUnitRange}) where {_A, _B} (0 children)
                 2: signature Tuple{typeof(similar), Type{Array{_A, _B}} where {_A, _B}, Tuple{Union{Integer, AbstractUnitRange}}} triggered MethodInstance for similar(::Type{Array{_A, _B}}, ::Tuple{Union{Integer, Base.OneTo}}) where {_A, _B} (2 children)
   backedges: 1: superseding similar(::Type{T}, dims::Tuple{Vararg{Int64, N}} where N) where T<:AbstractArray in Base at abstractarray.jl:779 with MethodInstance for similar(::Type{Array{_A, _B}}, ::Tuple{Int64}) where {_A, _B} (2 children)
              2: superseding similar(::Type{T}, dims::Tuple{Vararg{Int64, N}} where N) where T<:AbstractArray in Base at abstractarray.jl:779 with MethodInstance for similar(::Type{Array{_A, N} where N} where _A, ::Tuple{Int64}) (34 children)
              3: superseding similar(::Type{T}, dims::Tuple{Vararg{Int64, N}} where N) where T<:AbstractArray in Base at abstractarray.jl:779 with MethodInstance for similar(::Type{Vector{_A}} where _A, ::Tuple{Int64}) (104 children)

fresh session:

julia> include("/tmp/snoopr.jl")
insert_backedges for MethodInstance for (::Rmath_jll.var"#1#2")(::Any)
inserting convert(::Type{var"#s4"} where var"#s4"<:Tuple, comp::ChainRulesCore.Composite{var"#s3", var"#s2"} where {var"#s3", var"#s2"<:Tuple}) in ChainRulesCore at /Users/arthurb/.julia/packages/ChainRulesCore/eBwSt/src/differentials/composite.jl:68 invalidated:
   mt_backedges: 1: signature Tuple{typeof(convert), Type{Tuple{DataType, DataType, DataType}}, Any} triggered MethodInstance for Pair{DataType, Tuple{DataType, DataType, DataType}}(::Any, ::Any) (0 children)
                 2: signature Tuple{typeof(convert), Type{NTuple{8, DataType}}, Any} triggered MethodInstance for Pair{DataType, NTuple{8, DataType}}(::Any, ::Any) (0 children)
                 3: signature Tuple{typeof(convert), Type{NTuple{7, DataType}}, Any} triggered MethodInstance for Pair{DataType, NTuple{7, DataType}}(::Any, ::Any) (0 children)
                 4: signature Tuple{typeof(convert), Type{Tuple{Symbol, Any, Symbol, Symbol}}, Any} triggered MethodInstance for setindex!(::Vector{Tuple{Symbol, Any, Symbol, Symbol}}, ::Any, ::Int64) (0 children)
                 5: signature Tuple{typeof(convert), Type{Tuple{Base.UUID, String}}, Any} triggered MethodInstance for setindex!(::Vector{Tuple{Base.UUID, String}}, ::Any, ::Int64) (0 children)
                 6: signature Tuple{typeof(convert), Type{Tuple{Any, String}}, Any} triggered MethodInstance for setindex!(::Vector{Tuple{Any, String}}, ::Any, ::Int64) (0 children)


julia> root = method_invalidations.backedges[end]
ERROR: BoundsError: attempt to access 0-element Vector{SnoopCompile.InstanceNode} at index [0]
Stacktrace:
 [1] getindex(A::Vector{SnoopCompile.InstanceNode}, i1::Int64)
   @ Base ./array.jl:801
 [2] top-level scope
   @ REPL[3]:1

julia> root = method_invalidations.mt_backedges[end]
Pair{Any, SnoopCompile.InstanceNode}(Tuple{typeof(convert), Type{Tuple{Any, String}}, Any}, MethodInstance for setindex!(::Vector{Tuple{Any, String}}, ::Any, ::Int64) at depth 0 with 0 children)

julia> ascend(root)
ERROR: MethodError: no method matching method(::Pair{Any, SnoopCompile.InstanceNode})
Closest candidates are:
  method(::Core.MethodInstance) at /Users/arthurb/.julia/packages/Cthulhu/wsvdB/src/backedges.jl:84
  method(::Vector{Base.StackTraces.StackFrame}) at /Users/arthurb/.julia/packages/Cthulhu/wsvdB/src/backedges.jl:90
  method(::SnoopCompile.InstanceNode) at /Users/arthurb/.julia/packages/SnoopCompile/Y7SPE/src/invalidations.jl:507
  ...
Stacktrace:
 [1] callstring(io::IOBuffer, mi::Pair{Any, SnoopCompile.InstanceNode})
   @ Cthulhu ~/.julia/packages/Cthulhu/wsvdB/src/backedges.jl:96
 [2] treelist(mi::Pair{Any, SnoopCompile.InstanceNode})
   @ Cthulhu ~/.julia/packages/Cthulhu/wsvdB/src/backedges.jl:117
 [3] ascend(mi::Pair{Any, SnoopCompile.InstanceNode}; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ Cthulhu ~/.julia/packages/Cthulhu/wsvdB/src/Cthulhu.jl:285
 [4] ascend(mi::Pair{Any, SnoopCompile.InstanceNode})
   @ Cthulhu ~/.julia/packages/Cthulhu/wsvdB/src/Cthulhu.jl:285
 [5] top-level scope
   @ REPL[5]:1

@bjarthur
Copy link
Member

bjarthur commented Feb 7, 2021

@timholy when you commented that Gadlfy's method invalidations used to be 1850 and Makie is 200, you meant the unique ones as reported with length(uinvalidated(invalidations)), right? length(invalidations) for Gadfly is currently ~1600.

@timholy
Copy link
Collaborator

timholy commented Feb 7, 2021

you meant the unique ones as reported with length(uinvalidated(invalidations)), right?

exactly

not sure how to look into "mt_backedges" (as indicated with "signature"), as ascend doesn't seem to work on them.

https://timholy.github.io/SnoopCompile.jl/stable/snoopr/#mt_backedges-invalidations

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

Successfully merging this pull request may close these issues.

5 participants