-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
JuliaSyntax:force specialize on function in parse_brackets
#60403
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
Conversation
|
Did you check that this fixes the invalidations? When I built Julia from that JuliaSyntax branch it didn't actually work: JuliaLang/JuliaSyntax.jl#601 (comment) I ended up type-asserting everything, which did fix it: JuliaLang/JuliaSyntax.jl#601 (comment) |
|
I tested and it worked for me at least. |
|
Ok, maybe I screwed up the JuliaSyntax commit or something when building. Glad that this simpler fix works :) |
|
You could confirm if you want to ( |
|
Yep, they don't show up anymore 🎉 julia> using SnoopCompileCore
julia> invs, trees = begin
invs = @snoop_invalidations import InitialValues
using SnoopCompile, AbstractTrees
trees = invalidation_trees(invs)
invs, trees
end;
julia> trees
8-element Vector{SnoopCompile.MethodInvalidations}:
inserting +(x, ::Union{InitialValues.NonspecificInitialValue, InitialValues.SpecificInitialValue{typeof(+)}}) @ InitialValues ~/.julia/packages/InitialValues/OWP8V/src/InitialValues.jl:161 invalidated:
mt_backedges: 1: signature Tuple{typeof(+), Ptr{UInt16}, Any} triggered MethodInstance for Base._copyfrompacked!(::Ptr, ::Ptr{UInt16}) (0 children)
2: signature Tuple{typeof(+), Ptr{Tuple{UInt8, UInt8}}, Any} triggered MethodInstance for Base._copyfrompacked!(::Ptr, ::Ptr{Tuple{UInt8, UInt8}}) (0 children)
3: signature Tuple{typeof(+), Ptr{Int32}, Any} triggered MethodInstance for Base._copytopacked!(::Ptr{Int32}, ::Ptr) (0 children)
4: signature Tuple{typeof(+), Ptr{Int32}, Any} triggered MethodInstance for Base._copytopacked!(::Ptr{Int32}, ::Ptr{T} where T<:Function) (0 children)
5: signature Tuple{typeof(+), Ptr{T} where T<:(NTuple{_A, UInt8} where _A), Any} triggered MethodInstance for Base._copytopacked!(::Ptr{T} where T<:(NTuple{_A, UInt8} where _A), ::Ptr) (0 children)
6: signature Tuple{typeof(+), Ptr{T} where T<:(NTuple{_A, UInt8} where _A), Any} triggered MethodInstance for Base._copytopacked!(::Ptr{T} where T<:(NTuple{_A, UInt8} where _A), ::Ptr{T} where T<:Function) (0 children)
inserting |(::Union{InitialValues.NonspecificInitialValue, InitialValues.SpecificInitialValue{typeof(|)}}, x) @ InitialValues ~/.julia/packages/InitialValues/OWP8V/src/InitialValues.jl:154 invalidated:
mt_backedges: 1: signature Tuple{typeof(|), Any, Bool} triggered MethodInstance for Base._base(::Int64, ::Integer, ::Int64, ::Bool) (0 children)
inserting &(::Union{InitialValues.NonspecificInitialValue, InitialValues.SpecificInitialValue{typeof(&)}}, x) @ InitialValues ~/.julia/packages/InitialValues/OWP8V/src/InitialValues.jl:154 invalidated:
mt_backedges: 1: signature Tuple{typeof(&), Any, Bool} triggered MethodInstance for ==(::AbstractUnitRange, ::UnitRange{Int64}) (7 children)
inserting add_sum(x, ::Union{InitialValues.NonspecificInitialValue, InitialValues.SpecificInitialValue{typeof(Base.add_sum)}}) @ InitialValues ~/.julia/packages/InitialValues/OWP8V/src/InitialValues.jl:161 invalidated:
backedges: 1: superseding add_sum(x, y) @ Base reduce.jl:16 with MethodInstance for Base.add_sum(::Int64, ::Any) (39 children)
inserting &(x, ::Union{InitialValues.NonspecificInitialValue, InitialValues.SpecificInitialValue{typeof(&)}}) @ InitialValues ~/.julia/packages/InitialValues/OWP8V/src/InitialValues.jl:161 invalidated:
mt_backedges: 1: signature Tuple{typeof(&), Bool, Any} triggered MethodInstance for Base.var"#string#391"(::Int64, ::Int64, ::typeof(string), ::Unsigned) (0 children)
2: signature Tuple{typeof(&), Bool, Any} triggered MethodInstance for div(::Unsigned, ::Int64, ::RoundingMode{:Up}) (1 children)
3: signature Tuple{typeof(&), Bool, Any} triggered MethodInstance for isempty(::StepRange{Tuple{LineNumberNode, Expr}}) (2 children)
4: signature Tuple{typeof(&), Bool, Any} triggered MethodInstance for LinearAlgebra._chkstride1(::Bool, ::Any, ::Vararg{Any}) (8 children)
5: signature Tuple{typeof(&), Bool, Any} triggered MethodInstance for div(::Unsigned, ::Int64, ::RoundingMode{:Down}) (48 children)
inserting *(::Union{InitialValues.NonspecificInitialValue, InitialValues.SpecificInitialValue{typeof(*)}}, x) @ InitialValues ~/.julia/packages/InitialValues/OWP8V/src/InitialValues.jl:154 invalidated:
mt_backedges: 1: signature Tuple{typeof(*), Any, Compiler.MethodMatchInfo} triggered MethodInstance for Base.lerpi(::Integer, ::Integer, ::Compiler.MethodMatchInfo, ::Compiler.MethodMatchInfo) (0 children)
2: signature Tuple{typeof(*), Any, Compiler.CallMeta} triggered MethodInstance for Base.lerpi(::Integer, ::Integer, ::Compiler.CallMeta, ::Compiler.CallMeta) (0 children)
3: signature Tuple{typeof(*), Any, Compiler.ApplyCallInfo} triggered MethodInstance for Base.lerpi(::Integer, ::Integer, ::Compiler.ApplyCallInfo, ::Compiler.ApplyCallInfo) (0 children)
4: signature Tuple{typeof(*), Any, Nothing} triggered MethodInstance for Base.lerpi(::Integer, ::Integer, ::Nothing, ::Nothing) (0 children)
5: signature Tuple{typeof(*), Any, Compiler.AbstractIterationInfo} triggered MethodInstance for Base.lerpi(::Integer, ::Integer, ::Compiler.AbstractIterationInfo, ::Compiler.AbstractIterationInfo) (0 children)
6: signature Tuple{typeof(*), Any, Compiler.NewPhiCNode2} triggered MethodInstance for Base.lerpi(::Integer, ::Integer, ::Compiler.NewPhiCNode2, ::Compiler.NewPhiCNode2) (0 children)
7: signature Tuple{typeof(*), Any, Compiler.AbstractIterationInfo} triggered MethodInstance for Base.lerpi(::Integer, ::Integer, ::Compiler.AbstractIterationInfo, ::Compiler.AbstractIterationInfo) (1 children)
8: signature Tuple{typeof(*), Any, Compiler.MethodMatchInfo} triggered MethodInstance for Base.lerpi(::Integer, ::Integer, ::Compiler.MethodMatchInfo, ::Compiler.MethodMatchInfo) (10 children)
9: signature Tuple{typeof(*), Any, Compiler.CallMeta} triggered MethodInstance for Base.lerpi(::Integer, ::Integer, ::Compiler.CallMeta, ::Compiler.CallMeta) (10 children)
10: signature Tuple{typeof(*), Any, Compiler.ApplyCallInfo} triggered MethodInstance for Base.lerpi(::Integer, ::Integer, ::Compiler.ApplyCallInfo, ::Compiler.ApplyCallInfo) (10 children)
11: signature Tuple{typeof(*), Any, Nothing} triggered MethodInstance for Base.lerpi(::Integer, ::Integer, ::Nothing, ::Nothing) (10 children)
12: signature Tuple{typeof(*), Any, Module} triggered MethodInstance for Base.lerpi(::Integer, ::Integer, ::Module, ::Module) (10 children)
13: signature Tuple{typeof(*), Any, Compiler.NewPhiCNode2} triggered MethodInstance for Base.lerpi(::Integer, ::Integer, ::Compiler.NewPhiCNode2, ::Compiler.NewPhiCNode2) (10 children)
14: signature Tuple{typeof(*), Any, Tuple{LineNumberNode, Expr}} triggered MethodInstance for Base.lerpi(::Integer, ::Integer, ::Tuple{LineNumberNode, Expr}, ::Tuple{LineNumberNode, Expr}) (11 children)
inserting convert(::Type{T}, ::Union{InitialValues.SpecificInitialValue{typeof(*)}, InitialValues.SpecificInitialValue{typeof(Base.mul_prod)}}) where T<:Union{AbstractString, Number} @ InitialValues ~/.julia/packages/InitialValues/OWP8V/src/InitialValues.jl:258 invalidated:
mt_backedges: 1: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Base.Terminals.TTYTerminal(::Any, ::Any, ::Any, ::Any) (0 children)
2: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Base.CoreLogging.var"#handle_message#6"(::Base.Pairs{Symbol, Union{}, Nothing, @NamedTuple{}}, ::typeof(Base.CoreLogging.handle_message), ::Base.CoreLogging.ConsoleLogger, ::Base.CoreLogging.LogLevel, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any) (1 children)
3: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Base.CoreLogging.var"#handle_message#3"(::Base.Pairs{Symbol, Union{}, Nothing, @NamedTuple{}}, ::typeof(Base.CoreLogging.handle_message), ::Base.CoreLogging.SimpleLogger, ::Base.CoreLogging.LogLevel, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any) (1 children)
4: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for setindex!(::Vector{String}, ::Any, ::Int64) (2 children)
5: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Base.CoreLogging.var"#handle_message#6"(::Base.Pairs{Symbol, _A, Nothing, A} where {_A, A<:NamedTuple}, ::typeof(Base.CoreLogging.handle_message), ::Base.CoreLogging.ConsoleLogger, ::Base.CoreLogging.LogLevel, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any) (7 children)
6: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Base.CoreLogging.var"#handle_message#3"(::Base.Pairs{Symbol, _A, Nothing, A} where {_A, A<:NamedTuple}, ::typeof(Base.CoreLogging.handle_message), ::Base.CoreLogging.SimpleLogger, ::Base.CoreLogging.LogLevel, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any) (7 children)
7: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for setindex!(::Memory{String}, ::Any, ::Int64) (14 children)
8: signature Tuple{typeof(convert), Type{SubString{String}}, Any} triggered MethodInstance for setindex!(::Memory{SubString{String}}, ::Any, ::Int64) (14 children)
9: signature Tuple{typeof(convert), Type{SubString{Base.AnnotatedString{String}}}, Any} triggered MethodInstance for setindex!(::Memory{SubString{Base.AnnotatedString{String}}}, ::Any, ::Int64) (15 children)
10: signature Tuple{typeof(convert), Type{Union{Bool, Int64, String}}, Any} triggered MethodInstance for convert(::Type{Union{Nothing, Bool, Int64, String}}, ::Any) (113 children)
inserting |(x, ::Union{InitialValues.NonspecificInitialValue, InitialValues.SpecificInitialValue{typeof(|)}}) @ InitialValues ~/.julia/packages/InitialValues/OWP8V/src/InitialValues.jl:161 invalidated:
mt_backedges: 1: signature Tuple{typeof(|), Bool, Any} triggered MethodInstance for <=(::Any, ::VersionNumber) (0 children)
2: signature Tuple{typeof(|), Missing, Any} triggered MethodInstance for <=(::Any, ::VersionNumber) (307 children) |
This prevents invalidations. Backport of JuliaLang/julia#60403
This prevents invalidations. Backport of JuliaLang/julia#60403
Brings over JuliaLang/JuliaSyntax.jl#601 here now that the repo has moved. But we need this on 1.13 (and 1.12) as well.
Without this the REPL becomes very laggy after loading GLMakie:
Even though the function is directly called in the function body, I think the fact that there is a default argument prevents specialization from happening. To elaborate:
is rewritten internally as:
now, the second generated method does not call
fdirectly so it will heuristically be despecialized.