aboutsummaryrefslogtreecommitdiff
path: root/src/zenutil
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2024-03-28 14:56:20 +0100
committerGitHub Enterprise <[email protected]>2024-03-28 14:56:20 +0100
commit76ac4d541c603dd869e18cfbc6644ebf6c6e22d7 (patch)
treef919560d5ddb5a33057f9337d930ca327149dafd /src/zenutil
parentadd "fieldnames" query param for GetProjectFiles/GetProjectChunkInfos (#29) (diff)
downloadzen-76ac4d541c603dd869e18cfbc6644ebf6c6e22d7.tar.xz
zen-76ac4d541c603dd869e18cfbc6644ebf6c6e22d7.zip
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()`
Diffstat (limited to 'src/zenutil')
-rw-r--r--src/zenutil/include/zenutil/workerpools.h7
-rw-r--r--src/zenutil/workerpools.cpp27
2 files changed, 30 insertions, 4 deletions
diff --git a/src/zenutil/include/zenutil/workerpools.h b/src/zenutil/include/zenutil/workerpools.h
index 339120ece..78a8e5c5e 100644
--- a/src/zenutil/include/zenutil/workerpools.h
+++ b/src/zenutil/include/zenutil/workerpools.h
@@ -6,10 +6,13 @@
namespace zen {
-// Worker pool with std::thread::hardware_concurrency() worker threads
+// Worker pool with std::thread::hardware_concurrency() worker threads, but at least one thread
WorkerThreadPool& GetLargeWorkerPool();
-// Worker pool with std::thread::hardware_concurrency() / 4 worker threads
+// Worker pool with std::thread::hardware_concurrency() / 4 worker threads, but at least one thread
+WorkerThreadPool& GetMediumWorkerPool();
+
+// Worker pool with std::thread::hardware_concurrency() / 8 worker threads, but at least one thread
WorkerThreadPool& GetSmallWorkerPool();
// Special worker pool that does not use worker thread but issues all scheduled work on the calling thread
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<int>(std::thread::hardware_concurrency());
- const int SmallWorkerThreadPoolTreadCount = gsl::narrow<int>(Max((std::thread::hardware_concurrency() / 4u), 1u));
+ const int LargeWorkerThreadPoolTreadCount = gsl::narrow<int>(std::thread::hardware_concurrency());
+ const int MediumWorkerThreadPoolTreadCount = gsl::narrow<int>(Max((std::thread::hardware_concurrency() / 4u), 1u));
+ const int SmallWorkerThreadPoolTreadCount = gsl::narrow<int>(Max((std::thread::hardware_concurrency() / 8u), 1u));
static bool IsShutDown = false;
RwLock PoolLock;
std::unique_ptr<WorkerThreadPool> LargeWorkerPool;
+ std::unique_ptr<WorkerThreadPool> MediumWorkerPool;
std::unique_ptr<WorkerThreadPool> SmallWorkerPool;
std::unique_ptr<WorkerThreadPool> SyncWorkerPool;
} // namespace
@@ -44,6 +46,26 @@ GetLargeWorkerPool()
}
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();
}