-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Add tests for method invalidation fixes #47093
base: master
Are you sure you want to change the base?
Conversation
On 1.8 this seems to cause zero invalidations. Any idea what made it start? |
Well spotted. No, I have no idea. |
Thanks. It was this change which caused the invalidations: - convert(::Type{T}, s::AbstractString) where {T<:AbstractString} = T(s)
+ convert(::Type{T}, s::AbstractString) where {T<:AbstractString} = T(s)::T I've reverted that change in 98f8c23 and, with that, fixed all method invalidations for the insertion of the julia> using SnoopCompileCore
julia> invs = @snoopr(using StaticArrays);
julia> using SnoopCompile
julia> length(uinvalidated(invs))
84 |
Do you understand why the change in #46573 caused these new invalidations? I don't understand how type-asserting there could negatively impact invalidations here - but would really like to understand that (e.g., do the other type-assertions in that PR have a similar risk?). |
I also do not understand how the change causes the invalidations. The only difference visible in
It does look like it yes. This is what happens inside julia> using SnoopCompileCore
julia> import Base
julia> struct A{K,V} <: AbstractDict{K,V} end
julia> invs = @snoopr(Base.convert(::Type{A}, ::AbstractDict) = A());
julia> using SnoopCompile
julia> length(uinvalidated(invs))
12 and the number went to zero after the following change: function convert(::Type{T}, x::AbstractDict) where T<:AbstractDict
- h = T(x)::T
+ h = T(x)
if length(h) != length(x)
error("key collision during dictionary conversion")
end
return h
end But, based on some large packages that I've checked for invalidations the invalidations caused by #46573 aren't too bad. Only a few dozen. It's probably best to consider those fixes out of scope for this PR? |
Test failures are in |
Agreed: but confounding that my changes in #46573 - intended to decrease invalidations - seems to have caused them elsewhere. |
It's a bit weird now, we introduce |
I definitely agree with this. Would it make sense to discuss this aspect somewhere else and merge this PR soon to get the new testing infrastructure into |
convert(::Type{String}, ::X)
I've changed the title of the PR to more clearly indicate that the main focus is the testing logic. The invalidation fix is more of a test case. |
This PR adds tests for method invalidation fixes (fixes #47022).
As an example, it adds a test which verifies that we avoid 1154 method invalidations for downstream packages which insert
Base.convert(::Type{String}, ::X)
or similar and adds tests. Packages which benefit from these changes includeCategoricalArrays.jl
andProgressLogging.jl
. The PR which introduced this regression is listed below.