diff options
| author | Dan Engelbrecht <[email protected]> | 2023-11-29 09:14:57 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-11-29 15:14:57 +0100 |
| commit | 68b3382ef7e0f7795b9a601aae73adc2f8ef9873 (patch) | |
| tree | a8460fa497195575505e14f7beef069ecee31ef7 /src/zenserver/cache/cachedisklayer.cpp | |
| parent | fixed file logger pattern (#579) (diff) | |
| download | zen-68b3382ef7e0f7795b9a601aae73adc2f8ef9873.tar.xz zen-68b3382ef7e0f7795b9a601aae73adc2f8ef9873.zip | |
global thread worker pools (#577)
- Improvement: Use two global worker thread pools instead of ad-hoc creation of worker pools
Diffstat (limited to 'src/zenserver/cache/cachedisklayer.cpp')
| -rw-r--r-- | src/zenserver/cache/cachedisklayer.cpp | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/zenserver/cache/cachedisklayer.cpp b/src/zenserver/cache/cachedisklayer.cpp index c8bc3871a..9117b8820 100644 --- a/src/zenserver/cache/cachedisklayer.cpp +++ b/src/zenserver/cache/cachedisklayer.cpp @@ -14,6 +14,7 @@ #include <zencore/trace.h> #include <zencore/workthreadpool.h> #include <zencore/xxhash.h> +#include <zenutil/workerpools.h> #include <future> @@ -3709,11 +3710,8 @@ ZenCacheDiskLayer::DiscoverBuckets() RwLock SyncLock; - const size_t MaxHwTreadUse = std::thread::hardware_concurrency(); - const int WorkerThreadPoolCount = gsl::narrow<int>(Min(MaxHwTreadUse, FoundBucketDirectories.size())); - - WorkerThreadPool Pool(WorkerThreadPoolCount, "CacheBucket::OpenOrCreate"); - Latch WorkLatch(1); + WorkerThreadPool& Pool = GetLargeWorkerPool(); + Latch WorkLatch(1); for (auto& BucketPath : FoundBucketDirectories) { WorkLatch.AddCount(1); @@ -3825,11 +3823,8 @@ ZenCacheDiskLayer::Flush() } } { - const size_t MaxHwTreadUse = Max((std::thread::hardware_concurrency() / 4u), 1u); - const int WorkerThreadPoolCount = gsl::narrow<int>(Min(MaxHwTreadUse, Buckets.size())); - - WorkerThreadPool Pool(WorkerThreadPoolCount, "CacheBucket::Flush"); - Latch WorkLatch(1); + WorkerThreadPool& Pool = GetSmallWorkerPool(); + Latch WorkLatch(1); for (auto& Bucket : Buckets) { WorkLatch.AddCount(1); |