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

don't specialize convert #25

Merged
merged 3 commits into from
Oct 11, 2022
Merged

don't specialize convert #25

merged 3 commits into from
Oct 11, 2022

Conversation

jishnub
Copy link
Member

@jishnub jishnub commented Oct 11, 2022

This reduces invalidation without changing functionality. On master, and using julia nightly,

julia> VERSION
v"1.9.0-DEV.1570"

julia> using SnoopCompileCore

julia> invalidations = @snoopr using Infinities;

julia> using SnoopCompile

julia> trees = invalidation_trees(invalidations)
6-element Vector{SnoopCompile.MethodInvalidations}:
 inserting one(::Type{<:InfiniteCardinal}) @ Infinities ~/Dropbox/JuliaPackages/Infinities.jl/src/cardinality.jl:31 invalidated:
   backedges: 1: superseding one(::Type{T}) where T<:Number @ Base number.jl:346 with MethodInstance for one(::Type{T} where T<:Integer) (1 children)

 inserting zero(::InfiniteCardinal) @ Infinities ~/Dropbox/JuliaPackages/Infinities.jl/src/cardinality.jl:30 invalidated:
   backedges: 1: superseding zero(x::Number) @ Base number.jl:308 with MethodInstance for zero(::Integer) (2 children)

 inserting getindex(A::Array, i1::InfiniteCardinal{0}, I::Integer...) @ Infinities ~/Dropbox/JuliaPackages/Infinities.jl/src/cardinality.jl:199 invalidated:
   backedges: 1: superseding getindex(A::Array, i1::Integer, I::Integer...) @ Base abstractarray.jl:1289 with MethodInstance for getindex(::Vector{Revise.FileInfo}, ::Integer) (5 children)

 inserting to_index(::Union{InfiniteCardinal{0}, Infinities.Infinity}) @ Infinities ~/Dropbox/JuliaPackages/Infinities.jl/src/cardinality.jl:172 invalidated:
   backedges: 1: superseding to_index(i::Integer) @ Base indices.jl:292 with MethodInstance for Base.to_index(::Integer) (5 children)

 inserting convert(::Type{Float32}, x::RealInfinity) @ Infinities ~/Dropbox/JuliaPackages/Infinities.jl/src/Infinities.jl:137 invalidated:
   backedges: 1: superseding convert(::Type{T}, x::Number) where T<:Number @ Base number.jl:7 with MethodInstance for convert(::Type{<:Real}, ::Real) (11 children)

 inserting to_shape(::Union{InfiniteCardinal{0}, Infinities.Infinity}) @ Infinities ~/Dropbox/JuliaPackages/Infinities.jl/src/cardinality.jl:173 invalidated:
   backedges: 1: superseding to_shape(i::Integer) @ Base abstractarray.jl:846 with MethodInstance for Base.to_shape(::Integer) (25 children)

This PR

julia> trees = invalidation_trees(invalidations)
4-element Vector{SnoopCompile.MethodInvalidations}:
 inserting one(::Type{<:InfiniteCardinal}) @ Infinities ~/Dropbox/JuliaPackages/Infinities.jl/src/cardinality.jl:31 invalidated:
   backedges: 1: superseding one(::Type{T}) where T<:Number @ Base number.jl:346 with MethodInstance for one(::Type{T} where T<:Integer) (1 children)

 inserting zero(::InfiniteCardinal) @ Infinities ~/Dropbox/JuliaPackages/Infinities.jl/src/cardinality.jl:30 invalidated:
   backedges: 1: superseding zero(x::Number) @ Base number.jl:308 with MethodInstance for zero(::Integer) (2 children)

 inserting to_index(::Union{InfiniteCardinal{0}, Infinities.Infinity}) @ Infinities ~/Dropbox/JuliaPackages/Infinities.jl/src/cardinality.jl:172 invalidated:
   backedges: 1: superseding to_index(i::Integer) @ Base indices.jl:292 with MethodInstance for Base.to_index(::Integer) (10 children)

 inserting to_shape(::Union{InfiniteCardinal{0}, Infinities.Infinity}) @ Infinities ~/Dropbox/JuliaPackages/Infinities.jl/src/cardinality.jl:173 invalidated:
   backedges: 1: superseding to_shape(i::Integer) @ Base abstractarray.jl:846 with MethodInstance for Base.to_shape(::Integer) (25 children)
   41 mt_cache

This PR removes the invalidation due to convert, and I'm not certain how the getindex one is resolved as well. In any case, specializing convert seems unnecessary, as convert calls constructors that are specialized anyway.

@codecov
Copy link

codecov bot commented Oct 11, 2022

Codecov Report

Base: 99.43% // Head: 99.13% // Decreases project coverage by -0.29% ⚠️

Coverage data is based on head (cb34397) compared to base (f197633).
Patch coverage: 90.90% of modified lines in pull request are covered.

❗ Current head cb34397 differs from pull request most recent head 0a626d8. Consider uploading reports for the commit 0a626d8 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #25      +/-   ##
==========================================
- Coverage   99.43%   99.13%   -0.30%     
==========================================
  Files           2        2              
  Lines         353      347       -6     
==========================================
- Hits          351      344       -7     
- Misses          2        3       +1     
Impacted Files Coverage Δ
src/Infinities.jl 99.54% <90.90%> (-0.46%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@dlfivefifty dlfivefifty merged commit a0766bd into JuliaMath:master Oct 11, 2022
@jishnub jishnub deleted the convert branch October 11, 2022 15:48
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.

2 participants