From 339668ac935f781c06225d2d685642e27348772b Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Wed, 10 Sep 2025 16:38:33 +0200 Subject: add EMode to WorkerTheadPool to avoid thread starvation (#492) - Improvement: Add a new mode to worker thread pools to avoid starvation of workers which could cause long stalls due to other work begin queued up. UE-305498 --- src/zenstore/workspaces.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src/zenstore/workspaces.cpp') diff --git a/src/zenstore/workspaces.cpp b/src/zenstore/workspaces.cpp index 0ca2adab2..4e7bd79a3 100644 --- a/src/zenstore/workspaces.cpp +++ b/src/zenstore/workspaces.cpp @@ -622,17 +622,19 @@ Workspaces::GetWorkspaceShareChunks(const Oid& WorkspaceId, for (size_t Index = 0; Index < ChunkRequests.size(); Index++) { WorkLatch.AddCount(1); - WorkerPool.ScheduleWork([&, Index]() { - auto _ = MakeGuard([&WorkLatch]() { WorkLatch.CountDown(); }); - try - { - Chunks[Index] = GetOne(RootPath, *WorkspaceAndShare.second, ChunkRequests[Index]); - } - catch (const std::exception& Ex) - { - ZEN_WARN("Exception while fetching chunks, chunk {}: {}", ChunkRequests[Index].ChunkId, Ex.what()); - } - }); + WorkerPool.ScheduleWork( + [&, Index]() { + auto _ = MakeGuard([&WorkLatch]() { WorkLatch.CountDown(); }); + try + { + Chunks[Index] = GetOne(RootPath, *WorkspaceAndShare.second, ChunkRequests[Index]); + } + catch (const std::exception& Ex) + { + ZEN_WARN("Exception while fetching chunks, chunk {}: {}", ChunkRequests[Index].ChunkId, Ex.what()); + } + }, + WorkerThreadPool::EMode::DisableBacklog); } WorkLatch.CountDown(); WorkLatch.Wait(); -- cgit v1.2.3