Skip to content

Wrap-around problem #105

@walterhackin

Description

@walterhackin

@MengRao,

The current wrap-around mechanism in the SPSC queue is implemented by resetting the write index to zero when there isn’t sufficient space at the end of the buffer—even though space might be available at the beginning. However, the approach of using a single contiguous static array forces the allocation of a very large continuous block of memory to achieve high capacity. This design not only wastes memory but also may be inefficient in managing the wrap-around, especially under high log generation rates.

Suggested Improvements:
1. Implement a segmented or ring-of-buffers approach to allow more flexible wrap-around without the need for a huge continuous memory block.
2. Optimize the logic to better recycle freed segments when the consumer advances the read pointer, ensuring that wrap-around is efficient and minimizes wasted space.

Sometimes it feels like poll() is clearing SPSC queue too long, so wrap-around just rewrite existing logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions