concurrent-programs
concurrent-programs copied to clipboard
Pack gap bit into size field's LSB
Reduce ringbuf_element_t from 8 bytes to 4 bytes by encoding the gap flag into the LSB of the size field.
Since all payload sizes are padded to 8 bytes, the lower 3 bits of size are always zero, making it safe to reuse bit 0.
This shrinks the per-element header.
Summary by cubic
Packed the gap flag into the size field’s LSB, shrinking ringbuf_element_t from 8 bytes to 4 bytes. This reduces per-element overhead and can improve cache locality.
-
Refactors
- Encoded gap via GAP_MASK (1) and masked size via SIZE_MASK; sizes remain 8-byte padded.
- Updated read/write paths to set/test the gap bit and to mask size; fixed read_advance to use masked size.
- Changed posix_memalign alignment to 8 bytes.
-
Migration
- Shared-memory layout changed; not compatible with buffers from previous versions.
- Recreate ring buffers and roll out readers/writers together.