aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/cache/cachedisklayer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenserver/cache/cachedisklayer.cpp')
-rw-r--r--src/zenserver/cache/cachedisklayer.cpp43
1 files changed, 28 insertions, 15 deletions
diff --git a/src/zenserver/cache/cachedisklayer.cpp b/src/zenserver/cache/cachedisklayer.cpp
index a6cb54444..afb974d76 100644
--- a/src/zenserver/cache/cachedisklayer.cpp
+++ b/src/zenserver/cache/cachedisklayer.cpp
@@ -3210,7 +3210,7 @@ ZenCacheDiskLayer::DiscoverBuckets()
const size_t MaxHwTreadUse = std::thread::hardware_concurrency();
const int WorkerThreadPoolCount = gsl::narrow<int>(Min(MaxHwTreadUse, FoundBucketDirectories.size()));
- WorkerThreadPool Pool(WorkerThreadPoolCount);
+ WorkerThreadPool Pool(WorkerThreadPoolCount, "CacheBucket::OpenOrCreate");
Latch WorkLatch(1);
for (auto& BucketPath : FoundBucketDirectories)
{
@@ -3300,9 +3300,17 @@ void
ZenCacheDiskLayer::Flush()
{
std::vector<CacheBucket*> Buckets;
+ Stopwatch Timer;
+ const auto _ = MakeGuard([&] {
+ if (Buckets.empty())
+ {
+ return;
+ }
+ ZEN_INFO("Flushed {} buckets at '{}' in {}", Buckets.size(), m_RootDir, NiceTimeSpanMs(Timer.GetElapsedTimeMs()));
+ });
{
- RwLock::SharedLockScope _(m_Lock);
+ RwLock::SharedLockScope __(m_Lock);
if (m_Buckets.empty())
{
return;
@@ -3314,21 +3322,26 @@ ZenCacheDiskLayer::Flush()
Buckets.push_back(Bucket);
}
}
- const size_t MaxHwTreadUse = Max((std::thread::hardware_concurrency() / 4u), 1u);
- const int WorkerThreadPoolCount = gsl::narrow<int>(Min(MaxHwTreadUse, Buckets.size()));
-
- WorkerThreadPool Pool(WorkerThreadPoolCount);
- Latch WorkLatch(1);
- for (auto& Bucket : Buckets)
{
- WorkLatch.AddCount(1);
- Pool.ScheduleWork([&]() {
- auto _ = MakeGuard([&]() { WorkLatch.CountDown(); });
- Bucket->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);
+ for (auto& Bucket : Buckets)
+ {
+ WorkLatch.AddCount(1);
+ Pool.ScheduleWork([&]() {
+ auto _ = MakeGuard([&]() { WorkLatch.CountDown(); });
+ Bucket->Flush();
+ });
+ }
+ WorkLatch.CountDown();
+ while (!WorkLatch.Wait(1000))
+ {
+ ZEN_DEBUG("Waiting for {} buckets at '{}' to flush", WorkLatch.Remaining(), m_RootDir);
+ }
}
- WorkLatch.CountDown();
- WorkLatch.Wait();
}
void