[julia-users] Re: Memory allocation for vectorized operations

2014-04-29 Thread Carlos Becker
I just saw another part of your message, I am wondering also why memory 
consumption is so high.

El martes, 29 de abril de 2014 11:31:09 UTC+2, Carlos Becker escribió:

 This is likely to be because Julia is creating temporaries. This is 
 probably why you get increasing memory usage when increasing array size.

 This is a long topic, that will have to be solved (hopefully soon), I had 
 a previous question related to something similar here: 
 https://groups.google.com/d/topic/julia-users/Pbrm9Nn9fWc/discussion


 El martes, 29 de abril de 2014 08:05:17 UTC+2, John Aslanides escribió:

 I'm aware that evaluating a vectorized operation (say, an elementwise 
 product of two arrays) will result in the allocation of a temporary array. 
 I'm surprised, though, at just how much memory this seems to consume in 
 practice -- unless there's something I'm not understanding. Here is an 
 extreme example:

 julia a = rand(2); b = rand(2);

 julia @time a .*= b;
 elapsed time: 0.505942281 seconds (11612212 bytes allocated)

 julia @time a .*= b;
 elapsed time: 1.4177e-5 seconds (800 bytes allocated)

 julia @time a .*= b;
 elapsed time: 2.5334e-5 seconds (800 bytes allocated)

 800 bytes seems like a lot of overhead given that a and b are both only 
 16 bytes each. Of course, this overhead (whatever it is) becomes 
 comparatively less significant as we move to larger arrays, but it's still 
 sizeable:

 julia a = rand(20); b = rand(20);

 julia @time a.*= b;
 elapsed time: 1.4162e-5 seconds (944 bytes allocated)

 julia @time a.*= b;
 elapsed time: 2.3754e-5 seconds (944 bytes allocated)

 Can someone explain what's going on here?



[julia-users] Re: Memory allocation for vectorized operations

2014-04-29 Thread Carlos Becker
Besides Julia internals, I suppose there is memory overhead in terms of the 
structure holding the array itself (when temporaries are created).
I suppose an array isn't just the size in bytes of the data it holds, but 
also information about its size/type/etc. Though I doubt that would add up 
to 800 bytes, it could explain part of it.

I wonder if there is a way within julia to know the 'real' size of a julia 
object.

El martes, 29 de abril de 2014 11:32:21 UTC+2, Carlos Becker escribió:

 I just saw another part of your message, I am wondering also why memory 
 consumption is so high.

 El martes, 29 de abril de 2014 11:31:09 UTC+2, Carlos Becker escribió:

 This is likely to be because Julia is creating temporaries. This is 
 probably why you get increasing memory usage when increasing array size.

 This is a long topic, that will have to be solved (hopefully soon), I had 
 a previous question related to something similar here: 
 https://groups.google.com/d/topic/julia-users/Pbrm9Nn9fWc/discussion


 El martes, 29 de abril de 2014 08:05:17 UTC+2, John Aslanides escribió:

 I'm aware that evaluating a vectorized operation (say, an elementwise 
 product of two arrays) will result in the allocation of a temporary array. 
 I'm surprised, though, at just how much memory this seems to consume in 
 practice -- unless there's something I'm not understanding. Here is an 
 extreme example:

 julia a = rand(2); b = rand(2);

 julia @time a .*= b;
 elapsed time: 0.505942281 seconds (11612212 bytes allocated)

 julia @time a .*= b;
 elapsed time: 1.4177e-5 seconds (800 bytes allocated)

 julia @time a .*= b;
 elapsed time: 2.5334e-5 seconds (800 bytes allocated)

 800 bytes seems like a lot of overhead given that a and b are both only 
 16 bytes each. Of course, this overhead (whatever it is) becomes 
 comparatively less significant as we move to larger arrays, but it's still 
 sizeable:

 julia a = rand(20); b = rand(20);

 julia @time a.*= b;
 elapsed time: 1.4162e-5 seconds (944 bytes allocated)

 julia @time a.*= b;
 elapsed time: 2.3754e-5 seconds (944 bytes allocated)

 Can someone explain what's going on here?



[julia-users] Re: Memory allocation for vectorized operations

2014-04-29 Thread Avik Sengupta
That overhead seems constant, beyond a single temporary. So I dont suppose 
there is that much to be worried about, unless you are using many small 
arrays. 

julia 800-sizeof(rand(2))
784

julia 944-sizeof(rand(20))
784


