Hacker News with Generative AI: Garbage Collection

Understanding JVM Garbage Collector Performance (mill-build.org)
Garbage collectors are a core part of many programming languages. While they generally work well, on occasion when they go wrong they can fail in very unintuitive ways. This article will discuss the fundamental design of how garbage collectors work, and tie it to real benchmarks of how GCs perform on the Java Virtual Machine.
Weak references and garbage collectors (bernsteinbear.com)
From 2018 to 2021, I worked on a greenfield Python runtime called Skybison. One of its major differences from CPython was that it used a moving garbage collector (GC). This I understood in theory—I knew that it ran when the heap filled up, knew we needed handles to update pointers in the runtime’s code, had read the Moon paper (PDF)—but the other day, I wanted to implement weak references and couldn’t immediately figure it out.
Weak references and garbage collectors (bernsteinbear.com)
From 2018 to 2021, I worked on a greenfield Python runtime called Skybison. One of its major differences from CPython was that it used a moving garbage collector (GC). This I understood in theory—I knew that it ran when the heap filled up, knew we needed handles to update pointers in the runtime’s code, had read the Moon paper (PDF)—but the other day, I wanted to implement weak references and couldn’t immediately figure it out.
Garbage collected smart pointers in Rust via concurrent cycle collection (maplant.com)
Ten years ago I wrote an article on how to implement a conservative garbage collector for C, and I got a lot of constructive criticism regarding the actual usefulness of the code presented. It only makes sense that on the ten-year anniversary of publishing I should try to fix my error by writing a garbage collector that is precise, does not make assumptions, and (hopefully) actually works.
Getting to Go: The Journey of Go's Garbage Collector (go.dev)
This is the transcript from the keynote I gave at the International Symposium on Memory Management (ISMM) on June 18, 2018.
Mark–Scavenge: Waiting for Trash to Take Itself Out (inside.java)
This blog post summarises a new garbage collection algorithm called Mark-Scavenge, which highlights how using reachability as a proxy for liveness in moving GCs leads to unnecessary data movement and how we can address this. This work is from the latest paper within the research collaboration between Oracle and Uppsala University. The full paper can be found on the ACM website.
A simple semi-space collector – wingolog (2022) (wingolog.org)
Good day, hackfolk. Today’s article is about semi-space collectors. Many of you know what these are, but perhaps not so many have seen an annotated implementation, so let’s do that.
Baby’s Second Garbage Collector (jennyjams.net)
This blog post is meant to an iteration on the tutorial and introduction to garbage collection implementation presented in this classic blog post. We are still working with simple garbage collectors, but this time another one with a bit more complexity.
CPython's Garbage Collector and Its Impact on Application Performance (codingconfessions.com)
Learn how the knowledge of CPython internals translate into performance insights for your code
Shenandoah GC (openjdk.org)
Shenandoah is the low pause time garbage collector that reduces GC pause times by performing more garbage collection work concurrently with the running Java program.
Next Generation Out of Band Garbage Collection (railsatscale.com)
In 2023, I wrote about how we’ve tuned Ruby’s garbage collector for Shopify’s monolith, including how we implemented out-of-band garbage collection to reduce the impact of major collection on latency.
A Performance Comparison of Modern Garbage Collectors (2021) [pdf] (rodrigo-bruno.github.io)
Incremental Garbage Collection in Ruby 2.2 (2015) (heroku.com)
This article introduces incremental garbage collection (GC) which has been introduced in Ruby 2.2. We call this algorithm RincGC. RincGC achieves short GC pause times compared to Ruby 2.1.
JVM statistics cause garbage collection pauses (2015) (evanjones.ca)
TL;DR: The JVM by default exports statistics by mmap-ing a file in /tmp (hsperfdata). On Linux, modifying a memory mapped file can block until disk I/O completes, which can be hundreds of milliseconds. Since the JVM modifies these statistics during garbage collection and safepoints, this causes pauses that are hundreds of milliseconds long. To reduce worst-case pause latencies, add the -XX:+PerfDisableSharedMem JVM flag to disable this feature. This will break tools that read this file, like jstat.
Conservative GC can be faster than precise GC (wingolog.org)
Should your garbage collector be precise or conservative? The prevailing wisdom is that precise is always better. Conservative GC can retain more objects than strictly necessary, making GC slow: GC has to more frequently, and it has to trace a larger heap on each collection. However the calculus is not as straightforward as most people think, and indeed there are some reasons to expect that conservative root-finding can result in faster systems.
Crash the GC with Random Values in Unsafe.Pointers (philpearl.github.io)
Deconstructing the Garbage-First Collector (2020) [pdf] (steveblackburn.org)
Making PyPy's GC and JIT produce a sound [video] (youtube.com)
Techniques for safe garbage collection in Rust (kyju.org)
Whippet is a garbage collector library for language run-time authors (wingolog.org)
Crafting Interpreters with Rust: On Garbage Collection (tunglevo.com)
Tracing garbage collection for arenas (btmc.substack.com)
Beginner's guide to the Shenandoah garbage collector (redhat.com)
Parallel garbage collection for SBCL (2023) (zenodo.org)
Garbage Collectors Are Scary (enyo.de)