Skip to content

Conversation

@maxkozlovsky
Copy link
Contributor

Use boost::container::small_vector to allocate up to 64 completion entries on the stack, avoiding heap allocation in the common case.

Fix bug where io_uring_sq_ready() was incorrectly used instead of io_uring_cq_ready() when reserving capacity for the completions vector. The code processes completion queue entries, not submission queue entries, so it should check completion queue readiness.

  • Add COMPLETIONS_STACK_CAPACITY constant (64) for stack capacity
  • Replace std::vector with small_vector for stack allocation
  • Fix io_uring_sq_ready() → io_uring_cq_ready() in reserve() call

This code was generated using Claude Sonnet 4.5

Use boost::container::small_vector to allocate up to 64 completion
entries on the stack, avoiding heap allocation in the common case.

Fix bug where io_uring_sq_ready() was incorrectly used instead of
io_uring_cq_ready() when reserving capacity for the completions vector.
The code processes completion queue entries, not submission queue entries,
so it should check completion queue readiness.

- Add COMPLETIONS_STACK_CAPACITY constant (64) for stack capacity
- Replace std::vector with small_vector for stack allocation
- Fix io_uring_sq_ready() → io_uring_cq_ready() in reserve() call

This code was generated using Claude Sonnet 4.5
Copilot AI review requested due to automatic review settings October 27, 2025 23:03
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR optimizes memory allocation in the io_uring polling function and fixes a critical bug in completion queue size estimation. The changes improve performance by avoiding heap allocations for common cases while correcting the logic for determining the number of pending completions.

  • Replace heap-allocated vector with stack-allocated small_vector for up to 64 completion entries
  • Fix incorrect use of submission queue ready count instead of completion queue ready count
  • Add COMPLETIONS_STACK_CAPACITY constant for maintainability

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants