Python Agentic Systems Lab Published: 2026-10-26

False Sharing: Runtime Invariants and Algorithmic Bounds in Python

Abstract

We investigate the counter-intuitive performance gap between a single-mutex counter and a lock-free sharded counter in CPython. The sharded design, popular in high-throughput systems, distributes increments across independent cells to avoid global contention. However, on a modern Research Compute Cluster processor, the unpadded sharded counter incurs significant false sharing, leading to a mean latency of 2 556 555 µs and a throughput of 391 ops/s, whereas the mutex counter achieves a mean latency of 1 200 000 µs and 800 ops/s. We formalize the linearizability invariant of the sharded counter, prove its correctness, and empirically demonstrate that padding each cell to a 64-byte boundary eliminates the slowdown. The study highlights the subtle interplay between Python's GIL, memory layout, and thread scheduling.

Manuscript Page 1 Preview
False Sharing: Runtime Invariants and Algorithmic Bounds in Python Preview
Research Preprint & Verification Disclosure

Manuscript Attribution: This manuscript is an empirical research preprint published by the Mateus Yonathan Agentic Autonomous Lab adhering to academic two-column preprint conventions.

Algorithmic Provenance: Algorithmic complexity bounds, execution profiles, and memory models reflect verified standard-library reference implementations across our polyglot systems repositories.

Limitation of Liability & Scholarly Purpose: Disseminated solely for scholarly inquiry, peer discussion, and reproducible empirical comparison. It does not constitute formal peer-reviewed accreditation. Any reliance upon the mathematical proofs or complexity bounds herein is strictly at the reader's own legal and technical risk.

Bibliographic Citation (BibTeX)
@article{yonathan2026_2026_10_26_false_sharing_why_your_lock_free_co,
  title={False Sharing: Runtime Invariants and Algorithmic Bounds in Python},
  author={Yonathan, Mateus},
  journal={Polyglot Systems Lab Agentic Research Preprints},
  year={2026},
  publisher={Polyglot Systems Lab},
  url={https://myonathanlinkedin.github.io/papers/2026-10-26_false_sharing_why_your_lock_free_co/},
  howpublished={\url{https://raw.githubusercontent.com/myonathanlinkedin/mini-papers/main/papers/2026-10-26_false_sharing_why_your_lock_free_co/2026-10-26_false_sharing_why_your_lock_free_co.pdf}}
}