-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
fix apply_type_tfunc accuracy
#47136
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please tweak indentations so that they are aligned with the other parts.
|
@nanosoldier |
Done (and rebased on |
|
Your benchmark job has completed - no performance regressions were detected. A full report can be found here. |
julia> code_warntype(keys, (Dict{String},))
MethodInstance for keys(::Dict{String})
from keys(a::AbstractDict) @ Base abstractdict.jl:105
Arguments
#self#::Core.Const(keys)
a::Dict{String}
Body::Base.KeySet{String, T} where T<:(Dict{String})
1 ─ %1 = Base.KeySet(a)::Base.KeySet{String, T} where T<:(Dict{String})
└── return %1That's definitely better than julia> code_warntype(keys, (Dict{String},))
MethodInstance for keys(::Dict{String})
from keys(a::AbstractDict) in Base at abstractdict.jl:105
Arguments
#self#::Core.Const(keys)
a::Dict{String}
Body::Base.KeySet{String, _A} where _A<:(AbstractDict{String})
1 ─ %1 = Base.KeySet(a)::Base.KeySet{String, _A} where _A<:(AbstractDict{String})
└── return %1in Julia v1.8.2 🥳 |
|
Well, how does this change prevent the invalidation? |
|
This PR: julia> import Pkg; Pkg.activate(temp=true); Pkg.add("DataStructures")
julia> using SnoopCompileCore; invalidations = @snoopr(using DataStructures); using SnoopCompile
julia> length(uinvalidated(invalidations))
174
julia> trees = invalidation_trees(invalidations)
...
inserting iterate(v::Union{Base.KeySet{<:Any, <:SwissDict}, Base.ValueIterator{<:SwissDict}}, state) @ DataStructures ~/.julia/packages/DataStructures/59MD0/src/swiss_dict.jl:646 invalidated:
backedges: 1: superseding iterate(v::T, i::Int64) where T<:Union{KeySet{<:Any, <:Dict}, ValueIterator{<:Dict}} @ Base dict.jl:698 with MethodInstance for iterate(::Base.KeySet{K, T} where {K, T<:(Dict{K})}, ::Int64) (13 children)
2: superseding iterate(v::T, i::Int64) where T<:Union{KeySet{<:Any, <:Dict}, ValueIterator{<:Dict}} @ Base dict.jl:698 with MethodInstance for iterate(::Base.KeySet{String, T} where T<:(Dict{String}), ::Int64) (40 children)
14 mt_cache
...Compared to julia> length(uinvalidated(invalidations))
482
julia> trees = invalidation_trees(invalidations)
...
inserting iterate(v::Union{Base.KeySet{<:Any, <:SwissDict}, Base.ValueIterator{<:SwissDict}}, state) in DataStructures at ~/.julia/packages/DataStructures/59MD0/src/swiss_dict.jl:646 invalidated:
backedges: 1: superseding iterate(v::Union{Base.KeySet, Base.ValueIterator}, state...) in Base at abstractdict.jl:63 with MethodInstance for iterate(::Base.KeySet, ::Any) (1 children)
2: superseding iterate(v::Union{Base.KeySet, Base.ValueIterator}, state...) in Base at abstractdict.jl:63 with MethodInstance for iterate(::Base.KeySet{String, _A} where _A<:(AbstractDict{String}), ::Any) (8 children)
3: superseding iterate(v::T, i::Int64) where T<:Union{Base.KeySet{<:Any, <:Dict}, Base.ValueIterator{<:Dict}} in Base at dict.jl:712 with MethodInstance for iterate(::Base.KeySet{var"#s82", T} where {var"#s82", T<:(Dict{var"#s82"})}, ::Int64) (44 children)
4: superseding iterate(v::T, i::Int64) where T<:Union{Base.KeySet{<:Any, <:Dict}, Base.ValueIterator{<:Dict}} in Base at dict.jl:712 with MethodInstance for iterate(::Base.KeySet{String, _A} where _A<:(Dict{String}), ::Int64) (317 children)on Julia v1.8.2. So there are still some invalidations left but a big chunk is gone. We cannot test invalidations directly but should probably do so when/if #47093 is merged. |
|
While our benchmark result seems good, I'd like to confirm this change doesn't come with noticeable regression in compiling a large package like Plots.jl or OrdinaryDiffEq.jl. We currently don't have a proper benchmark setup for that, so it needs some manual inspection. |
|
OrdinaryDiffEq.jl cannot be precompiled with the current nightly build since LinearSolve.jl fails to precompile there 🤷 |
|
Nevertheless, I ran the following code to benchmark precompilation time of some packages I use frequently: julia-nightly -e 'rm(joinpath(homedir(), ".julia", "compiled", "v1.9"), force=true, recursive=true); import Pkg; Pkg.activate(temp=true); @time Pkg.add(["Plots", "OrdinaryDiffEq", "Trixi", "BSeries", "Symbolics", "SymPy", "PyPlot"])'Nightly build of Julia (Commit dc3a2e8): This PR: So this does not look like a serious regression to me. Is this what you had in mind? |
Yeah, that check seems valid, thanks so much! |
|
Added more unit tests. Going to merge once confirming that CI runs successfully. |
apply_type_tfunc accuracy
|
@nanosoldier |
|
Note that you can get |
|
Your benchmark job has completed - no performance regressions were detected. A full report can be found here. |
CI has never passed on this branch, apparently due to the added time required, so let's not be too hasty to remove the comment about this being disabled because it slows down inference too much |
|
It does seem that it's a hang/deadlock more than a slowdown |
Co-authored-by: Shuhei Kadowaki <[email protected]>
|
There seems to be some inference convergence/performance issues to due to this. I would like to keep working on it on my branch, so let me supersede this by #48329. |
As discussed in #47089
Closes #47089
CC @aviatesk