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/cidstore.cpp | |
| 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/cidstore.cpp')
| -rw-r--r-- | src/zenstore/cidstore.cpp | 31 |
1 files changed, 29 insertions, 2 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 |