{
  "id": 12966335,
  "title": "The Performance Cost of RwLock in Our Read-Heavy Workload",
  "url": "https://urgent.news/2026/10/08/the-performance-cost-of-rwlock-in-our-read-heavy-workload",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-08T11:58:52.000Z",
  "source": {
    "name": "Lobsters",
    "slug": "lobsters",
    "url": "https://pranitha.dev/posts/rwlock-vs-lockfree/"
  },
  "original_language": "en",
  "account": "In a recent interview, the speaker discussed their experience using different data structures for a read-heavy workload. They mentioned that people often claim to use lock-free structures, but the benefits depend on factors like how often data is updated and the read pattern. The speaker provided a simplified example of a workload with a relational data model, where reads traversed all elements in a Block and performed computations. The service was read-heavy, with a single writer thread continuously updating data in Store.\n\nTwo approaches were considered: using an RwLock or storing an immutable Metrics value behind an atomic pointer. The speaker chose parking_lot for the RwLock implementation due to its synchronous computation and avoidance of yielding while acquiring every item. Alternatively, the Metrics value could have been stored behind an atomic pointer, with readers loading the current pointer and the writer replacing it with a newly allocated value. The defer_destroy marker ensured that old values would be freed later when all active readers had finished.\n\nThe benchmark results showed that the lock-free version had significantly higher read throughput and lower read latency compared to RwLock. However, at first glance, it might seem like the lower throughput for RwLock is due to read-write contention. But when the writer was turned off, the read throughput barely changed. The parking_lot implementation internally uses AtomicUsize to track the number of active readers, with atomic compare-and-exchange operations for acquiring and releasing locks. For a single entry in Block, a simplified read involved 16,384 read lock acquisitions and 16,384 lock releases. This resulted in approximately 524 million updates per second performed by RwLock internally, despite the atomic operations being more expensive than ordinary reads and writes.",
  "summary": null,
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}