MEDIUM: ring: align the head and tail fields in the ring_storage structure

We really want to let the readers and writers act on different areas, so
we want to have the tail and the head on separate cache lines, themselves
separate from the rest of the ring. Doing so improves the performance from
2.15 to 2.35M msg/s at 48 threads on a 24-core EPYC.

This increases the header space from 32 to 192 bytes when threads are
enabled. But since we already have the header size available in the file,
haring remains able to detect the aligned vs unaligned formats and call
dump_v2a() when aligned is detected.
This commit is contained in:
Willy Tarreau
2024-02-28 12:04:22 +01:00
parent bf3dead20c
commit dd8ea5d928
2 changed files with 44 additions and 2 deletions

View File

@@ -107,8 +107,11 @@
struct ring_storage {
size_t size; // storage size
size_t rsvd; // header length (used for file-backed maps)
THREAD_PAD(64 - 2 * sizeof(size_t));
size_t tail; // storage tail
THREAD_PAD(64 - sizeof(size_t));
size_t head; // storage head
THREAD_PAD(64 - sizeof(size_t));
char area[0]; // storage area begins immediately here
};