From bfb3de7a8a9c612774dd82d27f947f2c2dbdeaab Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Thu, 4 Feb 2021 23:42:38 -0300 Subject: [PATCH] Use use max_items as bound in tower-batch (#1691) --- tower-batch/src/service.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tower-batch/src/service.rs b/tower-batch/src/service.rs index 7015af3c6..9598bd3c3 100644 --- a/tower-batch/src/service.rs +++ b/tower-batch/src/service.rs @@ -57,8 +57,12 @@ where T::Error: Send + Sync, Request: Send + 'static, { - // XXX(hdevalence): is this bound good - let bound = 1; + // The semaphore bound limits the maximum number of concurrent requests + // (specifically, requests which got a `Ready` from `poll_ready`, but haven't + // used their semaphore reservation in a `call` yet). + // We choose a bound that allows callers to check readiness for every item in + // a batch, then actually submit those items. + let bound = max_items; let (tx, rx) = mpsc::unbounded_channel(); let (handle, worker) = Worker::new(service, rx, max_items, max_latency); tokio::spawn(worker.run());