aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2024-10-22 12:50:30 +0200
committerGitHub Enterprise <[email protected]>2024-10-22 12:50:30 +0200
commit5e73f7f9e9abee0481eb29d28124b2a557dbf54a (patch)
treec35379e1a71b7e89c42ae7e8148352a88a801f8b /src
parentbucket size queries (#203) (diff)
downloadzen-5e73f7f9e9abee0481eb29d28124b2a557dbf54a.tar.xz
zen-5e73f7f9e9abee0481eb29d28124b2a557dbf54a.zip
Use a smaller thread pool during pre-cache phase of GC to reduce memory pressure (#205)
Diffstat (limited to 'src')
-rw-r--r--src/zenstore/gc.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/zenstore/gc.cpp b/src/zenstore/gc.cpp
index 981ba15cb..be8fc0148 100644
--- a/src/zenstore/gc.cpp
+++ b/src/zenstore/gc.cpp
@@ -632,7 +632,8 @@ GcManager::CollectGarbage(const GcSettings& Settings)
std::unordered_map<std::unique_ptr<GcStoreCompactor>, GcCompactStoreStats*> StoreCompactors;
RwLock StoreCompactorsLock;
- WorkerThreadPool& ThreadPool = Settings.SingleThread ? GetSyncWorkerPool() : GetMediumWorkerPool(EWorkloadType::Background);
+ WorkerThreadPool& PreCachePhaseThreadPool =
+ Settings.SingleThread ? GetSyncWorkerPool() : GetSmallWorkerPool(EWorkloadType::Background);
ZEN_INFO("GCV2: Removing expired data from {} referencers", m_GcReferencers.size());
if (!m_GcReferencers.empty())
@@ -662,7 +663,7 @@ GcManager::CollectGarbage(const GcSettings& Settings)
GcReferencer* Owner = m_GcReferencers[Index];
std::pair<std::string, GcReferencerStats>* Stats = &Result.ReferencerStats[Index];
WorkLeft.AddCount(1);
- ThreadPool.ScheduleWork([this, &Ctx, &WorkLeft, Owner, Stats, &StoreCompactorsLock, &StoreCompactors]() {
+ PreCachePhaseThreadPool.ScheduleWork([this, &Ctx, &WorkLeft, Owner, Stats, &StoreCompactorsLock, &StoreCompactors]() {
auto _ = MakeGuard([&WorkLeft]() { WorkLeft.CountDown(); });
try
{
@@ -728,7 +729,7 @@ GcManager::CollectGarbage(const GcSettings& Settings)
GcReferenceStore* ReferenceStore = m_GcReferenceStores[Index];
std::pair<std::string, GcReferenceStoreStats>* Stats = &Result.ReferenceStoreStats[Index];
WorkLeft.AddCount(1);
- ThreadPool.ScheduleWork(
+ PreCachePhaseThreadPool.ScheduleWork(
[this, &Ctx, ReferenceStore, Stats, Index, &WorkLeft, &ReferencePrunersLock, &ReferencePruners]() {
auto _ = MakeGuard([&WorkLeft]() { WorkLeft.CountDown(); });
try
@@ -799,7 +800,7 @@ GcManager::CollectGarbage(const GcSettings& Settings)
GcReferencer* Referencer = m_GcReferencers[Index];
std::pair<std::string, GcReferencerStats>* Stats = &Result.ReferencerStats[Index];
WorkLeft.AddCount(1);
- ThreadPool.ScheduleWork(
+ PreCachePhaseThreadPool.ScheduleWork(
[this, &Ctx, &WorkLeft, Referencer, Index, Stats, &ReferenceCheckersLock, &ReferenceCheckers]() {
auto _ = MakeGuard([&WorkLeft]() { WorkLeft.CountDown(); });
// The Referencer will create a reference checker that guarantees that the references do not change as
@@ -873,7 +874,7 @@ GcManager::CollectGarbage(const GcSettings& Settings)
size_t Index = It.second;
std::pair<std::string, GcReferencerStats>* Stats = &Result.ReferencerStats[Index];
WorkLeft.AddCount(1);
- ThreadPool.ScheduleWork([this, &Ctx, Checker, Index, Stats, &WorkLeft]() {
+ PreCachePhaseThreadPool.ScheduleWork([this, &Ctx, Checker, Index, Stats, &WorkLeft]() {
auto _ = MakeGuard([&WorkLeft]() { WorkLeft.CountDown(); });
try
{
@@ -893,6 +894,9 @@ GcManager::CollectGarbage(const GcSettings& Settings)
}
}
+ WorkerThreadPool& LockedPhaseThreadPool =
+ Settings.SingleThread ? GetSyncWorkerPool() : GetMediumWorkerPool(EWorkloadType::Background);
+
std::vector<RwLock::SharedLockScope> LockerScopes;
SCOPED_TIMER(uint64_t ElapsedMS = Timer.GetElapsedTimeMs(); Result.WriteBlockMS = std::chrono::milliseconds(ElapsedMS);
ZEN_INFO("GCV2: Writes blocked for {}", NiceTimeSpanMs(ElapsedMS)));
@@ -957,7 +961,7 @@ GcManager::CollectGarbage(const GcSettings& Settings)
size_t Index = It.second;
std::pair<std::string, GcReferencerStats>* Stats = &Result.ReferencerStats[Index];
WorkLeft.AddCount(1);
- ThreadPool.ScheduleWork([this, &Ctx, Checker, Index, Stats, &WorkLeft]() {
+ LockedPhaseThreadPool.ScheduleWork([this, &Ctx, Checker, Index, Stats, &WorkLeft]() {
auto _ = MakeGuard([&WorkLeft]() { WorkLeft.CountDown(); });
try
{
@@ -1030,7 +1034,7 @@ GcManager::CollectGarbage(const GcSettings& Settings)
size_t Index = It.first;
GcReferenceStoreStats* Stats = &Result.ReferenceStoreStats[Index].second;
WorkLeft.AddCount(1);
- ThreadPool.ScheduleWork(
+ LockedPhaseThreadPool.ScheduleWork(
[this, &Ctx, Pruner, Stats, &WorkLeft, &GetUnusedReferences, &StoreCompactorsLock, &StoreCompactors]() {
auto _ = MakeGuard([&WorkLeft]() { WorkLeft.CountDown(); });
// Go through all the ReferenceCheckers to see if the list of Cids the collector selected are