circbuf icon indicating copy to clipboard operation
circbuf copied to clipboard

Add various optimizations

Open lmbarros opened this issue 4 years ago • 1 comments

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.

lmbarros avatar May 17 '21 18:05 lmbarros

Very nice PR. Thanks!

likebike avatar Jul 24 '21 23:07 likebike