Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drastically reduce allocations in ring buffer implementation #64

Merged
merged 3 commits into from
Nov 20, 2021

Commits on Oct 5, 2021

  1. reuse cap of s.b slice by shifting its elements to the left on writes

    Before this change `Append` was allocating a new slice every time because len(s.b) == cap(s.b). In my testings len(s.b) is usually small enough (<= 50, sometimes spikes to 200) even in high-write benchmarks such as BenchmarkSendRecvLarge, often near 0, so copy should not be too expensive. It is also efficient when write rate is roughly equal to read rate.
    pymq committed Oct 5, 2021
    Configuration menu
    Copy the full SHA
    4f550fc View commit details
    Browse the repository at this point in the history

Commits on Oct 18, 2021

  1. shift buffer only if at least ~1/4 of slice is empty to prevent extre…

    …me case when we shift slice by one every time
    pymq committed Oct 18, 2021
    Configuration menu
    Copy the full SHA
    f7fe806 View commit details
    Browse the repository at this point in the history

Commits on Oct 29, 2021

  1. add more doc to segmentedBuffer

    pymq committed Oct 29, 2021
    Configuration menu
    Copy the full SHA
    453784a View commit details
    Browse the repository at this point in the history