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

Many invalidations #122

Open
sumiya11 opened this issue Feb 14, 2024 · 0 comments
Open

Many invalidations #122

sumiya11 opened this issue Feb 14, 2024 · 0 comments

Comments

@sumiya11
Copy link
Owner

Currently on 1.10, I have

@time begin
           using AbstractAlgebra
           R, (x,y) = polynomial_ring(QQ, ["x","y"], ordering=:degrevlex)
           using Groebner
           groebner([x^2 - y^2, x*y^2 + x])
       end
 10.243601 seconds (4.98 M allocations: 336.788 MiB, 3.64% gc time, 73.70% compilation time)

Running this

# from https://sciml.ai/news/2022/09/21/compile_time/
using SnoopCompile

invalidations = @snoopr begin
    using AbstractAlgebra
    R, (x,y) = polynomial_ring(QQ, ["x","y"], ordering=:degrevlex)
    using Groebner
    groebner([x^2 - y^2, x*y^2 + x])
end

trees = SnoopCompile.invalidation_trees(invalidations);

@show length(SnoopCompile.uinvalidated(invalidations)) # show total invalidations

show(trees[end]) # show the most invalidated method

# Count number of children (number of invalidations per invalidated method)
n_invalidations = map(trees) do methinvs
    SnoopCompile.countchildren(methinvs)
end

Gives me

julia> n_invalidations[end]
625

julia> n_invalidations[end-1]
452

julia> n_invalidations[end-2]
333

julia> n_invalidations[end-3]
71

julia> trees[end]
inserting lock(io::AbstractAlgebra.PrettyPrinting.IOCustom) @ AbstractAlgebra.PrettyPrinting C:\Users\User\.julia\packages\AbstractAlgebra\TPsmz\src\PrettyPrinting.jl:1537 invalidated:
   backedges: 1: superseding lock(::IO) @ Base io.jl:26 with MethodInstance for lock(::IO) (621 children)
              2: superseding lock(::IO) @ Base io.jl:26 with MethodInstance for lock(::IO) (4 children)


julia> trees[end-1]
inserting ==(p::MultivariatePolynomials.AbstractPolynomialLike, α) @ MultivariatePolynomials C:\Users\User\.julia\packages\MultivariatePolynomials\TpRhf\src\operators.jl:65 invalidated:
   backedges: 1: superseding ==(x, y) @ Base Base.jl:165 with MethodInstance for ==(::Any, ::Cthulhu.DInfo.DebugInfo) (6 children)
              2: superseding ==(x, y) @ Base Base.jl:165 with MethodInstance for ==(::Any, ::Core.MethodInstance) (8 children)
              3: superseding ==(x, y) @ Base Base.jl:165 with MethodInstance for ==(::Any, ::Symbol) (420 children)
              4: superseding ==(x, y) @ Base Base.jl:165 with MethodInstance for ==(::Any, ::typeof(display)) (2 children)
              5: superseding ==(x, y) @ Base Base.jl:165 with MethodInstance for ==(::Any, ::Symbol) (1 children)
              6: superseding ==(x, y) @ Base Base.jl:165 with MethodInstance for ==(::Any, ::Symbol) (1 children)
              7: superseding ==(x, y) @ Base Base.jl:165 with MethodInstance for ==(::Any, ::typeof(display)) (1 children)
              8: superseding ==(x, y) @ Base Base.jl:165 with MethodInstance for ==(::Any, ::typeof(display)) (11 children)
              9: superseding ==(x, y) @ Base Base.jl:165 with MethodInstance for ==(::Any, ::Symbol) (2 children)


julia> trees[end-2]
inserting ==(α, q::MultivariatePolynomials.RationalPoly) @ MultivariatePolynomials C:\Users\User\.julia\packages\MultivariatePolynomials\TpRhf\src\comparison.jl:118 invalidated:
   backedges: 1: superseding ==(x, y) @ Base Base.jl:165 with MethodInstance for ==(::Core.MethodInstance, ::Any) (6 children)
              2: superseding ==(x, y) @ Base Base.jl:165 with MethodInstance for ==(::Module, ::Any) (11 children)
              3: superseding ==(x, y) @ Base Base.jl:165 with MethodInstance for ==(::Method, ::Any) (33 children)
              4: superseding ==(x, y) @ Base Base.jl:165 with MethodInstance for ==(::Core.TypeName, ::Any) (124 children)
              5: superseding ==(x, y) @ Base Base.jl:165 with MethodInstance for ==(::Symbol, ::Any) (154 children)
              6: superseding ==(x, y) @ Base Base.jl:165 with MethodInstance for ==(::Symbol, ::Any) (1 children)
              7: superseding ==(x, y) @ Base Base.jl:165 with MethodInstance for ==(::Symbol, ::Any) (4 children)


julia> trees[end-3]
inserting keys(ba::DataStructures.SortedDict) @ DataStructures C:\Users\User\.julia\packages\DataStructures\t9DKl\src\container_loops.jl:233 invalidated:
   backedges: 1: superseding keys(a::AbstractDict) @ Base abstractdict.jl:105 with MethodInstance for keys(::AbstractDict) (25 children)
              2: superseding keys(a::AbstractDict) @ Base abstractdict.jl:105 with MethodInstance for keys(::AbstractDict) (14 children)
              3: superseding keys(a::AbstractDict) @ Base abstractdict.jl:105 with MethodInstance for keys(::AbstractDict) (32 children)

Would be nice to fix the three most heavy sources of invalidation.

⌅ [c3fe647b] AbstractAlgebra v0.36.6
   [0b43b601] Groebner v0.7.0 `..\..\..\..\..\data\projects\gbgb\Groebner.jl`
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