Skip to content

Conversation

ranocha
Copy link
Member

@ranocha ranocha commented Sep 27, 2022

I improved type stability to fix some invalidations. This is based on the following code:

julia> import Pkg; Pkg.activate(temp=true); Pkg.add("Static")

julia> using SnoopCompileCore; invalidations = @snoopr(using Static); using SnoopCompile

julia> length(uinvalidated(invalidations))
195

julia> trees = invalidation_trees(invalidations)
...
 inserting !(::False) in Static at ~/.julia/packages/Static/maaLb/src/Static.jl:428 invalidated:
 ...
                 34: signature Tuple{typeof(!), Any} triggered MethodInstance for Base.Sort.var"#sort!#8"(::Base.Sort.Algorithm, ::typeof(isless), ::Function, ::Nothing, ::Base.Order.ForwardOrdering, ::typeof(sort!), ::Vector) (10 children)
...
                 37: signature Tuple{typeof(!), Any} triggered MethodInstance for Base.Sort.var"#sort!#8"(::Base.Sort.Algorithm, ::typeof(isless), ::typeof(identity), ::Nothing, ::Base.Order.ForwardOrdering, ::typeof(sort!), ::AbstractVector) (15 children)
...
                 39: signature Tuple{typeof(!), Any} triggered MethodInstance for Base.Sort.var"#sort!#8"(::Base.Sort.Algorithm, ::typeof(isless), ::typeof(identity), ::Nothing, ::Base.Order.ForwardOrdering, ::typeof(sort!), ::Vector) (45 children)

With this PR on top of the current release-1.8 branch:

julia> length(uinvalidated(invalidations))
132

and all invalidations in sort! are gone.

This requires a manual backport (which is relatively straightforward) since quite a bit changed in sort.jl - searching for all instances of sub_with_overflow/add_with_overflow in sort.jl and applying the change there.

@ranocha ranocha added latency Latency backport 1.8 Change should be backported to release-1.8 labels Sep 27, 2022
@KristofferC KristofferC mentioned this pull request Sep 30, 2022
37 tasks
@LilithHafner LilithHafner added the sorting Put things in order label Oct 2, 2022
Co-authored-by: Lilith Orion Hafner <[email protected]>
@LilithHafner LilithHafner added the merge me PR is reviewed. Merge when all tests are passing label Oct 2, 2022
@LilithHafner LilithHafner merged commit 9105064 into JuliaLang:master Oct 3, 2022
@LilithHafner LilithHafner removed the merge me PR is reviewed. Merge when all tests are passing label Oct 3, 2022
@ranocha ranocha deleted the hr/invalidations_sort branch October 3, 2022 14:28
KristofferC pushed a commit that referenced this pull request Oct 28, 2022
Co-authored-by: Lilith Orion Hafner <[email protected]>
(cherry picked from commit 9105064)
@KristofferC KristofferC removed the backport 1.8 Change should be backported to release-1.8 label Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
latency Latency sorting Put things in order
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants