<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/read-locks-are-not-your-friends-rfms5918e" -->

---
title: Read Locks Are Not Your Friends | daily.dev
description: A hands-on investigation into why RwLock performed ~5× worse than Mutex for a read-heavy LRU tensor cache in Rust. The root cause is cache-line ping-pong: even...
canonical: https://daily.dev/posts/read-locks-are-not-your-friends-rfms5918e
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Read Locks Are Not Your Friends | daily.dev
og:description: A hands-on investigation into why RwLock performed ~5× worse than Mutex for a read-heavy LRU tensor cache in Rust. The root cause is cache-line ping-pong: even...
og:url: https://daily.dev/posts/read-locks-are-not-your-friends-rfms5918e
og:image: https://api.daily.dev/og/posts/rFMs5918e.png
og:image:alt: Read Locks Are Not Your Friends
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Read Locks Are Not Your Friends

**[Lobsters](https://daily.dev/sources/lobsters)** · 5 min read · 0 upvotes · 0 comments

## Summary

A hands-on investigation into why RwLock performed ~5× worse than Mutex for a read-heavy LRU tensor cache in Rust. The root cause is cache-line ping-pong: even a read lock requires an atomic increment of an internal reader counter, causing every core to fight for exclusive ownership of that cache line. For very short critical sections (nanosecond-scale hashmap lookups), this contention overhead dominates actual work time. Key takeaways: prefer Mutex for tiny critical sections, use sharding to reduce contention, and always profile with tools like perf or flamegraph before assuming RwLock is faster for read-heavy workloads.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://eventual-consistency.vercel.app/posts/write-locks-faster>

## Similar posts on daily.dev

- [Spinlocks Considered Harmful \(2020\)](https://daily.dev/posts/spinlocks-considered-harmful-2020--xqfzzgjdk) · Lobsters · 0 upvotes · 0 comments
- [Read-Copy-Update \(RCU\): The Secret to Lock-Free Performance](https://daily.dev/posts/read-copy-update-rcu-the-secret-to-lock-free-performance-ekig5oxyy) · InfoQ · 0 upvotes · 0 comments
- [Rust Prevents Data Races, Not Race Conditions](https://daily.dev/posts/rust-prevents-data-races-not-race-conditions-fjfi1lvd3) · corrode · 9 upvotes · 0 comments
- [Spinning around: Please don't\!](https://daily.dev/posts/spinning-around-please-don-t--cekmueark) · Hacker News · 0 upvotes · 0 comments
- [ReadWriteLock allows wrong-thread write release and stray read-release counter corruption](https://daily.dev/posts/readwritelock-allows-wrong-thread-write-release-and-stray-read-release-counter-corruption-nsztjc8hx) · RUBYLAND · 0 upvotes · 0 comments

---

Tags: [#performance](https://daily.dev/tags/performance), [#rust](https://daily.dev/tags/rust)

[View this post on daily.dev](https://daily.dev/posts/read-locks-are-not-your-friends-rfms5918e)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Read Locks Are Not Your Friends","url":"https://daily.dev/posts/read-locks-are-not-your-friends-rfms5918e","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/read-locks-are-not-your-friends-rfms5918e"},"datePublished":"2026-02-23T05:56:29.122Z","dateModified":"2026-02-23T05:56:49.973Z","description":"A hands-on investigation into why RwLock performed ~5× worse than Mutex for a read-heavy LRU tensor cache in Rust. The root cause is cache-line ping-pong: even...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/73a4a0ffa6b2733bbdaaee672cb108d5?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/73a4a0ffa6b2733bbdaaee672cb108d5?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Lobsters","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Lobsters","logo":"https://media.daily.dev/image/upload/s--tl8v_Fku--/f_auto,t_logo/v1698841318/logos/lobste.jpg","url":"https://daily.dev/sources/lobsters"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/read-locks-are-not-your-friends-rfms5918e","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"performance,rust","timeRequired":"PT5M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Lobsters","item":"https://daily.dev/sources/lobsters"},{"@type":"ListItem","position":3,"name":"Read Locks Are Not Your Friends"}]}
```

