Skip to content

Isolate the blocking-queue futexes on their own cache lines#109

Open
vadimskipin wants to merge 1 commit into
mainfrom
vskipin/fix-blocking-queue
Open

Isolate the blocking-queue futexes on their own cache lines#109
vadimskipin wants to merge 1 commit into
mainfrom
vskipin/fix-blocking-queue

Conversation

@vadimskipin

Copy link
Copy Markdown
Collaborator

FiberBlockingQueue laid spaceAvailable and itemAvailable on the line holding BoundedQueue's dequeuePos, so every producer's itemAvailable post invalidated the consumer's dequeue cursor and every dequeue invalidated the line producers read and post at enqueue. Aligning each futex to its own line measured +14% on a 100-producer, one-consumer enqueue-heavy workload.

FiberBlockingQueue laid spaceAvailable and itemAvailable on the line
holding BoundedQueue's dequeuePos, so every producer's itemAvailable
post invalidated the consumer's dequeue cursor and every dequeue
invalidated the line producers read and post at enqueue. Aligning each
futex to its own line measured +14% on a 100-producer, one-consumer
enqueue-heavy workload.
@praktika-gh

praktika-gh Bot commented Jul 24, 2026

Copy link
Copy Markdown

Workflow [PR], commit [2312fcb]

Summary:

job_name test_name status info comment
Test ARM (release) FAIL
Bench FAIL

Copilot AI left a comment

Copy link
Copy Markdown

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 improves FiberBlockingQueue throughput under high producer contention by reducing false sharing: the spaceAvailable and itemAvailable futexes are moved onto separate cache lines so producer/consumer signaling doesn’t constantly invalidate the queue cursor cache lines.

Changes:

  • Cache-line align spaceAvailable futex to reduce interference with the consumer-side dequeue cursor.
  • Cache-line align itemAvailable futex so producer posts don’t invalidate consumer hot data.
  • Add inline documentation explaining the intended cache-line ownership pattern.

💡 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.

2 participants