Tracking allocations lost its way?

I get a @time report:

92.505464 seconds (20.12 M allocations: 2.683 GiB, 0.29% gc time) .

When I look at the code with --track-allocations=all, the following (abbreviated) file is obtained.
All lines with any allocation whatsoever are included here. Clearly the number of allocations is
about 10, not 20 million. What is it talking about in the @time report?


        - function cs!(outputI, outputJ, outputV, I, J, V, Nc)
 40240112     count = fill(zero(eltype(J)), Nc+1)
        0     @inbounds for i in eachindex(J)
...
        0     end
        0     return nothing
        - end
        - 
        - function cp(Nc, J)
 40240112     colptr = fill(0, Nc+1)
        -     p = 1
...
        0     return colptr
        - end
        - 
        - function cr(N, colptr, I, V)
        0     maxrows = maximum(diff(colptr))
        -     # newrows = fill(zero(eltype(I)), maxrows)
        -     # newvals = fill(zero(eltype(V)), maxrows)
      336     prma = fill(zero(eltype(I)), maxrows)
458768240     newI = similar(I)
458768240     newV = similar(V)
 40240112     newcolptr = similar(colptr)
        0     newcolptr[1] = colptr[1]
...
        0     end
458768048     newI = newI[1:p-1]
458768048     newV = newV[1:p-1]
        0     return newcolptr, newI, newV
        - end
        - 
        - function sc(inputI, inputJ, inputV, Nr, Nc)
458768240     I = similar(inputI)
458768240     J = similar(inputJ)
458768240     V = similar(inputV)
        - 
...
        - end
        - 

Could maybe be allocations in Base? Hunting down allocations with Julia 1.8's Allocation Profiler | Nathan Daly, Pete Vilter - YouTube is a better way to find allocations imo.

2 Likes

Thanks for the pointer!

Wouldn’t it actually be nice to have the allocations in the base also in the code listing?
That is useful information…

You were right apparently: sortperm! allocates 16 bytes. Edit: Which could be eliminated. Now the code is down to 26 allocations from 20M.

my understanding is this thing is soft deprecated, forgot reason

1 Like

Because of the new allocation profiler. This one was unreliable due to changing how code is emitted, possibly leading to false positives.

3 Likes