Developer reverts 'faster' circular buffer after CPU usage jumps tenfold on Raspberry Pi
A developer building Kalinka Player, a music player for Raspberry Pi, replaced std::deque with boost::circular_buffer expecting performance gains, only to see playback CPU usage spike from 1–3% to 20–30%. The switch was made on September 11, 2024, after a microbenchmark showed circular_buffer outperforming std::deque by 2–3x on producer/consumer workloads. The real-world slowdown stemmed from how audio data was actually moved — large ~16 KB byte-stream chunks rather than the small fixed-size records used in the benchmark, which negated circular buffer's theoretical advantages. An attempted fix using the more efficient erase_begin() method offered only partial relief, and the developer ultimately reverted to std::deque a week later. The case highlights how microbenchmarks can mislead when their workload assumptions don't match production access patterns.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in