-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Open
Labels
performanceMust go fasterMust go fasterregression 1.11Regression in the 1.11 releaseRegression in the 1.11 releasesortingPut things in orderPut things in ordersparseSparse arraysSparse arrays
Description
Usingsortslices
on a boolean sparse matrix is more than 100x slower than sortslices
on sparse matrices of other data types or directly summing and sorting the slices.
Replicated the issue on both Windows and MacOS builds of Julia 1.11.1 and do not see the same issue on 1.10.5
using SparseArrays
function sum_sort(matrix::SparseMatrixCSC)
csum = vec(sum(matrix, dims=1))
perm = sortperm(csum)
return matrix[:,perm]
end
test_mat_bool = rand(Bool,1000,1000) |> SparseMatrixCSC
result_bool = @time sortslices(test_mat_bool, dims=2, by=sum)
result_bool2 = @time sum_sort(test_mat_bool)
@assert result_bool == (result_bool2 |> dropzeros!)
test_mat_int = rand(Int,1000,1000) |> SparseMatrixCSC
result_int = @time sortslices(test_mat_int, dims=2, by=sum)
result_int2 = @time sum_sort(test_mat_int)
@assert result_int == (result_int2 |> dropzeros!)
Metadata
Metadata
Assignees
Labels
performanceMust go fasterMust go fasterregression 1.11Regression in the 1.11 releaseRegression in the 1.11 releasesortingPut things in orderPut things in ordersparseSparse arraysSparse arrays