Re:Yes, You Have Been Writing SPSC Queues Wrong
by danbruc on Thursday December 15, 2016 @04:56PM
(#13188842)
Does this actually help? Both, producer and consumer, have to read both pointers on every operation to determine whether the buffer is full respectively empty even though each only updates one of the pointers making the buffer thread-safe. So if there is actually an advantage to not having both pointers in the same cache line, then it is not totally obvious, at least to me.
[ Parent
| on HN ]
Re:Yes, You Have Been Writing SPSC Queues Wrong
by gpderetta on Thursday December 15, 2016 @05:15PM
(#13189038)
The usual trick is for each side to cache the last value of the other side index so you only need to refresh the remote value when you "catch up".
Even without caching, padding is still a win as the shared to exclusive transition is less expensive than a request for ownership of an invalidated cache line (aka "single writer principle")