Julia written in Julia?

This is indeed a little ot. But anyway, I realized that I haven’t said his for long enough that it’s probably worth putting it up again.

One thing to realize is that freeing is not free. You must do work to free memory, work needed so that you can use the memory again, or else why are you freeing the memory in the first place…

So there are basically two aspects of freeing memory afa the GC is concerned, to mark it as not needed and to actually free it. In a tracing GC, the first is free (dead memory cause no time in marking) and does the second in bulk. Both of these are very important for the performance of the GC. In particular, the bulk freeing is actually one of the main reason, I believe, that a GC can achieve higher throughput than manual memory management. That this means is that if you don’t do freeing in bulk, you can easily loose performance, rather than gaining it and just marking something free is useless since it doesn’t take the GC any time to ffigure that out anyway.

Now this is not to say there’s nothing you can do to help the GC, but it won’t be trivial at all. It would almost have to be a very integrated solution, which might involve changing part of the GC to have different kinds of memory, maybe changing the compiler to take advantage of this (another way of having a different type of memory), and possibly other ways. And even with these, I think the most useful thing you can do is to give the compiler more escape information and then it isn’t necessarily a “help GC” anymore and we’ve certainly done a lot about it.

There are also other ways you could “help” the GC, but I think in general you can’t trivially help the GC in any meaningful way. There are certainly still areas you can improve the GC, but there are very few that doesn’t involve a trade off.

11 Likes