diff options
| author | Dan Engelbrecht <[email protected]> | 2023-09-14 13:41:06 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-09-14 19:41:06 +0200 |
| commit | b57cb102bdbba3ef3fbcb3d9c66b78e7ca406891 (patch) | |
| tree | 812c13d3a2ff6c1c617fddb401845a744f13fcd5 /src/zenstore | |
| parent | enable sentry personal information (ip/username) on shared instances (#404) (diff) | |
| download | zen-b57cb102bdbba3ef3fbcb3d9c66b78e7ca406891.tar.xz zen-b57cb102bdbba3ef3fbcb3d9c66b78e7ca406891.zip | |
More statistics for Cache, Project Store and Cid Store (#405)
Cache: requestcount, badrequestcount, writes
Project Store: requestcount
Cid Store: cidhits, cidmisses, cidwrites
Diffstat (limited to 'src/zenstore')
| -rw-r--r-- | src/zenstore/cidstore.cpp | 31 | ||||
| -rw-r--r-- | src/zenstore/include/zenstore/cidstore.h | 24 |
2 files changed, 45 insertions, 10 deletions
diff --git a/src/zenstore/cidstore.cpp b/src/zenstore/cidstore.cpp index 734ae8433..e366a6cb4 100644 --- a/src/zenstore/cidstore.cpp +++ b/src/zenstore/cidstore.cpp @@ -35,11 +35,26 @@ struct CidStore::Impl Payload.SetContentType(ZenContentType::kCompressedBinary); CasStore::InsertResult Result = m_CasStore.InsertChunk(Payload, RawHash, static_cast<CasStore::InsertMode>(Mode)); - + if (Result.New) + { + WriteCount++; + } return {.New = Result.New}; } - IoBuffer FindChunkByCid(const IoHash& DecompressedId) { return m_CasStore.FindChunk(DecompressedId); } + IoBuffer FindChunkByCid(const IoHash& DecompressedId) + { + IoBuffer Result = m_CasStore.FindChunk(DecompressedId); + if (Result) + { + HitCount++; + } + else + { + MissCount++; + } + return Result; + } bool ContainsChunk(const IoHash& DecompressedId) { return m_CasStore.ContainsChunk(DecompressedId); } @@ -62,6 +77,12 @@ struct CidStore::Impl m_CasStore.ScrubStorage(Ctx); } + CidStoreStats Stats() { return CidStoreStats{.HitCount = HitCount, .MissCount = MissCount, .WriteCount = WriteCount}; } + + std::atomic_uint64_t HitCount{}; + std::atomic_uint64_t MissCount{}; + std::atomic_uint64_t WriteCount{}; + uint64_t m_LastScrubTime = 0; }; @@ -123,4 +144,10 @@ CidStore::TotalSize() const return m_Impl->m_CasStore.TotalSize(); } +CidStoreStats +CidStore::Stats() const +{ + return m_Impl->Stats(); +} + } // namespace zen diff --git a/src/zenstore/include/zenstore/cidstore.h b/src/zenstore/include/zenstore/cidstore.h index 38815ed15..945f5d25a 100644 --- a/src/zenstore/include/zenstore/cidstore.h +++ b/src/zenstore/include/zenstore/cidstore.h @@ -29,6 +29,13 @@ struct CidStoreSize uint64_t TotalSize = 0; }; +struct CidStoreStats +{ + uint64_t HitCount; + uint64_t MissCount; + uint64_t WriteCount; +}; + struct CidStoreConfiguration { // Root directory for CAS store @@ -65,14 +72,15 @@ public: kMayBeMovedInPlace }; - void Initialize(const CidStoreConfiguration& Config); - InsertResult AddChunk(const IoBuffer& ChunkData, const IoHash& RawHash, InsertMode Mode = InsertMode::kMayBeMovedInPlace); - IoBuffer FindChunkByCid(const IoHash& DecompressedId); - bool ContainsChunk(const IoHash& DecompressedId); - void FilterChunks(HashKeySet& InOutChunks); - void Flush(); - void ScrubStorage(ScrubContext& Ctx); - CidStoreSize TotalSize() const; + void Initialize(const CidStoreConfiguration& Config); + InsertResult AddChunk(const IoBuffer& ChunkData, const IoHash& RawHash, InsertMode Mode = InsertMode::kMayBeMovedInPlace); + IoBuffer FindChunkByCid(const IoHash& DecompressedId); + bool ContainsChunk(const IoHash& DecompressedId); + void FilterChunks(HashKeySet& InOutChunks); + void Flush(); + void ScrubStorage(ScrubContext& Ctx); + CidStoreSize TotalSize() const; + CidStoreStats Stats() const; private: struct Impl; |