From 76ac4d541c603dd869e18cfbc6644ebf6c6e22d7 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Thu, 28 Mar 2024 14:56:20 +0100 Subject: Use multithreading to fetch size/rawsize of entries in `/prj/{project}/oplog/{log}/chunkinfos` and `/prj/{project}/oplog/{log}/files` (#30) - Improvement: Use multithreading to fetch size/rawsize of entries in `/prj/{project}/oplog/{log}/chunkinfos` and `/prj/{project}/oplog/{log}/files` - Improvement: Add `GetMediumWorkerPool()` in addition to `LargeWorkerPool()` and `SmallWorkerPool()` --- src/zenutil/workerpools.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'src/zenutil/workerpools.cpp') diff --git a/src/zenutil/workerpools.cpp b/src/zenutil/workerpools.cpp index 3ae302064..939f3a1c4 100644 --- a/src/zenutil/workerpools.cpp +++ b/src/zenutil/workerpools.cpp @@ -11,14 +11,16 @@ ZEN_THIRD_PARTY_INCLUDES_END namespace zen { namespace { - const int LargeWorkerThreadPoolTreadCount = gsl::narrow(std::thread::hardware_concurrency()); - const int SmallWorkerThreadPoolTreadCount = gsl::narrow(Max((std::thread::hardware_concurrency() / 4u), 1u)); + const int LargeWorkerThreadPoolTreadCount = gsl::narrow(std::thread::hardware_concurrency()); + const int MediumWorkerThreadPoolTreadCount = gsl::narrow(Max((std::thread::hardware_concurrency() / 4u), 1u)); + const int SmallWorkerThreadPoolTreadCount = gsl::narrow(Max((std::thread::hardware_concurrency() / 8u), 1u)); static bool IsShutDown = false; RwLock PoolLock; std::unique_ptr LargeWorkerPool; + std::unique_ptr MediumWorkerPool; std::unique_ptr SmallWorkerPool; std::unique_ptr SyncWorkerPool; } // namespace @@ -43,6 +45,26 @@ GetLargeWorkerPool() return *LargeWorkerPool; } +WorkerThreadPool& +GetMediumWorkerPool() +{ + { + RwLock::SharedLockScope _(PoolLock); + if (MediumWorkerPool) + { + return *MediumWorkerPool; + } + } + RwLock::ExclusiveLockScope _(PoolLock); + ZEN_ASSERT(!IsShutDown); + if (MediumWorkerPool) + { + return *MediumWorkerPool; + } + MediumWorkerPool.reset(new WorkerThreadPool(MediumWorkerThreadPoolTreadCount, "MediumThreadPool")); + return *MediumWorkerPool; +} + WorkerThreadPool& GetSmallWorkerPool() { @@ -89,6 +111,7 @@ ShutdownWorkerPools() RwLock::ExclusiveLockScope _(PoolLock); IsShutDown = true; LargeWorkerPool.reset(); + MediumWorkerPool.reset(); SmallWorkerPool.reset(); SyncWorkerPool.reset(); } -- cgit v1.2.3