diff options
| author | Per Larsson <[email protected]> | 2021-11-30 15:04:05 +0100 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2021-11-30 15:04:05 +0100 |
| commit | 571b483cad2d8c97a04d1f3ccdb594eb7e4cf791 (patch) | |
| tree | 5e8004ed313ba8b5bd173045c79674edbf7ec6cd | |
| parent | Added CAS total size. (diff) | |
| download | zen-571b483cad2d8c97a04d1f3ccdb594eb7e4cf791.tar.xz zen-571b483cad2d8c97a04d1f3ccdb594eb7e4cf791.zip | |
Added CacheStore and CAS store sizes to status endpoint.
| -rw-r--r-- | zenserver/cache/structuredcache.cpp | 18 | ||||
| -rw-r--r-- | zenserver/cache/structuredcachestore.cpp | 16 | ||||
| -rw-r--r-- | zenstore/cidstore.cpp | 6 | ||||
| -rw-r--r-- | zenstore/gc.cpp | 2 | ||||
| -rw-r--r-- | zenstore/include/zenstore/cidstore.h | 1 |
5 files changed, 35 insertions, 8 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) diff --git a/zenstore/cidstore.cpp b/zenstore/cidstore.cpp index c91f69ff7..4ddf34c79 100644 --- a/zenstore/cidstore.cpp +++ b/zenstore/cidstore.cpp @@ -289,4 +289,10 @@ CidStore::Scrub(ScrubContext& Ctx) m_Impl->Scrub(Ctx); } +CasStoreSize +CidStore::CasSize() const +{ + return m_Impl->m_CasStore.TotalSize(); +} + } // namespace zen diff --git a/zenstore/gc.cpp b/zenstore/gc.cpp index 52bb33955..5c2ee2daa 100644 --- a/zenstore/gc.cpp +++ b/zenstore/gc.cpp @@ -138,7 +138,7 @@ CasGc::CollectGarbage() // First gather reference set GcContext GcCtx; - GcCtx.SetDeletionMode(false); + GcCtx.SetDeletionMode(true); for (GcContributor* Contributor : m_GcContribs) { diff --git a/zenstore/include/zenstore/cidstore.h b/zenstore/include/zenstore/cidstore.h index a69569bd2..4dd83f24e 100644 --- a/zenstore/include/zenstore/cidstore.h +++ b/zenstore/include/zenstore/cidstore.h @@ -54,6 +54,7 @@ public: bool ContainsChunk(const IoHash& DecompressedId); void Flush(); void Scrub(ScrubContext& Ctx); + CasStoreSize CasSize() const; // TODO: add batch filter support |