Skip to content

huge performance hit in 0.6: negative of a sparse matrix #19503

Closed
@StephenVavasis

Description

@StephenVavasis

There appears to be a huge performance problem with taking the negative of a sparse matrix in 0.6. Observe the following timings for the code below (64-bit Windows 10 machine):

0.4.6:

julia> VERSION
v"0.4.6"

julia> @time test_minus_sparse.tms(4,10000)
  0.024588 seconds (106 allocations: 28.906 MB, 17.33% gc time)
-7.818594853651364

0.6.0-dev:

julia> VERSION
v"0.6.0-dev.1378"

julia> @time test_minus_sparse.tms(4,10000)
 10.796751 seconds (140 allocations: 28.757 MB, 0.11% gc time)
-7.818594853651364

Code:

module test_minus_sparse

function tms(ntrial,n)
    is = zeros(Int64,0)
    js = zeros(Int64,0)
    es = zeros(0)
    for i = 1 : n
        for k = max(1,i-10) : min(n, i+10)
            push!(is, i)
            push!(js, k)
            push!(es, sin(Float64(i)) * cos(Float64(k)))
        end
    end
    s = sparse(is,js,es,n,n)
    sum_e = 0.0
    for j = 1 : ntrial
        t = -s
        sum_e += t[1,1]
        s[1,1] += 1.0
    end
    sum_e
end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    performanceMust go fasterpotential benchmarkCould make a good benchmark in BaseBenchmarkssparseSparse arrays

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions