Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 8d 09h 54m 21s8 days 9 hours 54 minutes 21 seconds.
Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 8d 09h 54m 21s8 days 9 hours 54 minutes 21 seconds.

Sign in to watch this lesson
Performance of Concurrent Code · 3:55
Why an atomic counter shared by many threads scales so badly: even a relaxed fetch_add is a read-modify-write that needs the cache line exclusively, so the line ping-pongs between cores. Measured on an Apple M3 from 1 to 8 threads, one shared counter's total throughput fell while padded per-thread counters scaled about sevenfold; one handoff of a line costs a few tens of nanoseconds, and mutexes, even reader-only shared_mutexes, suffer the same way.