Search code examples
matrixjuliamultiplication

Why does simple matrix multiplication occupy so much garbage collector time in Julia?


I have two large-ish matrices D (4096 x 40) and W (40 x 2800).

when I use @time R = D*W this gives the following stats:

38.449856 seconds (1.40 G allocations: 20.932 GiB, 55.88% gc time)

The 55.88% gc time was shocking to me. There must be a better way of doing this simple matrix calculation. Any ideas for this Julia novice?


Solution

  • You need to provide more information on how you generate D and W (or at least what their types are).

    This is what I get:

    julia> D = rand(4096, 40); W = rand(40, 2800);
    
    julia> @time R = D * W;
      0.081237 seconds (7 allocations: 87.500 MiB, 6.74% gc time)