BRC's Superior Single-Thread Efficiency vs. Atomic RC

Biased Reference Counting (BRC) significantly reduces single-thread overhead compared to a plain atomic reference counting approach, which historically made Python 20% slower in experiments to remove the GIL.

The top 3

  1. BRC's Dual-Counter: Non-Atomic Local RefCounts: Biased Reference Counting (BRC) splits object reference counts into a non-atomic `ob_ref_local` for the creating thread and an atomic `ob_ref_shared` for other threads, enabling faster updates for the most common single-threaded operations.
  2. Atomic RC's 20% Single-Thread Slowdown Pre-BRC: Prior to BRC, initial attempts to remove Python's GIL by using pure atomic reference counting for all object operations resulted in a significant ~20% single-threaded performance slowdown, even without multi-thread contention.
  3. BRC's 'Owning Thread' Optimizes Common Case: BRC's enhanced single-thread efficiency stems from the insight that most Python objects are predominantly accessed by the thread that created them, allowing for non-atomic, faster reference count updates in the majority of scenarios.

Sources

Open the full topic