From ba32394ab65677e0daaebc3698b3cdf49fed896f Mon Sep 17 00:00:00 2001 From: rishabh mittal Date: Mon, 30 Mar 2026 21:43:17 -0700 Subject: [PATCH] pool: fix scaled-down threads still processing tasks When threads are scaled down, threads with ID > core_thread_count should go to sleep immediately. Previously, the park validation callback would still pop tasks from the queue, causing scaled-down threads to keep working instead of sleeping. Co-Authored-By: Claude Opus 4.6 Signed-off-by: rishabh mittal --- src/pool/spawn.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pool/spawn.rs b/src/pool/spawn.rs index 5c4e493..d648e63 100644 --- a/src/pool/spawn.rs +++ b/src/pool/spawn.rs @@ -329,6 +329,11 @@ impl Local { if !self.core.mark_sleep() { return false; } + // If this thread is above core_thread_count, go to sleep + // without popping so scaled-down threads don't keep working. + if id > self.core.config.core_thread_count.load(Ordering::SeqCst) { + return true; + } task = self.local_queue.pop(); task.is_none() },