-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Sparse-sparse matrix multiplication 4x slower on 0.5 than 0.4, 6x slower on master #21370
Comments
Ref: #939 (comment) ( |
It seems that creating the Adding (using https://github.com/KristofferC/TimerOutputs.jl): @timeit "create ord" begin
order = ord(lt,by,rev,order)
end
@timeit "create perm" begin
p = Perm(order, v)
end
@timeit "do sort" begin
sort!(x, alg, p)
end to
As a note, it is a bit sad that 2% is spent doing the sorting and 98% is overhead. |
Reduced to: using BenchmarkTools
function _sortperm!(v::AbstractVector;
lt=isless,
by=identity,
rev::Bool=false,
order::Base.Ordering=Base.Order.Forward)
order = Base.Order.ord(lt,by,rev,order)
p = Base.Order.Perm(order, v)
end
v = rand(12)
@btime _sortperm!($v) 0.6: Changes in 0.6 vs 0.5 is that Full relevant 0.6 trace:
Full relevant 0.5 trace:
|
With that benchmark, I also get: |
From #20993 (benchmarking 0.6 vs 0.5): | |
Is that the actual sorting that got slower or just overhead like here? |
We should probably have a dedicated sortperm implementation that doesn't use the same code paths as everything else. I believe can use a linear time sorting algorithm since you know the exact distribution of values. |
While true, it's perhaps not relevant for this issue. |
That sort of thing is why I wanted to check performance vs 0.4 in #20947 |
fix #21370, regression in dynamic dispatch of complex constructors
We should add something derived from this to the performance tracking tests. I'll have to familiarize myself with how to structure those if no one beats me to it. |
Although the constructor issue is solved, sparse matmul is still often dominated by sorting, so let me leave a note for future issue-posters or potential push-requesters to consider. |
Test code:
From looking into the profiles, almost all of the slowdown is from the sorting of the row indices that happens here https://github.com/JuliaLang/julia/blame/c8026a91acd988fbbb08158092a89e111c243965/base/sparse/linalg.jl#L192. Neither
spmatmul
norsortSparseMatrixCSC!
(https://github.com/JuliaLang/julia/blame/c8026a91acd988fbbb08158092a89e111c243965/base/sparse/sparsematrix.jl#L3310-L3362) have changed much from 0.4 to 0.5 or 0.5 to now.The text was updated successfully, but these errors were encountered: