Skip to content

Commit

Permalink
Remove single argument Pair constructor which invalidates
Browse files Browse the repository at this point in the history
All of the Base Pair constructors are 2 arguments, so the single argument one seems to cause invalidation which then infect the precompilation of all downstream packages. 

Before:

```julia
using SnoopCompile
using DiffEqBase, RecursiveFactorization
invalidations = @Snoopr using OrdinaryDiffEq
length(invalidations) # 61
trees = invalidation_trees(invalidations)

1-element Vector{SnoopCompile.MethodInvalidations}:
 inserting Pair(e::LightGraphs.SimpleGraphs.AbstractSimpleEdge) in LightGraphs.SimpleGraphs at C:\Users\accou\.julia\packages\LightGraphs\IgJif\src\SimpleGraphs\simpleedge.jl:26 invalidated:
   mt_backedges: 1: signature Tuple{Type{Pair}, Vararg{Any}} triggered MethodInstance for (::Base.var"sbromberger#6#7"{Pair})(::Any) (23 children)
   1 mt_cache
```

After:

```julia
length(invalidations) # 14
trees = invalidation_trees(invalidations) # zero
```

This only caused a 0.5 second compile time drop to OrdinaryDiffEq.jl, but it is nice and this should be fairly pervasive since `Pair` is used... well... everywhere. Also, I checked and this `Pair` constructor isn't even documented in the public API and does not seem to be used in the private API (the error messages even avoid using it), so it seems like just removing it is the best idea.
  • Loading branch information
ChrisRackauckas committed Aug 11, 2021
1 parent ca41a2e commit 5cdaf52
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/SimpleGraphs/simpleedge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dst(e::AbstractSimpleEdge) = e.dst
show(io::IO, e::AbstractSimpleEdge) = print(io, "Edge $(e.src) => $(e.dst)")

# Conversions
Pair(e::AbstractSimpleEdge) = Pair(src(e), dst(e))
#Pair(e::AbstractSimpleEdge) = Pair(src(e), dst(e))
Tuple(e::AbstractSimpleEdge) = (src(e), dst(e))

SimpleEdge{T}(e::AbstractSimpleEdge) where T <: Integer = SimpleEdge{T}(T(e.src), T(e.dst))
Expand Down
2 changes: 1 addition & 1 deletion src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ julia> dst(first(edges(g)))
"""
dst(e::AbstractEdge) = _NI("dst")

Pair(e::AbstractEdge) = _NI("Pair")
#Pair(e::AbstractEdge) = _NI("Pair")
Tuple(e::AbstractEdge) = _NI("Tuple")

"""
Expand Down

0 comments on commit 5cdaf52

Please sign in to comment.