▶ Interactive Lab

Lock Contention

N threads compete for one mutex; see throughput collapse with contention.

Advertisement
N threads, one mutex. Throughput collapses when threads spend more time waiting than working.

What you're seeing

Critical section is serialized — only one thread inside at a time. Throughput plateau: 1 / critical_section_duration. More threads past that point just add wait time.

This is why coarse locks kill scalability. Split into finer locks (per-shard, per-key), use read-write locks for read-heavy work, or use lock-free data structures for hottest paths.

★ KEY TAKEAWAY
N threads + 1 mutex = throughput plateau at 1 / critical_section_time. Past that, more threads only add wait.
▶ WHAT TO TRY
  • Slide Threads up — watch throughput plateau.
  • Reduce Crit section — throughput goes up proportionally.
  • This is why fine-grained locks beat coarse locks under load.