This is an automated email from the ASF dual-hosted git repository.
merlimat pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/master by this push:
new f1d7cc16f3 Add spin-wait hint to BlockingMpscQueue producer-side busy
loops (#4831)
f1d7cc16f3 is described below
commit f1d7cc16f3ef5ca2644fd516a0dea7fe4c2a1fdb
Author: Matteo Merli <[email protected]>
AuthorDate: Tue Jul 14 08:25:29 2026 -0700
Add spin-wait hint to BlockingMpscQueue producer-side busy loops (#4831)
---
.../org/apache/bookkeeper/common/collections/BlockingMpscQueue.java | 6 ++++++
1 file changed, 6 insertions(+)
diff --git
a/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/collections/BlockingMpscQueue.java
b/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/collections/BlockingMpscQueue.java
index 56d9627e84..d19eb96243 100644
---
a/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/collections/BlockingMpscQueue.java
+++
b/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/collections/BlockingMpscQueue.java
@@ -34,11 +34,14 @@ public class BlockingMpscQueue<T> extends MpscArrayQueue<T>
implements BlockingQ
@Override
public void put(T e) throws InterruptedException {
+ int idleCounter = 0;
while (!this.relaxedOffer(e)) {
// Do busy-spin loop
if (Thread.interrupted()) {
throw new InterruptedException();
}
+
+ idleCounter = WAIT_STRATEGY.idle(idleCounter);
}
}
@@ -46,6 +49,7 @@ public class BlockingMpscQueue<T> extends MpscArrayQueue<T>
implements BlockingQ
public boolean offer(T e, long timeout, TimeUnit unit) throws
InterruptedException {
long absoluteEndTime = System.nanoTime() + unit.toNanos(timeout);
+ int idleCounter = 0;
while (!this.relaxedOffer(e)) {
// Do busy-spin loop
@@ -56,6 +60,8 @@ public class BlockingMpscQueue<T> extends MpscArrayQueue<T>
implements BlockingQ
if (Thread.interrupted()) {
throw new InterruptedException();
}
+
+ idleCounter = WAIT_STRATEGY.idle(idleCounter);
}
return true;