From 4ce5748340a831e5d0b515e4590c4e560b98922a Mon Sep 17 00:00:00 2001 From: Borislav Borisov Date: Tue, 7 Apr 2026 08:41:09 +0100 Subject: [PATCH] Skip redundant poll_max_time check when batch is already full When is_full() triggers a flush, poll_max_time() was still called unnecessarily, registering a spurious waker and potentially overwriting the flush reason from "size" to "time" in trace output. --- src/worker.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/worker.rs b/src/worker.rs index c05e6d9..f32d2f5 100644 --- a/src/worker.rs +++ b/src/worker.rs @@ -184,10 +184,8 @@ where // Flush if the batch is full. if this.lot.is_full() { this.state.set(State::flushing("size".to_owned(), None)); - } - - // Or flush if the max time has elapsed. - if this.lot.poll_max_time(cx).is_ready() { + } else if this.lot.poll_max_time(cx).is_ready() { + // Or flush if the max time has elapsed. this.state.set(State::flushing("time".to_owned(), None)); } }