]> git.kaiwu.me - haproxy.git/commit
MINOR: add an MPSC ring buffer implementation
authorMaxime Henrion <mhenrion@haproxy.com>
Mon, 23 Feb 2026 22:19:15 +0000 (17:19 -0500)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 30 Apr 2026 13:33:07 +0000 (15:33 +0200)
commit57d8f0621510239deb50b28c8d44ec1aab59d6bf
treeba5582ab80d5910472f065ad261ef6612d72cb4f
parent66b00543c5d7b1024fd6dea8155350793676ec8e
MINOR: add an MPSC ring buffer implementation

This is to be used in the QUIC code, where the multiple producers are
the listener threads, and the single consumer is the datagram handler
thread. Entries are variable-length with a size header, and are kept
contiguous in the buffer, so padding is inserted at the end when an
entry would otherwise wrap around. The size field is overloaded to also
mark padding (-1) and entries that are still free or not yet ready for
reads (0).

Headers and payloads are aligned on 8 bytes. Aligning on 16 bytes might
be beneficial on some architectures to let memcpy() use 128-bit SIMD
instructions.

The head and tail offsets are 64-bit unsigned integers, making ABA
issues from integer overflow impossible on current or near-future
hardware. Reservation uses a CAS rather than FAA because of the need to
insert padding to keep entries contiguous.
Makefile
include/haproxy/mpring.h [new file with mode: 0644]
src/mpring.c [new file with mode: 0644]