We have a (time critical function) with the following prototype:

heapinsert!{N}(xs::Array{Tuple{NTuple{N, UInt}, heap_s}, 1}, exp::NTuple{N, 
UInt}, x::heap_s)


However, one line of code in the implementation is allocating gigabytes of 
memory, which is causing a massive performance deficit in our program:

xs[1] = (exp, x)

Note heap_s is just an ordinary Julia type here, which contains a couple of 
Ints and another heap_s. As far as I can see it is irrelevant. It should 
just be a pointer at the machine level.

It seems that Julia allocates space for the tuple (exp, x) and then writes 
it into the array xs.

Does anyone have any ideas how I can stop it from making this unnecessary 
allocation? It's slowing down multivariate polynomial multiplication by a 
factor of at least 2 (and possibly 10) and causing a massive blowout in 
memory allocation (this is really performance critical code).

I've already tried making using an immutable rather than a tuple. Same 
problem. I'm tracing this using julia --track-allocation=all.

Bill.

Reply via email to