diff options
| author | Dan Engelbrecht <[email protected]> | 2024-10-02 10:08:46 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-10-02 10:08:46 +0200 |
| commit | 0b86039ebbbce0138790f9039189dddb4b70b73a (patch) | |
| tree | e3deda42d154cb779ff8ab3dd29d04a5dc4069f0 /src/zenstore/compactcas.cpp | |
| parent | Porject -> Project (diff) | |
| download | zen-0b86039ebbbce0138790f9039189dddb4b70b73a.tar.xz zen-0b86039ebbbce0138790f9039189dddb4b70b73a.zip | |
gc block size target max size (#180)
* If a block is small (less than half max size) we add it to blocks to compact
Sort blocks when iterating over them
* do compact of block stores even if no new unused are found
* do compact phase even if bucket is empty
Diffstat (limited to 'src/zenstore/compactcas.cpp')
| -rw-r--r-- | src/zenstore/compactcas.cpp | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/src/zenstore/compactcas.cpp b/src/zenstore/compactcas.cpp index 5fca3046c..a5d70a991 100644 --- a/src/zenstore/compactcas.cpp +++ b/src/zenstore/compactcas.cpp @@ -871,48 +871,45 @@ public: Stats.CheckedCount = m_Cids.size(); Stats.FoundCount = UnusedCids.size(); - if (UnusedCids.empty()) - { - // Nothing to collect - return nullptr; - } - if (!Ctx.Settings.CollectSmallObjects) { return nullptr; } - if (Ctx.Settings.IsDeleteMode) + if (!UnusedCids.empty()) { - std::vector<CasDiskIndexEntry> ExpiredEntries; - ExpiredEntries.reserve(UnusedCids.size()); - + if (Ctx.Settings.IsDeleteMode) { - RwLock::ExclusiveLockScope __(m_CasContainerStrategy.m_LocationMapLock); - if (Ctx.IsCancelledFlag.load()) - { - return nullptr; - } + std::vector<CasDiskIndexEntry> ExpiredEntries; + ExpiredEntries.reserve(UnusedCids.size()); - for (const IoHash& Cid : UnusedCids) { - if (auto It = m_CasContainerStrategy.m_LocationMap.find(Cid); It != m_CasContainerStrategy.m_LocationMap.end()) + RwLock::ExclusiveLockScope __(m_CasContainerStrategy.m_LocationMapLock); + if (Ctx.IsCancelledFlag.load()) { - ExpiredEntries.push_back({.Key = Cid, - .Location = m_CasContainerStrategy.m_Locations[It->second], - .Flags = CasDiskIndexEntry::kTombstone}); + return nullptr; } - } - if (!ExpiredEntries.empty()) - { - for (const CasDiskIndexEntry& Entry : ExpiredEntries) + for (const IoHash& Cid : UnusedCids) + { + if (auto It = m_CasContainerStrategy.m_LocationMap.find(Cid); It != m_CasContainerStrategy.m_LocationMap.end()) + { + ExpiredEntries.push_back({.Key = Cid, + .Location = m_CasContainerStrategy.m_Locations[It->second], + .Flags = CasDiskIndexEntry::kTombstone}); + } + } + + if (!ExpiredEntries.empty()) { - m_CasContainerStrategy.m_LocationMap.erase(Entry.Key); - Stats.DeletedCount++; + for (const CasDiskIndexEntry& Entry : ExpiredEntries) + { + m_CasContainerStrategy.m_LocationMap.erase(Entry.Key); + Stats.DeletedCount++; + } + m_CasContainerStrategy.m_CasLog.Append(ExpiredEntries); + m_CasContainerStrategy.m_CasLog.Flush(); } - m_CasContainerStrategy.m_CasLog.Append(ExpiredEntries); - m_CasContainerStrategy.m_CasLog.Flush(); } } } |