Hacker News new | ask | show | jobs
by staticassertion 1447 days ago
If there's no contention there's no more synchronization compared to any other cache lines afaik.
1 comments

Atamic operations have some overhead.
The overhead of atomics is almost (if not entirely?) exclusively with regards to managing the caches in the CPU. Otherwise they're just normal bytes. Your CPU already has to do some cache management with regular bytes, so an atomic is only worse if there's contention (because that forces a flush).

The worst case for an atomic write is two additional cache line flushes, iirc.