From bf20e4c8e63638792e69098d4d9810c1136ff627 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Thu, 28 Sep 2023 23:57:31 +0200 Subject: adding more stats (#429) - Feature: Add detailed stats on requests and data sizes on a per-bucket level, use parameter `cachestorestats=true` on the `/stats/z$` endpoint to enable - Feature: Add detailed stats on requests and data sizes on cidstore, use parameter `cidstorestats=true` on the `/stats/z$` endpoint to enable - Feature: Dashboard now accepts parameters in the URL which is passed on to the `/stats/z$` endpoint --- src/zenserver/cache/cachedisklayer.cpp | 59 +++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 8 deletions(-) (limited to 'src/zenserver/cache/cachedisklayer.cpp') diff --git a/src/zenserver/cache/cachedisklayer.cpp b/src/zenserver/cache/cachedisklayer.cpp index 9e6f86d79..3cee3197b 100644 --- a/src/zenserver/cache/cachedisklayer.cpp +++ b/src/zenserver/cache/cachedisklayer.cpp @@ -662,10 +662,13 @@ ZenCacheDiskLayer::CacheBucket::GetStandaloneCacheValue(const DiskLocation& Loc, bool ZenCacheDiskLayer::CacheBucket::Get(const IoHash& HashKey, ZenCacheValue& OutValue) { + metrics::RequestStats::Scope StatsScope(m_GetOps, 0); + RwLock::SharedLockScope _(m_IndexLock); auto It = m_Index.find(HashKey); if (It == m_Index.end()) { + m_MissCount++; return false; } size_t EntryIndex = It.value(); @@ -710,18 +713,31 @@ ZenCacheDiskLayer::CacheBucket::Get(const IoHash& HashKey, ZenCacheValue& OutVal } } } - - return (bool)OutValue.Value; + if (OutValue.Value) + { + m_HitCount++; + StatsScope.SetBytes(OutValue.Value.GetSize()); + return true; + } + else + { + m_MissCount++; + return false; + } } void ZenCacheDiskLayer::CacheBucket::Put(const IoHash& HashKey, const ZenCacheValue& Value) { + metrics::RequestStats::Scope $(m_PutOps, Value.Value.Size()); + if (Value.Value.Size() >= m_LargeObjectThreshold) { return PutStandaloneCacheValue(HashKey, Value); } PutInlineCacheValue(HashKey, Value); + + m_WriteCount++; } bool @@ -1568,6 +1584,17 @@ ZenCacheDiskLayer::CacheBucket::UpdateAccessTimes(const std::vectorStats()}); + } + } + return Stats; +} + ZenCacheDiskLayer::Info ZenCacheDiskLayer::GetInfo() const { ZenCacheDiskLayer::Info Info = {.Config = {.RootDir = m_RootDir}, .TotalSize = TotalSize()}; - - RwLock::SharedLockScope _(m_Lock); - Info.BucketNames.reserve(m_Buckets.size()); - for (auto& Kv : m_Buckets) { - Info.BucketNames.push_back(Kv.first); - Info.EntryCount += Kv.second->EntryCount(); + RwLock::SharedLockScope _(m_Lock); + Info.BucketNames.reserve(m_Buckets.size()); + for (auto& Kv : m_Buckets) + { + Info.BucketNames.push_back(Kv.first); + Info.EntryCount += Kv.second->EntryCount(); + } } return Info; } -- cgit v1.2.3