Skip to content
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

large performance regression in obtaining sparse array from a transpose of a sparse array #28948

Closed
ExpandingMan opened this issue Aug 29, 2018 · 3 comments
Labels
performance Must go faster regression Regression in behavior compared to a previous version sparse Sparse arrays

Comments

@ExpandingMan
Copy link
Contributor

using Compat.SparseArrays, Compat.Random
using BenchmarkTools

const N = 10^4

const Nnz = 5*10^6

A = zeros(Float64, N,N)

for i  1:Nnz
    A[rand(1:size(A,1)),rand(1:size(A,2))] = 1.0
end

A = sparse(A)

On 0.6.4:

julia> @btime sparse(transpose(A));
  292.237 ms (15 allocations: 149.00 MiB)

On 1.0.0

julia> @btime sparse(transpose(A));
  9.729 s (40 allocations: 240.79 MiB)

This scales very badly with the size of the array. This makes life extremely difficult if you want to get the "I, J, V" values of the resulting transpose.

In the meantime any advice on a work around would be hugely appreciated.

@KristofferC
Copy link
Sponsor Member

Using SparseMatrixCSC(A), should be fast (#28049). Probably need to hook up sparse in the same way.

@ExpandingMan
Copy link
Contributor Author

Ah yes! I realized that literally just 2 minutes before you posted this, thanks!

That's a huge relief, it might have been a lot of work to get around this. Ok, I'll try to make a PR if the fix is straight-forward enough.

@mbauman mbauman added the sparse Sparse arrays label Aug 29, 2018
@nalimilan nalimilan added the regression Regression in behavior compared to a previous version label Sep 3, 2018
@JeffBezanson JeffBezanson added the performance Must go faster label Sep 4, 2018
KristofferC pushed a commit that referenced this issue Sep 4, 2018
KristofferC pushed a commit that referenced this issue Sep 4, 2018
* fixed regression in sparse of adjoint

(cherry picked from commit c43793c)
KristofferC pushed a commit that referenced this issue Sep 8, 2018
* fixed regression in sparse of adjoint

(cherry picked from commit c43793c)
KristofferC pushed a commit that referenced this issue Sep 8, 2018
* fixed regression in sparse of adjoint

(cherry picked from commit c43793c)
@KristofferC
Copy link
Sponsor Member

Fixed by #28954

KristofferC pushed a commit that referenced this issue Feb 11, 2019
* fixed regression in sparse of adjoint

(cherry picked from commit c43793c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster regression Regression in behavior compared to a previous version sparse Sparse arrays
Projects
None yet
Development

No branches or pull requests

5 participants