Isolate the blocking-queue futexes on their own cache lines#109
Open
vadimskipin wants to merge 1 commit into
Open
Isolate the blocking-queue futexes on their own cache lines#109vadimskipin wants to merge 1 commit into
vadimskipin wants to merge 1 commit into
Conversation
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.
|
Workflow [PR], commit [2312fcb] Summary: ⏳
|
There was a problem hiding this comment.
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
spaceAvailablefutex to reduce interference with the consumer-side dequeue cursor. - Cache-line align
itemAvailablefutex 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.