@@ -69,6 +69,16 @@ public class SingleChronicleQueueBuilder extends SelfDescribingMarshallable impl
6969 private static final Constructor <?> ENTERPRISE_QUEUE_CONSTRUCTOR ;
7070 private static final WireStoreFactory storeFactory = SingleChronicleQueueBuilder ::createStore ;
7171 private static final Supplier <TimingPauser > TIMING_PAUSER_SUPPLIER = DefaultPauserSupplier .INSTANCE ;
72+ /**
73+ * Maximum park duration (ms) for the writeLock/appendLock pauser.
74+ */
75+ private static final int WRITE_LOCK_PAUSER_MAX_MS = Jvm .getInteger ("chronicle.queue.writeLockPauserMaxMs" , 5 );
76+ /**
77+ * Pauser supplier used by {@link #writeLock()} / {@link #appendLock()}. Uses
78+ * {@link Pauser#balancedUpToMillis(int)}
79+ */
80+ private static final Supplier <TimingPauser > WRITE_LOCK_PAUSER_SUPPLIER =
81+ () -> Pauser .balancedUpToMillis (WRITE_LOCK_PAUSER_MAX_MS );
7282
7383 static {
7484 CLASS_ALIASES .addAlias (WireType .class );
@@ -711,7 +721,9 @@ public SingleChronicleQueueBuilder createAppenderConditionCreator(Function<Singl
711721 */
712722 @ NotNull
713723 WriteLock writeLock () {
714- return readOnly () ? new ReadOnlyWriteLock () : new TableStoreWriteLock (metaStore , pauserSupplier (), timeoutMS () * 3 / 2 );
724+ // Use a balanced pauser (busy -> yield -> parkNanos, capped at ~5ms)
725+ return readOnly () ? new ReadOnlyWriteLock ()
726+ : new TableStoreWriteLock (metaStore , WRITE_LOCK_PAUSER_SUPPLIER , timeoutMS () * 3 / 2 );
715727 }
716728
717729 /**
@@ -1594,7 +1606,10 @@ public SingleChronicleQueueBuilder setAllNullFields(@Nullable SingleChronicleQue
15941606 * @return the append lock for the queue
15951607 */
15961608 public WriteLock appendLock () {
1597- return readOnly () ? WriteLock .NO_OP : new AppendLock (metaStore , pauserSupplier (), timeoutMS () * 3 / 2 );
1609+ // Same balanced-pauser rationale as writeLock(): the lock holder is in another thread,
1610+ // tight spinning is pure CPU burn under contention.
1611+ return readOnly () ? WriteLock .NO_OP
1612+ : new AppendLock (metaStore , WRITE_LOCK_PAUSER_SUPPLIER , timeoutMS () * 3 / 2 );
15981613 }
15991614
16001615 /**
0 commit comments