aboutsummaryrefslogtreecommitdiff
path: root/zenstore/compactcas.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-05-02 11:22:14 +0200
committerDan Engelbrecht <[email protected]>2022-05-02 11:22:14 +0200
commitf14272b7adfb562a39295324a92c7bbf31c9bd3e (patch)
treeac7cae6aff48cdf0ba4c4a9290554fd82e866743 /zenstore/compactcas.cpp
parentcleanup (diff)
downloadzen-f14272b7adfb562a39295324a92c7bbf31c9bd3e.tar.xz
zen-f14272b7adfb562a39295324a92c7bbf31c9bd3e.zip
restore cg comment
Diffstat (limited to 'zenstore/compactcas.cpp')
-rw-r--r--zenstore/compactcas.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/zenstore/compactcas.cpp b/zenstore/compactcas.cpp
index ade6a7daf..5a0ba974b 100644
--- a/zenstore/compactcas.cpp
+++ b/zenstore/compactcas.cpp
@@ -321,8 +321,6 @@ CasContainerStrategy::Flush()
void
CasContainerStrategy::Scrub(ScrubContext& Ctx)
{
- ZEN_UNUSED(Ctx);
-
RwLock::SharedLockScope _(m_LocationMapLock);
uint64_t TotalChunkCount = m_LocationMap.size();
@@ -409,6 +407,31 @@ CasContainerStrategy::Scrub(ScrubContext& Ctx)
void
CasContainerStrategy::CollectGarbage(GcContext& GcCtx)
{
+ // It collects all the blocks that we want to delete chunks from. For each such
+ // block we keep a list of chunks to retain and a list of chunks to delete.
+ //
+ // If there is a block that we are currently writing to, that block is omitted
+ // from the garbage collection.
+ //
+ // Next it will iterate over all blocks that we want to remove chunks from.
+ // If the block is empty after removal of chunks we mark the block as pending
+ // delete - we want to delete it as soon as there are no IoBuffers using the
+ // block file.
+ // Once complete we update the m_LocationMap by removing the chunks.
+ //
+ // If the block is non-empty we write out the chunks we want to keep to a new
+ // block file (creating new block files as needed).
+ //
+ // We update the index as we complete each new block file. This makes it possible
+ // to break the GC if we want to limit time for execution.
+ //
+ // GC can very parallell to regular operation - it will block while taking
+ // a snapshot of the current m_LocationMap state and while moving blocks it will
+ // do a blocking operation and update the m_LocationMap after each new block is
+ // written and figuring out the path to the next new block.
+
+ ZEN_INFO("collecting garbage from '{}'", m_Config.RootDirectory / m_ContainerBaseName);
+
uint64_t WriteBlockTimeUs = 0;
uint64_t WriteBlockLongestTimeUs = 0;
uint64_t ReadBlockTimeUs = 0;