I had a bunch of LLM credits left at the end of the month and had Claude Opus 4.5 do a code review and refactor until the credits burned out.
One of the suggestions was to replace our spinlock queue implementation with a github project specifically for ARM architecture that is lock free.
Since the queue has always been a source of headaches, I gave it a try. It works great in stress testing. Upon reviewing the code I noticed it didn’t use the github project, but instead made something custom. It looks okay to me, but I wanted a stress test.
| Category | Test | What it verifies |
|---|---|---|
| Unit | test_init |
Struct fields, empty/full/level/free after init |
test_add_remove_single |
Basic enqueue/dequeue/peek, empty-queue rejection | |
test_fill_and_drain |
Fill to capacity−1, full rejection, FIFO drain order | |
test_wraparound |
20 rounds of fill+drain through the wrap boundary | |
test_blocking_ops |
Blocking add/remove/peek (single-threaded, no deadlock) | |
| Stress | test_stress_small_queue |
2M bytes through 16-byte queue, 2 threads (blocking API) |
test_stress_large_queue |
10M bytes through 4096-byte queue, 2 threads | |
test_stress_try_api |
5M bytes through 32-byte queue using try_ polling API | |
test_stress_peek_remove |
2M peek+remove pairs — peek/remove consistency under contention | |
test_stress_level_invariant |
581M samples verifying level + free == capacity−1 while active |
|
| Bench | test_throughput_benchmark |
20M bytes → 13.6 M ops/s throughput measurement |
So, I had the LLM build a test rig for the queue to stress test it (available in /tests/).
It’s not very much code, and it looks okay to me. I did a lot of terminal and bpio real world tests, so I’m going to push it to main ![]()