Skip to content

Make the MPMC Queue use a single slot access counter and fix index wrapping deadlock#31

Merged
DNedic merged 2 commits into
mainfrom
mpmc_queue_slot_single_access_counter
Feb 23, 2026
Merged

Make the MPMC Queue use a single slot access counter and fix index wrapping deadlock#31
DNedic merged 2 commits into
mainfrom
mpmc_queue_slot_single_access_counter

Conversation

@DNedic
Copy link
Copy Markdown
Owner

@DNedic DNedic commented Feb 22, 2026

Description

  1. This moves to a design that encodes the push and pop count of a slot to one counter, increasing performance.
    The fullness of the slot is encoded in the parity, while the "our turn" mechanic still exists through the divison by 2.
  2. We map the access count to the same range as revolution count, making sure index overflows do not cause a deadlock.
    This requires a limitation upon the queue size, it now must be a power of 2 and this is a breaking change.

… counter

This moves to a design that encodes the push and pop count of a slot to
one counter, increasing performance.
The fullness of the slot is encoded in the parity, while the "our turn"
mechanic still exists through the divison by 2.
@DNedic
Copy link
Copy Markdown
Owner Author

DNedic commented Feb 22, 2026

@qqqlab PTAL

This makes the access count and the revolution count in the same range,
ensuring index wrapping does not cause a deadlock for slot acquisition.

A consequence of this is that buffer sizes now must be powers of 2.
@DNedic DNedic changed the title performance(mpmc queue): Make the MPMC Queue use a single slot access counter Make the MPMC Queue use a single slot access counter and fix index wrapping deadlock Feb 23, 2026
@DNedic DNedic merged commit fcb1f54 into main Feb 23, 2026
1 check passed
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.

1 participant