HN Hall of Fame Weekly email

I've been writing ring buffers wrong all these years

www.snellman.net Essays & writing Essays & articles Computer science Candidate
Screenshot of www.snellman.net captured 2026-07-20
Page preview · captured 2026-07-20

Resurfaced independently across 2 calendar years, with breakout response in 2 of them.

submissions
3
submitters
3
observed span
2016–2025
peak thread · 167 comments
361 pts
latest 20+ return · 2025-12-16
164 pts

Submission timeline

2007–2026

One slot for every year since HN launched. Height is that year's peak points; orange marks a 100+ point or 50+ comment breakout. Select a bar to open its strongest thread.

First comments on top threads

HN comment order

This is of course not a new invention. The earliest instance I could find with a bit of searching was from 2004, with Andrew Morton mentioning in it a code review so casually that it seems to have been a well established trick. But the vast majority of implementations I looked at do not do this. I was doing this in 1992 so it's at least 12 years older than the 2004 implementation. I suspect it was being done long…

It is not just a way of writing ring buffers. It's a way of implementing concurrent non-blocking single-reader single-writer atomic ring buffers with only atomic load and store (and memory barriers). The author says that non-power-of-two is not possible, but I'm pretty sure it is if you use a conditional instead of integer modulus. I first learnt of this technique from Phil Burk, we've been using it in PortAudio forever. The technique is also widely known in FPGA/hardware circles, see…

The first top-level comment from each of the four biggest threads, in HN’s own order. Excerpts are shortened; open a comment for full context.

Breakout years
2

100+ points or 50+ comments

Total points
529

reference only — not used in Hall rules or ranking

Total comments
233

reference only — not used in Hall rules or ranking

Every submission

DateTitle as submittedByPointsComments
2016-12-13I've been writing ring buffers wrong all these yearsingve40
2016-12-14I've been writing ring buffers wrong all these yearsFirst breakout · Best threadb3h3moth361167
2025-12-16I've been writing ring buffers wrong all these years (2016)Latest 20+ point returnflaghacker16466