aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/cache/cachedisklayer.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenserver/cache/cachedisklayer.h')
-rw-r--r--src/zenserver/cache/cachedisklayer.h34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/zenserver/cache/cachedisklayer.h b/src/zenserver/cache/cachedisklayer.h
index fc4d8cd6f..80c643afa 100644
--- a/src/zenserver/cache/cachedisklayer.h
+++ b/src/zenserver/cache/cachedisklayer.h
@@ -4,6 +4,7 @@
#include "cacheshared.h"
+#include <zencore/stats.h>
#include <zenstore/blockstore.h>
#include <zenstore/caslog.h>
@@ -106,6 +107,27 @@ public:
uint64_t TotalSize = 0;
};
+ struct BucketStats
+ {
+ uint64_t TotalSize;
+ uint64_t HitCount;
+ uint64_t MissCount;
+ uint64_t WriteCount;
+ metrics::RequestStatsSnapshot PutOps;
+ metrics::RequestStatsSnapshot GetOps;
+ };
+
+ struct NamedBucketStats
+ {
+ std::string BucketName;
+ BucketStats Stats;
+ };
+
+ struct DiskStats
+ {
+ std::vector<NamedBucketStats> BucketStats;
+ };
+
explicit ZenCacheDiskLayer(const std::filesystem::path& RootDir);
~ZenCacheDiskLayer();
@@ -119,8 +141,9 @@ public:
void CollectGarbage(GcContext& GcCtx);
void UpdateAccessTimes(const zen::access_tracking::AccessTimes& AccessTimes);
- void DiscoverBuckets();
- uint64_t TotalSize() const;
+ void DiscoverBuckets();
+ uint64_t TotalSize() const;
+ DiskStats Stats() const;
Info GetInfo() const;
std::optional<BucketInfo> GetBucketInfo(std::string_view Bucket) const;
@@ -150,6 +173,7 @@ private:
inline uint64_t TotalSize() const { return m_TotalStandaloneSize.load(std::memory_order::relaxed) + m_BlockStore.TotalSize(); }
uint64_t EntryCount() const;
+ BucketStats Stats();
CacheValueDetails::BucketDetails GetValueDetails(const std::string_view ValueFilter) const;
void EnumerateBucketContents(std::function<void(const IoHash& Key, const CacheValueDetails::ValueDetails& Details)>& Fn) const;
@@ -184,6 +208,12 @@ private:
using IndexMap = tsl::robin_map<IoHash, size_t, IoHash::Hasher>;
+ std::atomic<uint64_t> m_HitCount;
+ std::atomic<uint64_t> m_MissCount;
+ std::atomic<uint64_t> m_WriteCount;
+ metrics::RequestStats m_PutOps;
+ metrics::RequestStats m_GetOps;
+
mutable RwLock m_IndexLock;
std::vector<AccessTime> m_AccessTimes;
std::vector<BucketPayload> m_Payloads;