Boost logo

Boost :

Subject: Re: [boost] [lockfree::fifo] Review
From: Chris M. Thomasson (cristom_at_[hidden])
Date: 2009-12-20 10:57:29

"Tim Blechmann" <tim_at_[hidden]> wrote in message

> > 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

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.

Boost list run by bdawes at, gregod at, cpdaniel at, john at