Apply InitialOptimizations more consistently in sorting#47946
Apply InitialOptimizations more consistently in sorting#47946LilithHafner merged 3 commits intomasterfrom
InitialOptimizations more consistently in sorting#47946Conversation
|
@nanosoldier |
|
Your benchmark job has completed - no performance regressions were detected. A full report can be found here. |
|
@nanosoldier |
|
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. |
|
Performance now looks equal to 1.8 but allocates 3x more. Is that expected? |
|
The allocations in julia> list = rand(50_000);
julia> ix = collect(1:length(list));
julia> @benchmark sortperm!(x, $list; alg = InsertionSort, rev = true) setup=(x = copy($ix))
BenchmarkTools.Trial: 5 samples with 1 evaluation.
Range (min … max): 1.068 s … 1.144 s ┊ GC (min … max): 0.00% … 0.00%
Time (median): 1.087 s ┊ GC (median): 0.00%
Time (mean ± σ): 1.091 s ± 30.354 ms ┊ GC (mean ± σ): 0.00% ± 0.00%
▁ ▁ █ ▁
█▁▁█▁▁▁▁▁▁▁▁▁▁█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█ ▁
1.07 s Histogram: frequency by time 1.14 s <
Memory estimate: 48 bytes, allocs estimate: 3.See issue #47949 |
|
The performance diff across this PR seems reasonable under JuliaCI/BaseBenchmarks.jl#305 as well |
|
Alright. This should be good to go then? |
#47383 revised how initial optimizations (special cases for
eltypes that are unions with missing and/or a concreteIEEEFloatorBooland very small input) are implemented and dispatched to. I accidentally dropped the initial optimizations in that PR for cases where the user specifiesalg=QuickSort,alg=MergeSort, oralg=InsertionSort. I also dropped those optimizations forpartialsortandparitalsort!. Thanks @vtjnash for catching these regressions hereThis PR applies
InitialOptimizationsto achieve better performance and avoid regressions.Also fixes a dispatch bug in
::MissingOptimizationand debugs code that was previously unreachable due to that dispatch bug.