aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenstore')
-rw-r--r--src/zenstore/blockstore.cpp19
-rw-r--r--src/zenstore/cache/cachedisklayer.cpp15
-rw-r--r--src/zenstore/cache/cacherpc.cpp20
-rw-r--r--src/zenstore/cache/structuredcachestore.cpp27
-rw-r--r--src/zenstore/cas.cpp20
-rw-r--r--src/zenstore/compactcas.cpp34
-rw-r--r--src/zenstore/filecas.cpp26
-rw-r--r--src/zenstore/gc.cpp30
8 files changed, 191 insertions, 0 deletions
diff --git a/src/zenstore/blockstore.cpp b/src/zenstore/blockstore.cpp
index 5f2f5cba0..9ad672060 100644
--- a/src/zenstore/blockstore.cpp
+++ b/src/zenstore/blockstore.cpp
@@ -26,10 +26,20 @@ ZEN_THIRD_PARTY_INCLUDES_END
# include <random>
#endif
+#include <zencore/memory/llm.h>
+
//////////////////////////////////////////////////////////////////////////
namespace zen {
+const FLLMTag&
+GetBlocksTag()
+{
+ static FLLMTag _("blocks");
+
+ return _;
+}
+
//////////////////////////////////////////////////////////////////////////
BlockStoreFile::BlockStoreFile(const std::filesystem::path& BlockPath) : m_Path(BlockPath)
@@ -266,6 +276,7 @@ BlockStore::~BlockStore()
void
BlockStore::Initialize(const std::filesystem::path& BlocksBasePath, uint64_t MaxBlockSize, uint64_t MaxBlockCount)
{
+ ZEN_MEMSCOPE(GetBlocksTag());
ZEN_TRACE_CPU("BlockStore::Initialize");
ZEN_ASSERT(MaxBlockSize > 0);
@@ -332,6 +343,7 @@ BlockStore::Initialize(const std::filesystem::path& BlocksBasePath, uint64_t Max
void
BlockStore::SyncExistingBlocksOnDisk(const BlockIndexSet& KnownBlocks)
{
+ ZEN_MEMSCOPE(GetBlocksTag());
ZEN_TRACE_CPU("BlockStore::SyncExistingBlocksOnDisk");
RwLock::ExclusiveLockScope InsertLock(m_InsertLock);
@@ -378,6 +390,7 @@ BlockStore::SyncExistingBlocksOnDisk(const BlockIndexSet& KnownBlocks)
BlockStore::BlockEntryCountMap
BlockStore::GetBlocksToCompact(const BlockUsageMap& BlockUsage, uint32_t BlockUsageThresholdPercent)
{
+ ZEN_MEMSCOPE(GetBlocksTag());
ZEN_TRACE_CPU("BlockStoreFile::GetBlocksToCompact");
BlockEntryCountMap Result;
{
@@ -507,6 +520,7 @@ BlockStore::GetFreeBlockIndex(uint32_t ProbeIndex, RwLock::ExclusiveLockScope&,
void
BlockStore::WriteChunk(const void* Data, uint64_t Size, uint32_t Alignment, const WriteChunkCallback& Callback)
{
+ ZEN_MEMSCOPE(GetBlocksTag());
ZEN_TRACE_CPU("BlockStore::WriteChunk");
ZEN_ASSERT(Data != nullptr);
@@ -565,6 +579,7 @@ BlockStore::WriteChunk(const void* Data, uint64_t Size, uint32_t Alignment, cons
void
BlockStore::WriteChunks(std::span<IoBuffer> Datas, uint32_t Alignment, const WriteChunksCallback& Callback)
{
+ ZEN_MEMSCOPE(GetBlocksTag());
ZEN_TRACE_CPU("BlockStore::WriteChunks");
ZEN_ASSERT(!Datas.empty());
@@ -680,6 +695,7 @@ BlockStore::TryGetChunk(const BlockStoreLocation& Location) const
void
BlockStore::Flush(bool ForceNewBlock)
{
+ ZEN_MEMSCOPE(GetBlocksTag());
ZEN_TRACE_CPU("BlockStore::Flush");
if (ForceNewBlock)
@@ -710,6 +726,7 @@ BlockStore::IterateBlock(std::span<const BlockStoreLocation> ChunkLocations,
const IterateChunksLargeSizeCallback& LargeSizeCallback,
uint64_t LargeSizeLimit)
{
+ ZEN_MEMSCOPE(GetBlocksTag());
ZEN_TRACE_CPU("BlockStore::IterateBlock");
if (InChunkIndexes.empty())
@@ -861,6 +878,7 @@ BlockStore::IterateBlock(std::span<const BlockStoreLocation> ChunkLocations,
bool
BlockStore::IterateChunks(const std::span<const BlockStoreLocation>& ChunkLocations, const IterateChunksCallback& Callback)
{
+ ZEN_MEMSCOPE(GetBlocksTag());
ZEN_TRACE_CPU("BlockStore::IterateChunks");
Stopwatch Timer;
@@ -914,6 +932,7 @@ BlockStore::CompactBlocks(const BlockStoreCompactState& CompactState,
const ClaimDiskReserveCallback& DiskReserveCallback,
std::string_view LogPrefix)
{
+ ZEN_MEMSCOPE(GetBlocksTag());
ZEN_TRACE_CPU("BlockStore::CompactBlocks");
uint64_t DeletedSize = 0;
diff --git a/src/zenstore/cache/cachedisklayer.cpp b/src/zenstore/cache/cachedisklayer.cpp
index 3046ab87c..a4f9fe78b 100644
--- a/src/zenstore/cache/cachedisklayer.cpp
+++ b/src/zenstore/cache/cachedisklayer.cpp
@@ -22,8 +22,18 @@
//////////////////////////////////////////////////////////////////////////
+#include <zencore/memory/llm.h>
+
namespace zen {
+const FLLMTag&
+GetCacheDiskTag()
+{
+ static FLLMTag _("disk", FLLMTag("cache"));
+
+ return _;
+}
+
namespace {
#pragma pack(push)
@@ -3894,6 +3904,8 @@ ZenCacheDiskLayer::DiscoverBuckets()
{
WorkLatch.AddCount(1);
Pool.ScheduleWork([this, &WorkLatch, &SyncLock, BucketPath]() {
+ ZEN_MEMSCOPE(GetCacheDiskTag());
+
auto _ = MakeGuard([&]() { WorkLatch.CountDown(); });
const std::string BucketName = PathToUtf8(BucketPath.stem());
try
@@ -3980,6 +3992,7 @@ ZenCacheDiskLayer::Drop()
void
ZenCacheDiskLayer::Flush()
{
+ ZEN_MEMSCOPE(GetCacheDiskTag());
ZEN_TRACE_CPU("Z$::Flush");
std::vector<CacheBucket*> Buckets;
@@ -4010,6 +4023,8 @@ ZenCacheDiskLayer::Flush()
{
WorkLatch.AddCount(1);
Pool.ScheduleWork([&WorkLatch, Bucket]() {
+ ZEN_MEMSCOPE(GetCacheDiskTag());
+
auto _ = MakeGuard([&]() { WorkLatch.CountDown(); });
try
{
diff --git a/src/zenstore/cache/cacherpc.cpp b/src/zenstore/cache/cacherpc.cpp
index 2a7721fe2..54c2ff7d0 100644
--- a/src/zenstore/cache/cacherpc.cpp
+++ b/src/zenstore/cache/cacherpc.cpp
@@ -17,10 +17,28 @@
#include <zenutil/cache/cacherequests.h>
#include <zenutil/packageformat.h>
+#include <zencore/memory/llm.h>
+
//////////////////////////////////////////////////////////////////////////
namespace zen {
+const FLLMTag&
+GetCacheTag()
+{
+ static FLLMTag CacheTag("cache");
+
+ return CacheTag;
+}
+
+const FLLMTag&
+GetCacheRpcTag()
+{
+ static FLLMTag CacheRpcTag("rpc", GetCacheTag());
+
+ return CacheRpcTag;
+}
+
using namespace std::literals;
std::optional<std::string>
@@ -165,6 +183,8 @@ CacheRpcHandler::HandleRpcRequest(const CacheRequestContext& Context,
{
ZEN_TRACE_CPU("Z$::HandleRpcRequest");
+ ZEN_MEMSCOPE(GetCacheRpcTag());
+
m_CacheStats.RpcRequests.fetch_add(1);
CbPackage Package;
diff --git a/src/zenstore/cache/structuredcachestore.cpp b/src/zenstore/cache/structuredcachestore.cpp
index 512f1d7f2..c14ea73a8 100644
--- a/src/zenstore/cache/structuredcachestore.cpp
+++ b/src/zenstore/cache/structuredcachestore.cpp
@@ -42,8 +42,20 @@ ZEN_THIRD_PARTY_INCLUDES_END
# include <unordered_map>
#endif
+#include <zencore/memory/llm.h>
+
+//////////////////////////////////////////////////////////////////////////
+
namespace zen {
+const FLLMTag&
+GetCacheStoreTag()
+{
+ static FLLMTag _("store", FLLMTag("cache"));
+
+ return _;
+}
+
bool
IsKnownBadBucketName(std::string_view Bucket)
{
@@ -122,6 +134,7 @@ ZenCacheNamespace::ZenCacheNamespace(GcManager& Gc, JobQueue& JobQueue, const st
, m_Configuration(Config)
, m_DiskLayer(m_Gc, m_JobQueue, m_RootDir, m_Configuration.DiskLayerConfig)
{
+ ZEN_MEMSCOPE(GetCacheStoreTag());
ZEN_INFO("initializing structured cache at '{}'", m_RootDir);
CreateDirectories(m_RootDir);
@@ -403,6 +416,8 @@ ZenCacheStore::ZenCacheStore(GcManager& Gc,
, m_Configuration(Configuration)
, m_ExitLogging(false)
{
+ ZEN_MEMSCOPE(GetCacheStoreTag());
+
SetLoggingConfig(m_Configuration.Logging);
CreateDirectories(m_BasePath);
@@ -459,6 +474,8 @@ ZenCacheStore::LogWorker()
{
SetCurrentThreadName("ZenCacheStore::LogWorker");
+ ZEN_MEMSCOPE(GetCacheStoreTag());
+
LoggerRef ZCacheLog(logging::Get("z$"));
auto Log = [&ZCacheLog]() -> LoggerRef { return ZCacheLog; };
@@ -539,6 +556,7 @@ ZenCacheStore::LogWorker()
ZenCacheStore::PutBatch::PutBatch(ZenCacheStore& CacheStore, std::string_view InNamespace, std::vector<bool>& OutResult)
: m_CacheStore(CacheStore)
{
+ ZEN_MEMSCOPE(GetCacheStoreTag());
if (m_Store = m_CacheStore.GetNamespace(InNamespace); m_Store)
{
m_NamespaceBatchHandle = m_Store->BeginPutBatch(OutResult);
@@ -551,6 +569,7 @@ ZenCacheStore::PutBatch::~PutBatch()
{
if (m_Store)
{
+ ZEN_MEMSCOPE(GetCacheStoreTag());
ZEN_ASSERT(m_NamespaceBatchHandle);
m_Store->EndPutBatch(m_NamespaceBatchHandle);
}
@@ -565,6 +584,7 @@ ZenCacheStore::GetBatch::GetBatch(ZenCacheStore& CacheStore, std::string_view In
: m_CacheStore(CacheStore)
, Results(OutResult)
{
+ ZEN_MEMSCOPE(GetCacheStoreTag());
if (m_Store = m_CacheStore.GetNamespace(InNamespace); m_Store)
{
m_NamespaceBatchHandle = m_Store->BeginGetBatch(OutResult);
@@ -577,6 +597,7 @@ ZenCacheStore::GetBatch::~GetBatch()
{
if (m_Store)
{
+ ZEN_MEMSCOPE(GetCacheStoreTag());
ZEN_ASSERT(m_NamespaceBatchHandle);
m_Store->EndGetBatch(m_NamespaceBatchHandle);
@@ -613,6 +634,7 @@ ZenCacheStore::Get(const CacheRequestContext& Context,
return false;
}
+ ZEN_MEMSCOPE(GetCacheStoreTag());
ZEN_TRACE_CPU("Z$::Get");
metrics::RequestStats::Scope OpScope(m_GetOps, 0);
@@ -673,6 +695,8 @@ ZenCacheStore::Get(const CacheRequestContext& Context,
m_RejectedReadCount++;
return;
}
+
+ ZEN_MEMSCOPE(GetCacheStoreTag());
ZEN_TRACE_CPU("Z$::Get");
metrics::RequestStats::Scope OpScope(m_GetOps, 0);
@@ -709,6 +733,7 @@ ZenCacheStore::Put(const CacheRequestContext& Context,
return;
}
+ ZEN_MEMSCOPE(GetCacheStoreTag());
ZEN_TRACE_CPU("Z$::Put");
metrics::RequestStats::Scope $(m_PutOps, Value.Value.GetSize());
@@ -776,6 +801,8 @@ ZenCacheStore::DropNamespace(std::string_view InNamespace)
void
ZenCacheStore::Flush()
{
+ ZEN_MEMSCOPE(GetCacheStoreTag());
+
ZEN_INFO("flushing cache store at '{}'", m_BasePath);
IterateNamespaces([&](std::string_view, ZenCacheNamespace& Store) { Store.Flush(); });
}
diff --git a/src/zenstore/cas.cpp b/src/zenstore/cas.cpp
index 4c1836cf7..7beac31e1 100644
--- a/src/zenstore/cas.cpp
+++ b/src/zenstore/cas.cpp
@@ -33,8 +33,20 @@
//////////////////////////////////////////////////////////////////////////
+#include <zencore/memory/llm.h>
+
+//////////////////////////////////////////////////////////////////////////
+
namespace zen {
+const FLLMTag&
+GetCasTag()
+{
+ static FLLMTag _("cas");
+
+ return _;
+}
+
/**
* CAS store implementation
*
@@ -97,6 +109,8 @@ CasImpl::~CasImpl()
void
CasImpl::Initialize(const CidStoreConfiguration& InConfig)
{
+ ZEN_MEMSCOPE(GetCasTag());
+
ZEN_TRACE_CPU("CAS::Initialize");
m_Config = InConfig;
@@ -226,6 +240,7 @@ CasImpl::UpdateManifest()
CasStore::InsertResult
CasImpl::InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash, InsertMode Mode)
{
+ ZEN_MEMSCOPE(GetCasTag());
ZEN_TRACE_CPU("CAS::InsertChunk");
const uint64_t ChunkSize = Chunk.Size();
@@ -294,6 +309,7 @@ GetFileCasResults(FileCasStrategy& Strategy,
std::vector<CasStore::InsertResult>
CasImpl::InsertChunks(std::span<IoBuffer> Data, std::span<IoHash> ChunkHashes, CasStore::InsertMode Mode)
{
+ ZEN_MEMSCOPE(GetCasTag());
ZEN_TRACE_CPU("CAS::InsertChunks");
ZEN_ASSERT(Data.size() == ChunkHashes.size());
@@ -448,6 +464,8 @@ CasImpl::Flush()
void
CasImpl::ScrubStorage(ScrubContext& Ctx)
{
+ ZEN_MEMSCOPE(GetCasTag());
+
ZEN_TRACE_CPU("Cas::ScrubStorage");
if (m_LastScrubTime == Ctx.ScrubTimestamp())
@@ -477,6 +495,8 @@ CasImpl::TotalSize() const
std::unique_ptr<CasStore>
CreateCasStore(GcManager& Gc)
{
+ ZEN_MEMSCOPE(GetCasTag());
+
return std::make_unique<CasImpl>(Gc);
}
diff --git a/src/zenstore/compactcas.cpp b/src/zenstore/compactcas.cpp
index 9982e7571..f85b19264 100644
--- a/src/zenstore/compactcas.cpp
+++ b/src/zenstore/compactcas.cpp
@@ -10,6 +10,7 @@
#include <zencore/fmtutils.h>
#include <zencore/iobuffer.h>
#include <zencore/logging.h>
+#include <zencore/memory/llm.h>
#include <zencore/scopeguard.h>
#include <zencore/trace.h>
#include <zencore/workthreadpool.h>
@@ -36,6 +37,14 @@ ZEN_THIRD_PARTY_INCLUDES_END
namespace zen {
+const FLLMTag&
+GetCasContainerTag()
+{
+ static FLLMTag _("container", FLLMTag("cas"));
+
+ return _;
+}
+
struct CasDiskIndexHeader
{
static constexpr uint32_t ExpectedMagic = 0x75696478; // 'uidx';
@@ -124,6 +133,8 @@ static const float IndexMaxLoadFactor = 0.7f;
CasContainerStrategy::CasContainerStrategy(GcManager& Gc) : m_Log(logging::Get("containercas")), m_Gc(Gc)
{
+ ZEN_MEMSCOPE(GetCasContainerTag());
+
m_LocationMap.min_load_factor(IndexMinLoadFactor);
m_LocationMap.max_load_factor(IndexMaxLoadFactor);
@@ -144,6 +155,8 @@ CasContainerStrategy::Initialize(const std::filesystem::path& RootDirectory,
uint32_t Alignment,
bool IsNewStore)
{
+ ZEN_MEMSCOPE(GetCasContainerTag());
+
ZEN_ASSERT(IsPow2(Alignment));
ZEN_ASSERT(!m_IsInitialized);
ZEN_ASSERT(MaxBlockSize > 0);
@@ -171,6 +184,8 @@ CasContainerStrategy::InsertChunk(const void* ChunkData, size_t ChunkSize, const
}
}
+ ZEN_MEMSCOPE(GetCasContainerTag());
+
// We can end up in a situation that InsertChunk writes the same chunk data in
// different locations.
// We release the insert lock once we have the correct WriteBlock ready and we know
@@ -201,6 +216,8 @@ CasContainerStrategy::InsertChunk(const void* ChunkData, size_t ChunkSize, const
CasStore::InsertResult
CasContainerStrategy::InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash)
{
+ ZEN_MEMSCOPE(GetCasContainerTag());
+
#if !ZEN_WITH_TESTS
ZEN_ASSERT(Chunk.GetContentType() == ZenContentType::kCompressedBinary);
#endif
@@ -210,6 +227,8 @@ CasContainerStrategy::InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash)
std::vector<CasStore::InsertResult>
CasContainerStrategy::InsertChunks(std::span<IoBuffer> Chunks, std::span<IoHash> ChunkHashes)
{
+ ZEN_MEMSCOPE(GetCasContainerTag());
+
ZEN_ASSERT(Chunks.size() == ChunkHashes.size());
std::vector<CasStore::InsertResult> Result(Chunks.size());
std::vector<size_t> NewChunkIndexes;
@@ -308,6 +327,8 @@ CasContainerStrategy::IterateChunks(std::span<IoHash> ChunkHashes,
WorkerThreadPool* OptionalWorkerPool,
uint64_t LargeSizeLimit)
{
+ ZEN_MEMSCOPE(GetCasContainerTag());
+
const size_t ChunkCount = ChunkHashes.size();
if (ChunkCount < 3)
{
@@ -407,6 +428,8 @@ CasContainerStrategy::IterateChunks(std::span<IoHash> ChunkHashes,
void
CasContainerStrategy::Flush()
{
+ ZEN_MEMSCOPE(GetCasContainerTag());
+
ZEN_TRACE_CPU("CasContainer::Flush");
m_BlockStore.Flush(/*ForceNewBlock*/ false);
m_CasLog.Flush();
@@ -416,6 +439,8 @@ CasContainerStrategy::Flush()
void
CasContainerStrategy::ScrubStorage(ScrubContext& Ctx)
{
+ ZEN_MEMSCOPE(GetCasContainerTag());
+
ZEN_TRACE_CPU("CasContainer::ScrubStorage");
if (Ctx.IsSkipCas())
@@ -563,6 +588,8 @@ public:
virtual void CompactStore(GcCtx& Ctx, GcCompactStoreStats& Stats, const std::function<uint64_t()>& ClaimDiskReserveCallback) override
{
+ ZEN_MEMSCOPE(GetCasContainerTag());
+
ZEN_TRACE_CPU("CasContainer::CompactStore");
auto Log = [&Ctx]() { return Ctx.Logger; };
@@ -717,6 +744,7 @@ public:
GcStats& Stats,
const GetUnusedReferencesFunc& GetUnusedReferences) override
{
+ ZEN_MEMSCOPE(GetCasContainerTag());
ZEN_TRACE_CPU("CasContainer::RemoveUnreferencedData");
auto Log = [&Ctx]() { return Ctx.Logger; };
@@ -799,6 +827,7 @@ CasContainerStrategy::GetGcName(GcCtx&)
GcReferencePruner*
CasContainerStrategy::CreateReferencePruner(GcCtx& Ctx, GcReferenceStoreStats&)
{
+ ZEN_MEMSCOPE(GetCasContainerTag());
ZEN_TRACE_CPU("CasContainer::CreateReferencePruner");
auto Log = [&Ctx]() { return Ctx.Logger; };
@@ -842,6 +871,7 @@ CasContainerStrategy::CreateReferencePruner(GcCtx& Ctx, GcReferenceStoreStats&)
void
CasContainerStrategy::CompactIndex(RwLock::ExclusiveLockScope&)
{
+ ZEN_MEMSCOPE(GetCasContainerTag());
ZEN_TRACE_CPU("CasContainer::CompactIndex");
size_t EntryCount = m_LocationMap.size();
@@ -868,6 +898,7 @@ CasContainerStrategy::StorageSize() const
void
CasContainerStrategy::MakeIndexSnapshot()
{
+ ZEN_MEMSCOPE(GetCasContainerTag());
ZEN_TRACE_CPU("CasContainer::MakeIndexSnapshot");
uint64_t LogCount = m_CasLog.GetLogCount();
@@ -981,6 +1012,7 @@ CasContainerStrategy::MakeIndexSnapshot()
uint64_t
CasContainerStrategy::ReadIndexFile(const std::filesystem::path& IndexPath, uint32_t& OutVersion)
{
+ ZEN_MEMSCOPE(GetCasContainerTag());
ZEN_TRACE_CPU("CasContainer::ReadIndexFile");
uint64_t EntryCount = 0;
@@ -1050,6 +1082,7 @@ CasContainerStrategy::ReadIndexFile(const std::filesystem::path& IndexPath, uint
uint64_t
CasContainerStrategy::ReadLog(const std::filesystem::path& LogPath, uint64_t SkipEntryCount)
{
+ ZEN_MEMSCOPE(GetCasContainerTag());
ZEN_TRACE_CPU("CasContainer::ReadLog");
if (!TCasLogFile<CasDiskIndexEntry>::IsValid(LogPath))
@@ -1106,6 +1139,7 @@ CasContainerStrategy::ReadLog(const std::filesystem::path& LogPath, uint64_t Ski
void
CasContainerStrategy::OpenContainer(bool IsNewStore)
{
+ ZEN_MEMSCOPE(GetCasContainerTag());
ZEN_TRACE_CPU("CasContainer::OpenContainer");
// Add .running file and delete on clean on close to detect bad termination
diff --git a/src/zenstore/filecas.cpp b/src/zenstore/filecas.cpp
index f64427807..339e5de0a 100644
--- a/src/zenstore/filecas.cpp
+++ b/src/zenstore/filecas.cpp
@@ -43,8 +43,20 @@ ZEN_THIRD_PARTY_INCLUDES_START
#endif
ZEN_THIRD_PARTY_INCLUDES_END
+#include <zencore/memory/llm.h>
+
+//////////////////////////////////////////////////////////////////////////
+
namespace zen {
+const FLLMTag&
+GetFileCasTag()
+{
+ static FLLMTag _("file", FLLMTag("cas"));
+
+ return _;
+}
+
namespace {
template<typename T>
void Reset(T& V)
@@ -150,6 +162,7 @@ FileCasStrategy::~FileCasStrategy()
void
FileCasStrategy::Initialize(const std::filesystem::path& RootDirectory, bool IsNewStore)
{
+ ZEN_MEMSCOPE(GetFileCasTag());
ZEN_TRACE_CPU("FileCas::Initialize");
using namespace filecas::impl;
@@ -248,6 +261,8 @@ FileCasStrategy::Initialize(const std::filesystem::path& RootDirectory, bool IsN
bool
FileCasStrategy::UpdateIndex(const IoHash& ChunkHash, uint64_t ChunkSize)
{
+ ZEN_MEMSCOPE(GetFileCasTag());
+
uint64 OldChunkSize = 0;
{
RwLock::ExclusiveLockScope _(m_Lock);
@@ -270,6 +285,8 @@ FileCasStrategy::UpdateIndex(const IoHash& ChunkHash, uint64_t ChunkSize)
CasStore::InsertResult
FileCasStrategy::InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash, CasStore::InsertMode Mode)
{
+ ZEN_MEMSCOPE(GetFileCasTag());
+
ZEN_TRACE_CPU("FileCas::InsertChunk");
ZEN_ASSERT(m_IsInitialized);
@@ -708,6 +725,8 @@ FileCasStrategy::IterateChunks(std::function<void(const IoHash& Hash, IoBuffer&&
void
FileCasStrategy::Flush()
{
+ ZEN_MEMSCOPE(GetFileCasTag());
+
ZEN_TRACE_CPU("FileCas::Flush");
m_CasLog.Flush();
@@ -717,6 +736,8 @@ FileCasStrategy::Flush()
void
FileCasStrategy::ScrubStorage(ScrubContext& Ctx)
{
+ ZEN_MEMSCOPE(GetFileCasTag());
+
ZEN_TRACE_CPU("FileCas::ScrubStorage");
if (Ctx.IsSkipCas())
@@ -896,6 +917,7 @@ FileCasStrategy::ValidateEntry(const FileCasIndexEntry& Entry, std::string& OutR
void
FileCasStrategy::MakeIndexSnapshot()
{
+ ZEN_MEMSCOPE(GetFileCasTag());
ZEN_TRACE_CPU("FileCas::MakeIndexSnapshot");
using namespace filecas::impl;
@@ -1208,6 +1230,7 @@ public:
virtual void CompactStore(GcCtx& Ctx, GcCompactStoreStats& Stats, const std::function<uint64_t()>&) override
{
+ ZEN_MEMSCOPE(GetFileCasTag());
ZEN_TRACE_CPU("FileCas::CompactStore");
auto Log = [&Ctx]() { return Ctx.Logger; };
@@ -1351,6 +1374,7 @@ public:
GcStats& Stats,
const GetUnusedReferencesFunc& GetUnusedReferences) override
{
+ ZEN_MEMSCOPE(GetFileCasTag());
ZEN_TRACE_CPU("FileCas::RemoveUnreferencedData");
auto Log = [&Ctx]() { return Ctx.Logger; };
@@ -1432,6 +1456,8 @@ FileCasStrategy::GetGcName(GcCtx&)
GcReferencePruner*
FileCasStrategy::CreateReferencePruner(GcCtx& Ctx, GcReferenceStoreStats&)
{
+ ZEN_MEMSCOPE(GetFileCasTag());
+
ZEN_TRACE_CPU("FileCas::CreateReferencePruner");
auto Log = [&Ctx]() { return Ctx.Logger; };
diff --git a/src/zenstore/gc.cpp b/src/zenstore/gc.cpp
index 15dff40f5..f2901c4ee 100644
--- a/src/zenstore/gc.cpp
+++ b/src/zenstore/gc.cpp
@@ -9,6 +9,7 @@
#include <zencore/filesystem.h>
#include <zencore/fmtutils.h>
#include <zencore/logging.h>
+#include <zencore/memory/llm.h>
#include <zencore/scopeguard.h>
#include <zencore/string.h>
#include <zencore/testing.h>
@@ -43,6 +44,14 @@
namespace zen {
+const FLLMTag&
+GetGcTag()
+{
+ static FLLMTag _("gc");
+
+ return _;
+}
+
using namespace std::literals;
namespace fs = std::filesystem;
@@ -633,6 +642,8 @@ KeepUnusedReferences(std::span<const IoHash> SortedUsedReferences, std::span<IoH
void
GcManager::AddGcReferencer(GcReferencer& Referencer)
{
+ ZEN_MEMSCOPE(GetGcTag());
+
RwLock::ExclusiveLockScope _(m_Lock);
m_GcReferencers.push_back(&Referencer);
}
@@ -646,12 +657,14 @@ GcManager::RemoveGcReferencer(GcReferencer& Referencer)
void
GcManager::AddGcReferenceLocker(GcReferenceLocker& ReferenceLocker)
{
+ ZEN_MEMSCOPE(GetGcTag());
RwLock::ExclusiveLockScope _(m_Lock);
m_GcReferencerLockers.push_back(&ReferenceLocker);
}
void
GcManager::RemoveGcReferenceLocker(GcReferenceLocker& ReferenceLocker)
{
+ ZEN_MEMSCOPE(GetGcTag());
RwLock::ExclusiveLockScope _(m_Lock);
std::erase_if(m_GcReferencerLockers, [&](GcReferenceLocker* $) { return $ == &ReferenceLocker; });
}
@@ -659,6 +672,7 @@ GcManager::RemoveGcReferenceLocker(GcReferenceLocker& ReferenceLocker)
void
GcManager::AddGcReferenceStore(GcReferenceStore& ReferenceStore)
{
+ ZEN_MEMSCOPE(GetGcTag());
RwLock::ExclusiveLockScope _(m_Lock);
m_GcReferenceStores.push_back(&ReferenceStore);
}
@@ -676,6 +690,7 @@ GcManager::RemoveGcReferenceStore(GcReferenceStore& ReferenceStore)
GcResult
GcManager::CollectGarbage(const GcSettings& Settings)
{
+ ZEN_MEMSCOPE(GetGcTag());
ZEN_TRACE_CPU("GcV2::CollectGarbage");
GcCtx Ctx{.Settings = Settings, .IsCancelledFlag = m_CancelGC, .Logger = Log()};
@@ -1333,6 +1348,8 @@ GcManager::SetCancelGC(bool CancelFlag)
void
GcManager::AddGcStorage(GcStorage* Storage)
{
+ ZEN_MEMSCOPE(GetGcTag());
+
ZEN_ASSERT(Storage != nullptr);
RwLock::ExclusiveLockScope _(m_Lock);
m_GcStorage.push_back(Storage);
@@ -1348,6 +1365,8 @@ GcManager::RemoveGcStorage(GcStorage* Storage)
void
GcManager::ScrubStorage(ScrubContext& GcCtx)
{
+ ZEN_MEMSCOPE(GetGcTag());
+
RwLock::SharedLockScope _(m_Lock);
for (GcStorage* Storage : m_GcStorage)
@@ -1359,6 +1378,7 @@ GcManager::ScrubStorage(ScrubContext& GcCtx)
GcStorageSize
GcManager::TotalStorageSize() const
{
+ ZEN_MEMSCOPE(GetGcTag());
ZEN_TRACE_CPU("Gc::TotalStorageSize");
RwLock::SharedLockScope _(m_Lock);
@@ -1507,6 +1527,8 @@ GcScheduler::~GcScheduler()
void
GcScheduler::Initialize(const GcSchedulerConfig& Config)
{
+ ZEN_MEMSCOPE(GetGcTag());
+
using namespace std::chrono;
m_Config = Config;
@@ -1571,6 +1593,8 @@ GcScheduler::Initialize(const GcSchedulerConfig& Config)
void
GcScheduler::Shutdown()
{
+ ZEN_MEMSCOPE(GetGcTag());
+
if (static_cast<uint32_t>(GcSchedulerStatus::kStopped) != m_Status)
{
bool GcIsRunning = m_Status == static_cast<uint32_t>(GcSchedulerStatus::kRunning);
@@ -1598,6 +1622,7 @@ GcScheduler::Shutdown()
bool
GcScheduler::TriggerGc(const GcScheduler::TriggerGcParams& Params)
{
+ ZEN_MEMSCOPE(GetGcTag());
std::unique_lock Lock(m_GcMutex);
if (static_cast<uint32_t>(GcSchedulerStatus::kIdle) == m_Status)
{
@@ -1617,6 +1642,7 @@ GcScheduler::TriggerGc(const GcScheduler::TriggerGcParams& Params)
bool
GcScheduler::TriggerScrub(const TriggerScrubParams& Params)
{
+ ZEN_MEMSCOPE(GetGcTag());
std::unique_lock Lock(m_GcMutex);
if (static_cast<uint32_t>(GcSchedulerStatus::kIdle) == m_Status)
@@ -1652,6 +1678,7 @@ GcScheduler::CancelGC()
DiskSpace
GcScheduler::CheckDiskSpace()
{
+ ZEN_MEMSCOPE(GetGcTag());
std::error_code Ec;
DiskSpace Space = DiskSpaceInfo(m_Config.RootDirectory, Ec);
if (Ec)
@@ -1685,6 +1712,7 @@ GcScheduler::CheckDiskSpace()
void
GcScheduler::AppendGCLog(std::string_view Id, GcClock::TimePoint StartTime, const GcSettings& Settings, const GcResult& Result)
{
+ ZEN_MEMSCOPE(GetGcTag());
try
{
std::vector<uint8_t> Blob;
@@ -1784,6 +1812,7 @@ GcScheduler::AppendGCLog(std::string_view Id, GcClock::TimePoint StartTime, cons
GcSchedulerState
GcScheduler::GetState() const
{
+ ZEN_MEMSCOPE(GetGcTag());
GcClock::TimePoint Now = GcClock::Now();
const GcStorageSize TotalSize = m_GcManager.TotalStorageSize();
@@ -1854,6 +1883,7 @@ GcScheduler::GetState() const
void
GcScheduler::SchedulerThread()
{
+ ZEN_MEMSCOPE(GetGcTag());
SetCurrentThreadName("GcScheduler");
std::chrono::seconds WaitTime{0};