Skip to content

sparse is twice as slow with Int32 indices #12963

@bdqp

Description

@bdqp

Constructing a large sparse matrix, using Int32 indices is a lot slower. Is this a performance bug or expected behavior? I kind of thought it would be quicker due to more elements being available in cache memory.

julia> N=1000000; NNZ=20*N;
julia> r = rand(int32(1:N),NNZ);
julia> c = rand(int32(1:N),NNZ);
julia> v = rand(Float32,NNZ);
julia> tic(); A = sparse(r,c,v,N,N); toc()
elapsed time: 11.829277923 seconds
11.829277923

julia> r = rand(int64(1:N),NNZ);
julia> c = rand(int64(1:N),NNZ);
julia> tic(); B = sparse(r,c,v,N,N); toc()
elapsed time: 6.594016314 seconds
6.594016314

julia> whos()
A 1000000x1000000 SparseMatrixCSC{Float32,Int32}
B 1000000x1000000 SparseMatrixCSC{Float32,Int64}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions