Use fixed-size ring buffer for event storage

The slice-based queue slides a window forward on dequeue and appends on enqueue. This works, but periodically the window reaches the end of the backing array's capacity, forcing append to allocate a new array and copy all events.

The ring buffer allocates once at creation and avoids these periodic O(n) copies. Also removes the redundant copy on Get — events are already copied on Add, so Get can hand them out directly.

Builds on top of !259 (merged), refs https://gitlab.com/gitlab-org/architecture/usage-billing/design-doc/-/work_items/36.

Edited by Igor

Merge request reports

Loading