circbuf
circbuf copied to clipboard
Add various optimizations
This PR contains some optimizations that we use (or plan to start using soon) in production at belena.io. To summarize, these are the main changes included here:
- Add methods to efficiently read and write a single byte at a time
- Avoid allocating memory on
Bytes()(at the expense of having a second, pre-allocated buffer) - Add a faster code path for buffers whose size is a power-of-two.
Check the individual commit messages for details.
For our use case (in which we use a circular buffer on a tight loop), each of these optimizations brought considerable performance improvements.
Very nice PR. Thanks!