From 9d353ebe454e19813444548253315128b17c610f Mon Sep 17 00:00:00 2001 From: AJ Heller Date: Thu, 25 May 2023 11:40:44 -0700 Subject: [PATCH] [EventEngine] Mark worker threads busy while draining (#33251) ~5% flake introduced earlier this week, where the pool was not scaling when draining work @ shutdown. Maintaining a busy thread count at shutdown allows the lifeguard to notice when all threads are blocked, and spawn new threads if necessary. --- .../lib/event_engine/thread_pool/work_stealing_thread_pool.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc b/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc index fd60eec3ce7..19c9eda0c4b 100644 --- a/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc +++ b/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc @@ -398,6 +398,9 @@ bool WorkStealingThreadPool::ThreadState::Step() { } void WorkStealingThreadPool::ThreadState::FinishDraining() { + // The thread is definitionally busy while draining + ThreadCount::AutoThreadCount auto_busy{pool_->thread_count(), + CounterType::kBusyCount}; // If a fork occurs at any point during shutdown, quit draining. The post-fork // threads will finish draining the global queue. while (!pool_->IsForking()) {