Reducing total memory usage from 329MB to 268MB for the ml100k.jl test by using SubArrays within Julia.
The problem is that given a matrix X, accessing a column or row of the matrix X[:, c] will allocate a completely new array with the contents of X[:, c]. Julia can avoid this by using subarrays which are views/references to the subarray with the matrix. To use a subarray and avoid memory allocation: sub(X, :, c).
To support both types of SubArray and DenseVector, we convert some types to StridedVector which is essentially a union of the two.
Coverage remained the same at 96.552% when pulling 3849ceb5f0228ccf8bc2b8d716f031ae4ae214b6 on Hydrotoast:subarray-memory-reduction into fa6c4f7d0d469924ac939867325111268b13e0e0 on btwardow:master.
Reducing total memory usage from 329MB to 268MB for the
ml100k.jl
test by usingSubArray
s within Julia.The problem is that given a matrix
X
, accessing a column or row of the matrixX[:, c]
will allocate a completely new array with the contents ofX[:, c]
. Julia can avoid this by using subarrays which are views/references to the subarray with the matrix. To use a subarray and avoid memory allocation:sub(X, :, c)
.To support both types of
SubArray
andDenseVector
, we convert some types toStridedVector
which is essentially a union of the two.