GHC and garbage collection

Somebody brought to my attention the 2024-04-16 discussion between Victor Miraldo, Niki Vazou and Joachim Breiner about GHC-produced software and garbage collection (GC) and the needs of users of certain software in production, starting at about 0:36:39 at the podcast transcript at: Victor Cacciari Miraldo. There is a reference there to @bgamari (Ben Gamari) having worked on GC strategies and ‘relatively recent’ developments in GHC’s approach to GC. Some questions flow from that:

The reference guide starts by explaining that there are several things that can be tweaked for maximum performance. A tutorial-like guide might explain what to tweak and how and when, to maximise performance in different circumstances.

EDIT: I am going to edit this top post to collect interesting strands in any discussion below, attempting a roughly chronological order. Thank you to all contributors:

People:

  • @bgamari: see references above.
  • @TeofilC (Teo Camarasu): has recently implemented improvements to the ‘non-moving’ GC, reducing memory usage overheads.
6 Likes

They refer to the non moving GC, which is a great choice for workloads where you have a large heap like the one mentioned in the interview. It has worked really well when I’ve seen it used on similar workloads.

Recently I’ve implemented some improvements to it that have reduced the memory usage overheads from it. And I’ve been thinking about things in this area.

The next thing I’m excited about in this area is something like what Ben describes here: https://www.youtube.com/watch?v=Ha7oIVrLwSI&list=PLyrlk8Xaylp5ahGXwF_NvYEhVOnedRIAs&index=14
See also: #21578: [Discussion] Erlang-style processes in the RTS · Issues · Glasgow Haskell Compiler / GHC · GitLab

I’m hoping to help with this at some point when I find some time, but I’ve been focusing on other things recently.

Though I think the current state of the non moving GC already makes very large heaps manageable with GHC

A tutorial like you describe would be great! I’ve also thought about similar things. I’m not sure if anything like that currently exists. The RTS GC docs are mostly a reference and aren’t super accessible for someone hoping to learn about it for the first time . There are a few talks about the GC as well that are helpful

12 Likes