
"Tim Blechmann" <tim@klingt.org> wrote in message news:4B2E4492.3050201@klingt.org...
Well, IMO, it should perform better because the producer and consumer are not thrashing each other wrt the head and tail indexes.
the performance difference is almost the same.
Interesting. Thanks for profiling it. Have you tried aligning everything on cache line boundaries? I would try to ensure that the buffer is aligned and padded along with the head and tail variables. For 64-byte cache line and 32-bit pointers you could do: struct ringbuffer { void* m_buffer[1024]; // multiple of a cache-line uint32_t m_head; char pad[60]; uint32_t m_tail; char pad[60]; }; Then ensure that `ringbuffer' structs are actually aligned on a cache line boundary. unsigned char buffer[sizeof(struct ringbuffer) + 63]; struct ringbuffer* rb = ALIGN(buffer, 64); Now I know for sure that `rb' is isolated and won't experience/cause false sharing with other parts of the application.