Threads are not speeding up computation a lot

The ones function only allocates one instance of one, so you get one allocation for the array and one for the single allocated element. For example for BigInt we have

julia> xs = ones(BigInt, 2)
2-element Vector{BigInt}:
 1
 1

julia> xs[1] === xs[2]
true

I don’t know if there is any way around the allocation, I think the gc needs to be involved to keep track of the #undef as well.

2 Likes