Garbage Collection Is Useful
6 days ago
- #incremental-parsing
- #reference-counting
- #garbage-collection
- The author reflects on their experience with garbage collection (GC) in the J9 Java VM and how it remains useful in solving modern problems.
- A tricky problem involving bidirectional updates between text documents parsed by Ohm and rendered in ProseMirror was solved using insights from the paper 'A Unified Theory of Garbage Collection'.
- Ohm supports incremental parsing and limited incremental transforms, allowing efficient updates by reusing portions of previous results.
- The initial solution involved tracing GC, which was inefficient as it required visiting every node in the document after each edit.
- The paper suggested that tracing and reference counting are duals, leading to a more efficient solution using reference counting to identify dead nodes without visiting all live ones.
- Reference counting was implemented to decrement counts recursively, efficiently identifying nodes not reused in the new document.