Ring buffers are underrated
A fixed-size circular queue solves most "I need a small log" problems without an allocator in the hot path. Notes on head/tail arithmetic, power-of-two masks, and the one off-by-one everyone hits.
A fixed-size circular queue solves most "I need a small log" problems without an allocator in the hot path. Notes on head/tail arithmetic, power-of-two masks, and the one off-by-one everyone hits.
Naive accumulation drifts. Kahan summation fixes most of it for a few extra instructions. When pairwise summation is the better trade, with numbers.
Readers stop blocking writers, checkpoints become the thing to tune, and the two settings that matter for a single-process service.
Why p99 lies when traffic is bursty, and a small histogram type that replaces averages in every service I run.