Understanding GC time

Hello together,

I am wondering what determines the time that the garbage collector needs. I have a complex simulation where I was hunting down allocations, but surprisingly even though I could heavily reduce number and amount of allocations, GC time didn’t change significantly. Before optimization I had 997.37 k allocations: 98.777 MiB, 14.90% gc time, after I could reduce it to 517.18 k allocations: 55.230 MiB, 20.16% gc time, overall timing is in both cases in the order of 0.8s. I actually thought the gc time should scale with number or amount of allocations, but apparently it does not.

I am manually evoking GC.gc() at the end of the simulation due to this issue. I have to test if this is still needed. So can it be that the advantage of reducing allocations only lies in that gc is needed less often while gc time itself is always the same?

Don’t do that. Should not be needed any longer for recent versions of Julia.

And try to start Julia with

 julia --project --gcthreads=8,1

depending on the number of cores of your CPU.

1 Like