aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore/filecas.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2023-05-16 13:34:08 +0200
committerGitHub <[email protected]>2023-05-16 13:34:08 +0200
commit4c518511ccf35c79284bde3dd10860b9bb52b6a0 (patch)
tree05f58d276ee82564832a2c9c078d3b1b6809d3cb /src/zenstore/filecas.cpp
parentMoved EnableVTMode function into zencore (#311) (diff)
downloadzen-4c518511ccf35c79284bde3dd10860b9bb52b6a0.tar.xz
zen-4c518511ccf35c79284bde3dd10860b9bb52b6a0.zip
Additional trace instrumentation (#312)
* added trace instrumentation to upstreamcache * added asio trace instrumentation * added trace annotations for project store * added trace annotations for BlockStore * added trace annotations for HttpClient * added trace annotations for CAS/GC
Diffstat (limited to 'src/zenstore/filecas.cpp')
-rw-r--r--src/zenstore/filecas.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/zenstore/filecas.cpp b/src/zenstore/filecas.cpp
index 88b847c51..2dd93a625 100644
--- a/src/zenstore/filecas.cpp
+++ b/src/zenstore/filecas.cpp
@@ -14,6 +14,7 @@
#include <zencore/testutils.h>
#include <zencore/thread.h>
#include <zencore/timer.h>
+#include <zencore/trace.h>
#include <zencore/uid.h>
#include <zenstore/gc.h>
#include <zenstore/scrubcontext.h>
@@ -125,6 +126,8 @@ FileCasStrategy::~FileCasStrategy()
void
FileCasStrategy::Initialize(const std::filesystem::path& RootDirectory, bool IsNewStore)
{
+ ZEN_TRACE_CPU("FileCas::Initialize");
+
using namespace filecas::impl;
m_IsInitialized = true;
@@ -242,6 +245,8 @@ DeletePayloadFileOnClose(const void* FileHandle)
CasStore::InsertResult
FileCasStrategy::InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash, CasStore::InsertMode Mode)
{
+ ZEN_TRACE_CPU("FileCas::InsertChunk");
+
ZEN_ASSERT(m_IsInitialized);
#if !ZEN_WITH_TESTS
@@ -321,7 +326,6 @@ FileCasStrategy::InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash, CasStore::
IsNew = m_Index.insert({ChunkHash, IndexEntry{.Size = ChunkSize}}).second;
}
if (IsNew)
-
{
m_TotalSize.fetch_add(static_cast<uint64_t>(ChunkSize), std::memory_order::relaxed);
}
@@ -536,6 +540,8 @@ FileCasStrategy::InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash, CasStore::
CasStore::InsertResult
FileCasStrategy::InsertChunk(const void* const ChunkData, const size_t ChunkSize, const IoHash& ChunkHash)
{
+ ZEN_TRACE_CPU("FileCas::InsertChunkData");
+
ZEN_ASSERT(m_IsInitialized);
{
@@ -748,6 +754,8 @@ FileCasStrategy::FindChunk(const IoHash& ChunkHash)
}
}
+ ZEN_TRACE_CPU("FileCas::FindChunk");
+
ShardingHelper Name(m_RootDirectory.c_str(), ChunkHash);
RwLock::SharedLockScope _(LockForHash(ChunkHash));
@@ -767,6 +775,8 @@ FileCasStrategy::HaveChunk(const IoHash& ChunkHash)
void
FileCasStrategy::DeleteChunk(const IoHash& ChunkHash, std::error_code& Ec)
{
+ ZEN_TRACE_CPU("FileCas::DeleteChunk");
+
ShardingHelper Name(m_RootDirectory.c_str(), ChunkHash);
uint64_t FileSize = static_cast<uint64_t>(std::filesystem::file_size(Name.ShardedPath.c_str(), Ec));
@@ -812,6 +822,8 @@ FileCasStrategy::FilterChunks(HashKeySet& InOutChunks)
void
FileCasStrategy::IterateChunks(std::function<void(const IoHash& Hash, IoBuffer&& Payload)>&& Callback)
{
+ ZEN_TRACE_CPU("FileCas::IterateChunks");
+
ZEN_ASSERT(m_IsInitialized);
RwLock::SharedLockScope _(m_Lock);
@@ -827,6 +839,8 @@ FileCasStrategy::IterateChunks(std::function<void(const IoHash& Hash, IoBuffer&&
void
FileCasStrategy::Flush()
{
+ ZEN_TRACE_CPU("FileCas::Flush");
+
m_CasLog.Flush();
MakeIndexSnapshot();
}
@@ -834,6 +848,8 @@ FileCasStrategy::Flush()
void
FileCasStrategy::ScrubStorage(ScrubContext& Ctx)
{
+ ZEN_TRACE_CPU("FileCas::ScrubStorage");
+
ZEN_INFO("scrubbing file CAS @ '{}'", m_RootDirectory);
ZEN_ASSERT(m_IsInitialized);
@@ -919,6 +935,8 @@ FileCasStrategy::ScrubStorage(ScrubContext& Ctx)
void
FileCasStrategy::CollectGarbage(GcContext& GcCtx)
{
+ ZEN_TRACE_CPU("FileCas::CollectGarbage");
+
ZEN_ASSERT(m_IsInitialized);
ZEN_DEBUG("collecting garbage from {}", m_RootDirectory);
@@ -1038,6 +1056,8 @@ FileCasStrategy::ValidateEntry(const FileCasIndexEntry& Entry, std::string& OutR
void
FileCasStrategy::MakeIndexSnapshot()
{
+ ZEN_TRACE_CPU("FileCas::MakeIndexSnapshot");
+
using namespace filecas::impl;
uint64_t LogCount = m_CasLog.GetLogCount();
@@ -1120,6 +1140,8 @@ FileCasStrategy::MakeIndexSnapshot()
uint64_t
FileCasStrategy::ReadIndexFile(const std::filesystem::path& IndexPath, uint32_t& OutVersion)
{
+ ZEN_TRACE_CPU("FileCas::ReadIndexFile");
+
using namespace filecas::impl;
std::vector<FileCasIndexEntry> Entries;
@@ -1203,6 +1225,8 @@ FileCasStrategy::ReadIndexFile(const std::filesystem::path& IndexPath, uint32_t&
uint64_t
FileCasStrategy::ReadLog(const std::filesystem::path& LogPath, uint64_t SkipEntryCount)
{
+ ZEN_TRACE_CPU("FileCas::ReadLog");
+
using namespace filecas::impl;
if (std::filesystem::is_regular_file(LogPath))
@@ -1255,6 +1279,8 @@ FileCasStrategy::ReadLog(const std::filesystem::path& LogPath, uint64_t SkipEntr
std::vector<FileCasStrategy::FileCasIndexEntry>
FileCasStrategy::ScanFolderForCasFiles(const std::filesystem::path& RootDir)
{
+ ZEN_TRACE_CPU("FileCas::ScanFolderForCasFiles");
+
using namespace filecas::impl;
std::vector<FileCasIndexEntry> Entries;