aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore/include
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2024-10-03 16:42:57 +0200
committerGitHub Enterprise <[email protected]>2024-10-03 16:42:57 +0200
commitb13b5f48bb497aaf9f9f3d74aceb6e474cf12898 (patch)
tree24b1ed63ece11fb773a0ecf41ce6308969468198 /src/zenstore/include
parent5.5.9-pre0 (diff)
downloadzen-b13b5f48bb497aaf9f9f3d74aceb6e474cf12898.tar.xz
zen-b13b5f48bb497aaf9f9f3d74aceb6e474cf12898.zip
remove gc v1 (#121)
* kill gc v1 * block use of gc v1 from zen command line * warn and flip to gcv2 if --gc-v2=false is specified for zenserver
Diffstat (limited to 'src/zenstore/include')
-rw-r--r--src/zenstore/include/zenstore/blockstore.h23
-rw-r--r--src/zenstore/include/zenstore/cache/cachedisklayer.h4
-rw-r--r--src/zenstore/include/zenstore/cache/structuredcachestore.h6
-rw-r--r--src/zenstore/include/zenstore/gc.h84
4 files changed, 17 insertions, 100 deletions
diff --git a/src/zenstore/include/zenstore/blockstore.h b/src/zenstore/include/zenstore/blockstore.h
index a98ca5375..d4c2be73f 100644
--- a/src/zenstore/include/zenstore/blockstore.h
+++ b/src/zenstore/include/zenstore/blockstore.h
@@ -127,13 +127,12 @@ public:
typedef std::vector<std::pair<size_t, BlockStoreLocation>> MovedChunksArray;
typedef std::vector<size_t> ChunkIndexArray;
- typedef std::function<void(const MovedChunksArray& MovedChunks, const ChunkIndexArray& RemovedChunks)> ReclaimCallback;
- typedef std::function<bool(const MovedChunksArray& MovedChunks, uint64_t FreedDiskSpace)> CompactCallback;
- typedef std::function<uint64_t()> ClaimDiskReserveCallback;
- typedef std::function<bool(size_t ChunkIndex, const void* Data, uint64_t Size)> IterateChunksSmallSizeCallback;
- typedef std::function<bool(size_t ChunkIndex, BlockStoreFile& File, uint64_t Offset, uint64_t Size)> IterateChunksLargeSizeCallback;
- typedef std::function<void(const BlockStoreLocation& Location)> WriteChunkCallback;
- typedef std::function<bool(uint32_t BlockIndex, std::span<const size_t> ChunkIndexes)> IterateChunksCallback;
+ typedef std::function<bool(const MovedChunksArray& MovedChunks, uint64_t FreedDiskSpace)> CompactCallback;
+ typedef std::function<uint64_t()> ClaimDiskReserveCallback;
+ typedef std::function<bool(size_t ChunkIndex, const void* Data, uint64_t Size)> IterateChunksSmallSizeCallback;
+ typedef std::function<bool(size_t ChunkIndex, BlockStoreFile& File, uint64_t Offset, uint64_t Size)> IterateChunksLargeSizeCallback;
+ typedef std::function<void(const BlockStoreLocation& Location)> WriteChunkCallback;
+ typedef std::function<bool(uint32_t BlockIndex, std::span<const size_t> ChunkIndexes)> IterateChunksCallback;
struct BlockUsageInfo
{
@@ -162,16 +161,6 @@ public:
IoBuffer TryGetChunk(const BlockStoreLocation& Location) const;
void Flush(bool ForceNewBlock);
- ReclaimSnapshotState GetReclaimSnapshotState();
- void ReclaimSpace(
- const ReclaimSnapshotState& Snapshot,
- const std::vector<BlockStoreLocation>& ChunkLocations,
- const ChunkIndexArray& KeepChunkIndexes,
- uint32_t PayloadAlignment,
- bool DryRun,
- const ReclaimCallback& ChangeCallback = [](const MovedChunksArray&, const ChunkIndexArray&) {},
- const ClaimDiskReserveCallback& DiskReserveCallback = []() { return 0; });
-
bool IterateChunks(const std::span<const BlockStoreLocation>& ChunkLocations, const IterateChunksCallback& Callback);
bool IterateBlock(std::span<const BlockStoreLocation> ChunkLocations,
diff --git a/src/zenstore/include/zenstore/cache/cachedisklayer.h b/src/zenstore/include/zenstore/cache/cachedisklayer.h
index f38776b6e..f8ce8641c 100644
--- a/src/zenstore/include/zenstore/cache/cachedisklayer.h
+++ b/src/zenstore/include/zenstore/cache/cachedisklayer.h
@@ -183,8 +183,6 @@ public:
bool DropBucket(std::string_view Bucket);
void Flush();
void ScrubStorage(ScrubContext& Ctx);
- void GatherReferences(GcContext& GcCtx);
- void CollectGarbage(GcContext& GcCtx);
void DiscoverBuckets();
GcStorageSize StorageSize() const;
@@ -231,8 +229,6 @@ public:
bool Drop();
void Flush();
void ScrubStorage(ScrubContext& Ctx);
- void GatherReferences(GcContext& GcCtx);
- void CollectGarbage(GcContext& GcCtx);
RwLock::SharedLockScope GetGcReferencerLock();
bool GetReferences(GcCtx& Ctx, bool StateIsAlreadyLocked, std::vector<IoHash>& OutReferences);
diff --git a/src/zenstore/include/zenstore/cache/structuredcachestore.h b/src/zenstore/include/zenstore/cache/structuredcachestore.h
index 9160db667..50e40042a 100644
--- a/src/zenstore/include/zenstore/cache/structuredcachestore.h
+++ b/src/zenstore/include/zenstore/cache/structuredcachestore.h
@@ -49,7 +49,7 @@ class JobQueue;
*/
-class ZenCacheNamespace final : public GcStorage, public GcContributor
+class ZenCacheNamespace final : public GcStorage
{
public:
struct Configuration
@@ -104,12 +104,8 @@ public:
bool Drop();
void Flush();
- // GcContributor
- virtual void GatherReferences(GcContext& GcCtx) override;
-
// GcStorage
virtual void ScrubStorage(ScrubContext& ScrubCtx) override;
- virtual void CollectGarbage(GcContext& GcCtx) override;
virtual GcStorageSize StorageSize() const override;
Configuration GetConfig() const { return m_Configuration; }
diff --git a/src/zenstore/include/zenstore/gc.h b/src/zenstore/include/zenstore/gc.h
index b79f1b9df..e191a0930 100644
--- a/src/zenstore/include/zenstore/gc.h
+++ b/src/zenstore/include/zenstore/gc.h
@@ -283,64 +283,6 @@ public:
//////// End GC V2
-/** Garbage Collection context object
- */
-class GcContext
-{
-public:
- GcContext(const GcClock::TimePoint& CacheExpireTime, const GcClock::TimePoint& ProjectStoreExpireTime);
- ~GcContext();
-
- void AddRetainedCids(std::span<const IoHash> Cid);
- void SetExpiredCacheKeys(const std::string& CacheKeyContext, std::vector<IoHash>&& ExpiredKeys);
-
- void IterateCids(std::function<void(const IoHash&)> Callback);
-
- void FilterCids(std::span<const IoHash> Cid, std::function<void(const IoHash&)> KeepFunc);
- void FilterCids(std::span<const IoHash> Cid, std::function<void(const IoHash&, bool)>&& FilterFunc);
-
- void AddDeletedCids(std::span<const IoHash> Cas);
- const HashKeySet& DeletedCids();
-
- std::span<const IoHash> ExpiredCacheKeys(const std::string& CacheKeyContext) const;
-
- bool SkipCid() const;
- void SetSkipCid(bool NewState);
-
- bool IsDeletionMode() const;
- void SetDeletionMode(bool NewState);
-
- bool CollectSmallObjects() const;
- void CollectSmallObjects(bool NewState);
-
- GcClock::TimePoint CacheExpireTime() const;
- GcClock::TimePoint ProjectStoreExpireTime() const;
-
- void DiskReservePath(const std::filesystem::path& Path);
- uint64_t ClaimGCReserve();
-
-private:
- struct GcState;
-
- std::unique_ptr<GcState> m_State;
-};
-
-/** GC root contributor
-
- Higher level data structures provide roots for the garbage collector,
- which ultimately determine what is garbage and what data we need to
- retain.
-
- */
-class GcContributor
-{
-public:
- virtual void GatherReferences(GcContext& GcCtx) = 0;
-
-protected:
- virtual ~GcContributor() {}
-};
-
struct GcStorageSize
{
uint64_t DiskSize{};
@@ -353,7 +295,6 @@ class GcStorage
{
public:
virtual void ScrubStorage(ScrubContext& ScrubCtx) = 0;
- virtual void CollectGarbage(GcContext& GcCtx) = 0;
virtual GcStorageSize StorageSize() const = 0;
protected:
@@ -392,14 +333,10 @@ public:
//////// End GC V2
- void AddGcContributor(GcContributor* Contributor);
- void RemoveGcContributor(GcContributor* Contributor);
-
void AddGcStorage(GcStorage* Contributor);
void RemoveGcStorage(GcStorage* Contributor);
- GcStorageSize CollectGarbage(GcContext& GcCtx);
- void ScrubStorage(ScrubContext& GcCtx);
+ void ScrubStorage(ScrubContext& GcCtx);
GcStorageSize TotalStorageSize() const;
@@ -407,14 +344,13 @@ public:
void SetDiskWriteBlocker(const DiskWriteBlocker* Monitor) { m_DiskWriteBlocker = Monitor; }
private:
- bool CheckGCCancel() { return m_CancelGC.load(); }
- LoggerRef Log() { return m_Log; }
- LoggerRef m_Log;
- mutable RwLock m_Lock;
- std::vector<GcContributor*> m_GcContribs;
- std::vector<GcStorage*> m_GcStorage;
- CidStore* m_CidStore = nullptr;
- const DiskWriteBlocker* m_DiskWriteBlocker = nullptr;
+ bool CheckGCCancel() { return m_CancelGC.load(); }
+ LoggerRef Log() { return m_Log; }
+ LoggerRef m_Log;
+ mutable RwLock m_Lock;
+ std::vector<GcStorage*> m_GcStorage;
+ CidStore* m_CidStore = nullptr;
+ const DiskWriteBlocker* m_DiskWriteBlocker = nullptr;
std::vector<GcReferencer*> m_GcReferencers;
std::vector<GcReferenceLocker*> m_GcReferencerLockers;
@@ -432,7 +368,7 @@ enum class GcSchedulerStatus : uint32_t
enum class GcVersion : uint32_t
{
- kV1,
+ kV1_Deprecated,
kV2
};
@@ -449,7 +385,7 @@ struct GcSchedulerConfig
uint64_t DiskSizeSoftLimit = 0;
uint64_t MinimumFreeDiskSpaceToAllowWrites = 1ul << 28;
std::chrono::seconds LightweightInterval{};
- GcVersion UseGCVersion = GcVersion::kV1;
+ GcVersion UseGCVersion = GcVersion::kV2;
uint32_t CompactBlockUsageThresholdPercent = 90;
bool Verbose = false;
bool SingleThreaded = false;