Skip to content

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

@ExpandingMan

Description

@ExpandingMan
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    performanceMust go fasterregressionRegression in behavior compared to a previous versionsparseSparse arrays

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions