merlimat opened a new pull request, #4836: URL: https://github.com/apache/bookkeeper/pull/4836
### Motivation `SingleThreadExecutor` backs every `OrderedExecutor` thread — including the bookie read/write thread pools — so its queue is on the task-dispatch hot path. Today it uses: - `GrowableMpScArrayConsumerBlockingQueue` (unbounded, the default), draining element-by-element via `drainTo(ArrayList)` - JDK `ArrayBlockingQueue` (bounded, when `maxTasksInQueue` is set) Meanwhile `BatchedArrayBlockingQueue` — purpose-built in the same package for the many-producers/one-consumer shape, with `System.arraycopy` batch draining — was unused by the executor. A JMH comparison (8 producers, consumers running the executor's exact drain loops) showed the growable queue is actually the *slowest* option, and the batched queue the fastest: | Queue | put throughput | |---|---| | `GrowableMpScArrayConsumerBlockingQueue` (current unbounded) | 32.7 Mops/s | | JDK `ArrayBlockingQueue` (current bounded) | 43.3 Mops/s | | **`GrowableBatchedArrayBlockingQueue` (new, unbounded)** | **48.5 Mops/s (+48%)** | | **`BatchedArrayBlockingQueue` (bounded)** | **51.4 Mops/s (+19%)** | ### Changes - Add `GrowableBatchedArrayBlockingQueue`: the unbounded companion of `BatchedArrayBlockingQueue`. Same single-lock design and two-span `System.arraycopy` batch operations (`takeAll` / `pollAll` / `putAll`), but with no `notFull` condition — producers never block; the backing array doubles when full (and never shrinks), like the queue it replaces. - `SingleThreadExecutor` now uses `BatchedArrayBlockingQueue` for the bounded case and the new growable queue for the unbounded case, and the run loop drains with `takeAll` into a reusable `Runnable[]` (capped at 1024) instead of per-element `drainTo(ArrayList)`. - New unit test covering the growth paths (including growth and batch-insert with wrapped indexes) and the batched operations. - New JMH benchmark (`SingleThreadExecutorQueueBenchmark`) comparing all four queue options with executor-style consumers. Verified: new queue test (9/9), `BatchedArrayBlockingQueueTest`, `GrowableArrayBlockingQueueTest`, `TestSingleThreadExecutor` (10/10), `TestOrderedExecutor`, `TestOrderedExecutorDecorators`, plus `BookieJournalTest` as an integration smoke through the bookie path (16/16). Checkstyle clean. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
