-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Description
If I have a function prototype something like this:
doit(a::Array{Tuple{Int, MyType}, 1}, b::Int, c::MyType)
where MyType is an ordinary Julia GC/heap allocated type, then the following line of code within the function seems to lead to a heap allocation of a tuple (the same is the case for any immutable type).
a[1] = b, c
There seem to be two issues here:
-
There seems to be no efficient way to write an immutable value directly into an array in Julia. The above shouldn't require any allocation of any kind, stack or heap.
-
Apparently, Julia GC/heap-allocates immutables if they contain heap references. I don't understand why, since surely the GC scans the stack conservatively for pointers.
Anyway, I have been unable to find a ticket or PR which deals with the above serious performance issue (which we hit in practice), directly.
(Obliquely) relevant tickets/PRs/tickets seem to include [1]. [2], [3] and [4] and of course the tupocalypse itself. There are also some relevant sounding things on Jeff's compiler optimisation tracker [5], though I am not clear if any are directly relevant.
[1] #8134
[2] #12205
[3] https://groups.google.com/forum/#!topic/julia-users/F_ncyfP2vxg
[4] https://groups.google.com/forum/#!topic/julia-users/LthfABeDN50
[5] #3440