aboutsummaryrefslogtreecommitdiff
path: root/zenserver/cache
diff options
context:
space:
mode:
authorPer Larsson <[email protected]>2021-11-30 15:04:05 +0100
committerPer Larsson <[email protected]>2021-11-30 15:04:05 +0100
commit571b483cad2d8c97a04d1f3ccdb594eb7e4cf791 (patch)
tree5e8004ed313ba8b5bd173045c79674edbf7ec6cd /zenserver/cache
parentAdded CAS total size. (diff)
downloadzen-571b483cad2d8c97a04d1f3ccdb594eb7e4cf791.tar.xz
zen-571b483cad2d8c97a04d1f3ccdb594eb7e4cf791.zip
Added CacheStore and CAS store sizes to status endpoint.
Diffstat (limited to 'zenserver/cache')
-rw-r--r--zenserver/cache/structuredcache.cpp18
-rw-r--r--zenserver/cache/structuredcachestore.cpp16
2 files changed, 27 insertions, 7 deletions
diff --git a/zenserver/cache/structuredcache.cpp b/zenserver/cache/structuredcache.cpp
index 53e1b1c61..fe3f44e00 100644
--- a/zenserver/cache/structuredcache.cpp
+++ b/zenserver/cache/structuredcache.cpp
@@ -1192,7 +1192,16 @@ HttpStructuredCacheService::HandleStatsRequest(zen::HttpServerRequest& Request)
const uint64_t MissCount = m_CacheStats.MissCount;
const uint64_t TotalCount = HitCount + MissCount;
+ const CasStoreSize CasSize = m_CidStore.CasSize();
+ const ZenCacheSize CacheSize = m_CacheStore.TotalSize();
+
Cbo.BeginObject("cache");
+ Cbo.BeginObject("size");
+ Cbo << "disk" << CacheSize.DiskSize;
+ Cbo << "memory" << CacheSize.MemorySize;
+ Cbo.EndObject();
+ Cbo << "upstream_ratio" << (HitCount > 0 ? (double(UpstreamHitCount) / double(HitCount)) : 0.0);
+ Cbo << "cas_tiny_size" << CasSize.TinySize;
Cbo << "hits" << HitCount << "misses" << MissCount;
Cbo << "hit_ratio" << (TotalCount > 0 ? (double(HitCount) / double(TotalCount)) : 0.0);
Cbo << "upstream_hits" << m_CacheStats.UpstreamHitCount;
@@ -1206,6 +1215,15 @@ HttpStructuredCacheService::HandleStatsRequest(zen::HttpServerRequest& Request)
Cbo.EndObject();
}
+ Cbo.BeginObject("cas");
+ Cbo.BeginObject("size");
+ Cbo << "tiny" << CasSize.TinySize;
+ Cbo << "small" << CasSize.SmallSize;
+ Cbo << "large" << CasSize.LargeSize;
+ Cbo << "total" << CasSize.TotalSize;
+ Cbo.EndObject();
+ Cbo.EndObject();
+
Request.WriteResponse(HttpResponseCode::OK, Cbo.Save());
}
diff --git a/zenserver/cache/structuredcachestore.cpp b/zenserver/cache/structuredcachestore.cpp
index ed6b065b5..62c59a0ef 100644
--- a/zenserver/cache/structuredcachestore.cpp
+++ b/zenserver/cache/structuredcachestore.cpp
@@ -568,19 +568,21 @@ ZenCacheDiskLayer::CacheBucket::OpenOrCreate(std::filesystem::path BucketDir, bo
if (RwLock::ExclusiveLockScope _(m_IndexLock); m_Index.empty())
{
- m_SlogFile.Replay([&](const DiskIndexEntry& Record) {
- if (Record.Key == IoHash::Zero)
+ m_SlogFile.Replay([&](const DiskIndexEntry& Entry) {
+ if (Entry.Key == IoHash::Zero)
{
++InvalidEntryCount;
- m_TotalSize.fetch_sub(Record.Location.Size());
+ }
+ else if (Entry.Location.IsFlagSet(DiskLocation::kTombStone))
+ {
+ m_TotalSize.fetch_sub(Entry.Location.Size());
}
else
{
- m_Index[Record.Key] = Record.Location;
-
- MaxFileOffset = std::max<uint64_t>(MaxFileOffset, Record.Location.Offset() + Record.Location.Size());
- m_TotalSize.fetch_add(Record.Location.Size());
+ m_Index[Entry.Key] = Entry.Location;
+ m_TotalSize.fetch_add(Entry.Location.Size());
}
+ MaxFileOffset = std::max<uint64_t>(MaxFileOffset, Entry.Location.Offset() + Entry.Location.Size());
});
if (InvalidEntryCount)