On Tuesday, 29 April 2014 10:40:10 UTC+1, Carlos Becker wrote:

 Besides Julia internals, I suppose there is memory overhead in terms of 
 the structure holding the array itself (when temporaries are created).
 I suppose an array isn't just the size in bytes of the data it holds, but 
 also information about its size/type/etc. Though I doubt that would add up 
 to 800 bytes, it could explain part of it.

 I wonder if there is a way within julia to know the 'real' size of a julia 
 object.

 El martes, 29 de abril de 2014 11:32:21 UTC+2, Carlos Becker escribió:

 I just saw another part of your message, I am wondering also why memory 
 consumption is so high.

 El martes, 29 de abril de 2014 11:31:09 UTC+2, Carlos Becker escribió:

 This is likely to be because Julia is creating temporaries. This is 
 probably why you get increasing memory usage when increasing array size.

 This is a long topic, that will have to be solved (hopefully soon), I 
 had a previous question related to something similar here: 
 https://groups.google.com/d/topic/julia-users/Pbrm9Nn9fWc/discussion


 El martes, 29 de abril de 2014 08:05:17 UTC+2, John Aslanides escribió:

 I'm aware that evaluating a vectorized operation (say, an elementwise 
 product of two arrays) will result in the allocation of a temporary array. 
 I'm surprised, though, at just how much memory this seems to consume in 
 practice -- unless there's something I'm not understanding. Here is an 
 extreme example:

 julia a = rand(2); b = rand(2);

 julia @time a .*= b;
 elapsed time: 0.505942281 seconds (11612212 bytes allocated)

 julia @time a .*= b;
 elapsed time: 1.4177e-5 seconds (800 bytes allocated)

 julia @time a .*= b;
 elapsed time: 2.5334e-5 seconds (800 bytes allocated)

 800 bytes seems like a lot of overhead given that a and b are both only 
 16 bytes each. Of course, this overhead (whatever it is) becomes 
 comparatively less significant as we move to larger arrays, but it's still 
 sizeable:

 julia a = rand(20); b = rand(20);

 julia @time a.*= b;
 elapsed time: 1.4162e-5 seconds (944 bytes allocated)

 julia @time a.*= b;
 elapsed time: 2.3754e-5 seconds (944 bytes allocated)

 Can someone explain what's going on here?



[julia-users] Re: Memory allocation for vectorized operations

2014-04-29 Thread John Aslanides
Avik: this is actually the situation I'm in. My tight inner loops 
involve elementwise operations on many small arrays, so the runtime cost 
of using vectorized code is enormous. Using the macros provided by 
Devectorize.jl only somewhat alleviates this problem, so I ended up 
hand-writing devectorized loops to achieve zero temp allocation when 
writing in-place. I'm quite happy to do this -- C-like code for C-like 
performance, after all -- but I was curious as to where this runtime 
overhead was coming from, and whether it's avoidable.



On 29/04/2014 8:27 pm, Avik Sengupta wrote:
That overhead seems constant, beyond a single temporary. So I dont 
suppose there is that much to be worried about, unless you are using 
many small arrays.


julia 800-sizeof(rand(2))
784

julia 944-sizeof(rand(20))
784


On Tuesday, 29 April 2014 10:40:10 UTC+1, Carlos Becker wrote:

Besides Julia internals, I suppose there is memory overhead in
terms of the structure holding the array itself (when temporaries
are created).
I suppose an array isn't just the size in bytes of the data it
holds, but also information about its size/type/etc. Though I
doubt that would add up to 800 bytes, it could explain part of it.

I wonder if there is a way within julia to know the 'real' size of
a julia object.

El martes, 29 de abril de 2014 11:32:21 UTC+2, Carlos Becker
escribió:

I just saw another part of your message, I am wondering also
why memory consumption is so high.

El martes, 29 de abril de 2014 11:31:09 UTC+2, Carlos Becker
escribió:

This is likely to be because Julia is creating
temporaries. This is probably why you get increasing
memory usage when increasing array size.

This is a long topic, that will have to be solved
(hopefully soon), I had a previous question related to
something similar here:
https://groups.google.com/d/topic/julia-users/Pbrm9Nn9fWc/discussion

https://groups.google.com/d/topic/julia-users/Pbrm9Nn9fWc/discussion


El martes, 29 de abril de 2014 08:05:17 UTC+2, John
Aslanides escribió:

I'm aware that evaluating a vectorized operation (say,
an elementwise product of two arrays) will result in
the allocation of a temporary array. I'm surprised,
though, at just how much memory this seems to consume
in practice -- unless there's something I'm not
understanding. Here is an extreme example:

julia a = rand(2); b = rand(2);

julia @time a .*= b;
elapsed time: 0.505942281 seconds (11612212 bytes
allocated)

julia @time a .*= b;
elapsed time: 1.4177e-5 seconds (800 bytes allocated)

julia @time a .*= b;
elapsed time: 2.5334e-5 seconds (800 bytes allocated)

800 bytes seems like a lot of overhead given that a
and b are both only 16 bytes each. Of course, this
overhead (whatever it is) becomes comparatively less
significant as we move to larger arrays, but it's
still sizeable:

julia a = rand(20); b = rand(20);

julia @time a.*= b;
elapsed time: 1.4162e-5 seconds (944 bytes allocated)

julia @time a.*= b;
elapsed time: 2.3754e-5 seconds (944 bytes allocated)

Can someone explain what's going on here?