You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by "merlimat (via GitHub)" <gi...@apache.org> on 2026/07/10 02:11:19 UTC
[PR] Add spin-wait hint to BlockingMpscQueue producer-side busy loops [bookkeeper]
merlimat opened a new pull request, #4831:
URL: https://github.com/apache/bookkeeper/pull/4831
### Motivation
`BlockingMpscQueue.put()` and the timed `offer()` busy-spin on `relaxedOffer()` in a bare loop, with no pause hint. When the queue fills up under back-pressure (e.g. the journal queue with `enableBusyWait=true`), every blocked producer thread pins a core spinning at full speed — competing for CPU with the very consumer thread that needs to run to drain the queue.
The consumer side (`take()` / `poll()`) already idles through `WAIT_STRATEGY.idle()`, which uses the `Thread.onSpinWait()` intrinsic (via `BusyWait.onSpinWait()`). The producer side was missing the same treatment.
### Changes
Apply the same wait strategy in the `put()` and `offer(timeout)` spin loops. The producers still busy-spin (by design for this queue), but with the spin-wait hint that reduces power/pipeline contention and lets the sibling hyperthread — often the consumer — make progress.
Verified with `BlockingMpscQueueTest` (4/4 pass) and module checkstyle.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@bookkeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add spin-wait hint to BlockingMpscQueue producer-side busy loops [bookkeeper]
Posted by "merlimat (via GitHub)" <gi...@apache.org>.
merlimat merged PR #4831:
URL: https://github.com/apache/bookkeeper/pull/4831
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@bookkeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org