July 22nd, 2024

Finalizers, Guardians, Phantom References

The discussion focuses on implementing guardians in the Whippet garbage collector, contrasting them with finalizers, and proposing solutions to manage concurrency and improve garbage collection strategies.

Read original articleLink Icon
Finalizers, Guardians, Phantom References

The discussion revolves around the implementation of guardians in the Whippet garbage collector, contrasting them with finalizers and their concurrency management. Guardians allow the mutator to control concurrency, unlike finalizers, which run concurrently with the mutator. The text references Java's PhantomReference and ReferenceQueue as similar concepts but notes differences in implementation. It highlights issues in Guile's implementation of guardians, where finalizers may run simultaneously with the objects they protect, potentially leading to problems like accessing already-closed file ports.

To address these issues, one proposed solution is to introduce a special guardian pass in the garbage collector to identify unreachable guarded objects before finalization occurs. This would ensure that all guarded objects are processed before any finalizers are executed. An alternative approach suggests implementing a system of finalizer priorities, allowing the garbage collector to run finalizers in a specific order, which could also accommodate constructs like Java's phantom references and weak references.

The author invites further exploration of other garbage collection constructs that could be exposed to the mutator and cannot be implemented using existing methods like ephemerons and multi-priority finalizers. The note serves as a reflection on potential improvements and considerations for future garbage collection strategies.

Related

Tracing garbage collection for arenas

Tracing garbage collection for arenas

Tracing garbage collection in systems programming languages like C++, Rust, and Ada is compared to reference counting. A simplified tracing garbage collection approach inspired by Mark-and-Sweep is proposed for languages like Zig or Odin.

Atomic Operations Composition in Go

Atomic Operations Composition in Go

The article discusses atomic operations composition in Go, crucial for predictable results in concurrent programming without locks. Examples show both reliable and unpredictable outcomes, cautioning about atomics' limitations compared to mutexes.

CPS in Hoot

CPS in Hoot

The Hoot Scheme-to-Wasm compiler uses CPS transformation to handle push calls in WebAssembly. Strategies like generic slicing and CPS transformation are explored, enabling features like Fibers and promise integration. Performance impact is under evaluation.

Copying collectors with block-structured heaps are unreliable

Copying collectors with block-structured heaps are unreliable

Copying collectors with block-structured heaps pose reliability challenges in garbage collection. Unpredictable post-collection fragmentation arises from non-commutative evacuation, exacerbated by multiple mutator threads. Mitigating this requires larger heap memory, emphasizing virtual memory and growable heaps for improved reliability.

Love, Death and PostgreSQL Triggers (2022)

Love, Death and PostgreSQL Triggers (2022)

The GitGuardian engineering team replaced PostgreSQL triggers with Celery tasks to address performance issues. Triggers caused unexpected behavior and complexities, leading to a shift towards simpler asynchronous computation methods for better performance.

Link Icon 1 comments