4 ms·
> Contended writes from multiple threads on the same memory location are a lot harder for the CPU's cache coherence protocol to handle FWIW, those are the same
by monocasa 3y ago
> Contended writes from multiple threads on the same memory location are a lot harder for the CPU's cache coherence protocol to handle
FWIW, those are the same location according to most cache coherency protocols, since cache coherency generally works on the cache line level. You'd want to split the two contexts to their own cache lines.
- stefanha 3y agoAnother cache optimization trick some ring-buffer implementations use is to keep a shadow copy of the read or write pointer to avoid frequently fetching the other context's cache line. The latest version of the read pointer is only needed when the writer catches up with their shadow copy and vice versa.
- anonymousDan 3y agoYes this is absolutely crucial for performance.