aboutsummaryrefslogtreecommitdiff
path: root/zenstore
diff options
context:
space:
mode:
authorPer Larsson <[email protected]>2021-12-09 16:17:56 +0100
committerPer Larsson <[email protected]>2021-12-09 16:17:56 +0100
commitd9dad00a33657c8759ca3551de4139136d16143b (patch)
tree2757d5fbf6b442766b4d6ea269ba2ca8cbbe537c /zenstore
parentGC default off. (diff)
downloadzen-d9dad00a33657c8759ca3551de4139136d16143b.tar.xz
zen-d9dad00a33657c8759ca3551de4139136d16143b.zip
Added options for Z$ max duration and whether to collect small objects.
Diffstat (limited to 'zenstore')
-rw-r--r--zenstore/compactcas.cpp4
-rw-r--r--zenstore/gc.cpp21
-rw-r--r--zenstore/include/zenstore/gc.h8
3 files changed, 20 insertions, 13 deletions
diff --git a/zenstore/compactcas.cpp b/zenstore/compactcas.cpp
index b481dead5..f3fcbca28 100644
--- a/zenstore/compactcas.cpp
+++ b/zenstore/compactcas.cpp
@@ -318,9 +318,9 @@ CasContainerStrategy::CollectGarbage(GcContext& GcCtx)
return;
}
- const bool GcEnabled = GcCtx.IsDeletionMode() && GcCtx.IsContainerGcEnabled();
+ const bool CollectSmallObjects = GcCtx.IsDeletionMode() && GcCtx.CollectSmallObjects();
- if (!GcEnabled)
+ if (!CollectSmallObjects)
{
ZEN_INFO("garbage collect from '{}' DISABLED, found #{} {} chunks of total #{} {}",
m_Config.RootDirectory / m_ContainerBaseName,
diff --git a/zenstore/gc.cpp b/zenstore/gc.cpp
index 5aff20e7a..bf04543b5 100644
--- a/zenstore/gc.cpp
+++ b/zenstore/gc.cpp
@@ -50,9 +50,9 @@ struct GcContext::GcState
CasChunkSet m_CasChunks;
CasChunkSet m_CidChunks;
GcClock::TimePoint m_GcTime;
- GcClock::Duration m_MaxCacheDuration = std::chrono::hours(24);
- bool m_DeletionMode = true;
- bool m_ContainerGcEnabled = false;
+ GcClock::Duration m_MaxCacheDuration = std::chrono::hours(24);
+ bool m_DeletionMode = true;
+ bool m_CollectSmallObjects = false;
};
GcContext::GcContext(GcClock::TimePoint Time) : m_State(std::make_unique<GcState>())
@@ -107,15 +107,15 @@ GcContext::SetDeletionMode(bool NewState)
}
bool
-GcContext::IsContainerGcEnabled() const
+GcContext::CollectSmallObjects() const
{
- return m_State->m_ContainerGcEnabled;
+ return m_State->m_CollectSmallObjects;
}
void
-GcContext::SetContainerGcEnabled(bool NewState)
+GcContext::CollectSmallObjects(bool NewState)
{
- m_State->m_ContainerGcEnabled = NewState;
+ m_State->m_CollectSmallObjects = NewState;
}
GcClock::TimePoint
@@ -346,7 +346,12 @@ GcScheduler::SchedulerThread()
GcContext GcCtx;
GcCtx.SetDeletionMode(true);
- GcCtx.SetContainerGcEnabled(true);
+ GcCtx.CollectSmallObjects(m_Config.CollectSmallObjects);
+ GcCtx.MaxCacheDuration(m_Config.MaxCacheDuration);
+
+ ZEN_DEBUG("collecting small objects {}, max cache duration {}s",
+ m_Config.CollectSmallObjects ? "YES"sv : "NO"sv,
+ m_Config.MaxCacheDuration.count());
m_CasGc.CollectGarbage(GcCtx);
diff --git a/zenstore/include/zenstore/gc.h b/zenstore/include/zenstore/gc.h
index 2ec318e9a..3c03c7feb 100644
--- a/zenstore/include/zenstore/gc.h
+++ b/zenstore/include/zenstore/gc.h
@@ -60,8 +60,8 @@ public:
bool IsDeletionMode() const;
void SetDeletionMode(bool NewState);
- bool IsContainerGcEnabled() const;
- void SetContainerGcEnabled(bool NewState);
+ bool CollectSmallObjects() const;
+ void CollectSmallObjects(bool NewState);
GcClock::TimePoint Time() const;
@@ -151,7 +151,9 @@ struct GcSchedulerConfig
{
std::filesystem::path RootDirectory;
std::chrono::seconds Interval{3600};
- bool Enabled = false;
+ std::chrono::seconds MaxCacheDuration{86400};
+ bool CollectSmallObjects = false;
+ bool Enabled = false;
};
class GcScheduler