RC vs. Tracing GC: Throughput vs. Latency

Python's reference counting offers predictable object deallocation but incurs constant CPU overhead, leading to typically lower throughput compared to tracing garbage collectors (like those in Java or Go), which achieve higher throughput with occasional, unpredictable 'stop-the-world' pauses.

The top 3

  1. Tracing GC's 'Stop-the-World' Latency: Tracing garbage collectors, like those in Java and Go, can introduce 'stop-the-world' pauses, halting all application threads for milliseconds to seconds, which significantly impacts real-time application latency.
  2. Reference Counting: Predictable but Costly Overhead: Reference counting provides deterministic, immediate memory reclamation but incurs constant `INCREF`/`DECREF` operations on pointer assignments, distributing overhead throughout execution and potentially leading to lower overall throughput due to memory synchronization costs.
  3. Hybrid GCs: Combining RC & Tracing Benefits: Many modern runtimes, including Swift and Python, employ hybrid garbage collection, using reference counting for eager deallocation and combining it with a tracing collector to handle cyclic references and optimize overall throughput.

Sources

Open the full topic