aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore/cache
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenstore/cache')
-rw-r--r--src/zenstore/cache/cachedisklayer.cpp34
-rw-r--r--src/zenstore/cache/structuredcachestore.cpp34
2 files changed, 39 insertions, 29 deletions
diff --git a/src/zenstore/cache/cachedisklayer.cpp b/src/zenstore/cache/cachedisklayer.cpp
index 4640309d9..22b9d0be5 100644
--- a/src/zenstore/cache/cachedisklayer.cpp
+++ b/src/zenstore/cache/cachedisklayer.cpp
@@ -140,25 +140,37 @@ namespace cache::impl {
const char* LogExtension = ".slog";
const char* MetaExtension = ".meta";
+ std::filesystem::path GetBucketFilePath(const std::filesystem::path& BucketDir, const std::string& BucketName, const char* Extension)
+ {
+ ExtendablePathBuilder<256> Path;
+ Path.Append(BucketDir);
+ Path /= BucketName.c_str();
+ Path << Extension;
+ return Path.ToPath();
+ }
+
std::filesystem::path GetIndexPath(const std::filesystem::path& BucketDir, const std::string& BucketName)
{
- return BucketDir / (BucketName + IndexExtension);
+ return GetBucketFilePath(BucketDir, BucketName, IndexExtension);
}
std::filesystem::path GetMetaPath(const std::filesystem::path& BucketDir, const std::string& BucketName)
{
- return BucketDir / (BucketName + MetaExtension);
+ return GetBucketFilePath(BucketDir, BucketName, MetaExtension);
}
std::filesystem::path GetLogPath(const std::filesystem::path& BucketDir, const std::string& BucketName)
{
- return BucketDir / (BucketName + LogExtension);
+ return GetBucketFilePath(BucketDir, BucketName, LogExtension);
}
std::filesystem::path GetManifestPath(const std::filesystem::path& BucketDir, const std::string& BucketName)
{
ZEN_UNUSED(BucketName);
- return BucketDir / "zen_manifest";
+ ExtendablePathBuilder<256> Path;
+ Path.Append(BucketDir);
+ Path /= "zen_manifest";
+ return Path.ToPath();
}
bool ValidateCacheBucketIndexEntry(const DiskIndexEntry& Entry, std::string& OutReason)
@@ -3083,7 +3095,7 @@ public:
{
ZEN_TRACE_CPU("Z$::Bucket::CompactStore");
- auto Log = [&Ctx]() { return Ctx.Logger; };
+ ZEN_SCOPED_LOG(Ctx.Logger);
Stopwatch Timer;
const auto _ = MakeGuard([&] {
@@ -3338,7 +3350,7 @@ ZenCacheDiskLayer::CacheBucket::RemoveExpiredData(GcCtx& Ctx, GcStats& Stats)
{
ZEN_TRACE_CPU("Z$::Bucket::RemoveExpiredData");
- auto Log = [&Ctx]() { return Ctx.Logger; };
+ ZEN_SCOPED_LOG(Ctx.Logger);
size_t TotalEntries = 0;
@@ -3502,7 +3514,7 @@ ZenCacheDiskLayer::CacheBucket::GetReferences(const LoggerRef& Logger,
{
ZEN_TRACE_CPU("Z$::Bucket::GetReferencesLocked");
- auto Log = [&Logger]() { return Logger; };
+ ZEN_SCOPED_LOG(Logger);
auto GetAttachments = [&](const IoHash& RawHash, MemoryView Data) -> bool {
if (CbValidateError Error = ValidateCompactBinary(Data, CbValidateMode::Default); Error == CbValidateError::None)
@@ -3718,7 +3730,7 @@ public:
{
ZEN_TRACE_CPU("Z$::Bucket::PreCache");
- auto Log = [&Ctx]() { return Ctx.Logger; };
+ ZEN_SCOPED_LOG(Ctx.Logger);
Stopwatch Timer;
const auto _ = MakeGuard([&] {
@@ -3753,7 +3765,7 @@ public:
{
ZEN_TRACE_CPU("Z$::Bucket::UpdateLockedState");
- auto Log = [&Ctx]() { return Ctx.Logger; };
+ ZEN_SCOPED_LOG(Ctx.Logger);
Stopwatch Timer;
const auto _ = MakeGuard([&] {
@@ -3784,7 +3796,7 @@ public:
{
ZEN_TRACE_CPU("Z$::Bucket::GetUnusedReferences");
- auto Log = [&Ctx]() { return Ctx.Logger; };
+ ZEN_SCOPED_LOG(Ctx.Logger);
const size_t InitialCount = IoCids.size();
size_t UsedCount = InitialCount;
@@ -3818,7 +3830,7 @@ ZenCacheDiskLayer::CacheBucket::CreateReferenceCheckers(GcCtx& Ctx)
{
ZEN_TRACE_CPU("Z$::Bucket::CreateReferenceCheckers");
- auto Log = [&Ctx]() { return Ctx.Logger; };
+ ZEN_SCOPED_LOG(Ctx.Logger);
Stopwatch Timer;
const auto _ = MakeGuard([&] {
diff --git a/src/zenstore/cache/structuredcachestore.cpp b/src/zenstore/cache/structuredcachestore.cpp
index cff0e9a35..990238e1e 100644
--- a/src/zenstore/cache/structuredcachestore.cpp
+++ b/src/zenstore/cache/structuredcachestore.cpp
@@ -468,7 +468,7 @@ ZenCacheStore::LogWorker()
LoggerRef ZCacheLog(logging::Get("z$"));
- auto Log = [&ZCacheLog]() -> LoggerRef { return ZCacheLog; };
+ ZEN_SCOPED_LOG(ZCacheLog);
std::vector<AccessLogItem> Items;
while (true)
@@ -817,7 +817,7 @@ ZenCacheStore::DropNamespace(std::string_view InNamespace)
std::function<void()> PostDropOp;
{
RwLock::ExclusiveLockScope _(m_NamespacesLock);
- if (auto It = m_Namespaces.find(std::string(InNamespace)); It != m_Namespaces.end())
+ if (auto It = m_Namespaces.find(InNamespace); It != m_Namespaces.end())
{
ZenCacheNamespace& Namespace = *It->second;
m_DroppedNamespaces.push_back(std::move(It->second));
@@ -888,13 +888,13 @@ ZenCacheNamespace*
ZenCacheStore::GetNamespace(std::string_view Namespace)
{
RwLock::SharedLockScope _(m_NamespacesLock);
- if (auto It = m_Namespaces.find(std::string(Namespace)); It != m_Namespaces.end())
+ if (auto It = m_Namespaces.find(Namespace); It != m_Namespaces.end())
{
return It->second.get();
}
if (Namespace == DefaultNamespace)
{
- if (auto It = m_Namespaces.find(std::string(UE4DDCNamespaceName)); It != m_Namespaces.end())
+ if (auto It = m_Namespaces.find(UE4DDCNamespaceName); It != m_Namespaces.end())
{
return It->second.get();
}
@@ -907,17 +907,17 @@ ZenCacheStore::GetNamespace(std::string_view Namespace)
}
RwLock::ExclusiveLockScope __(m_NamespacesLock);
- if (auto It = m_Namespaces.find(std::string(Namespace)); It != m_Namespaces.end())
+ if (auto It = m_Namespaces.find(Namespace); It != m_Namespaces.end())
{
return It->second.get();
}
auto NewNamespace =
- m_Namespaces.insert_or_assign(std::string(Namespace),
- std::make_unique<ZenCacheNamespace>(m_Gc,
- m_JobQueue,
- m_BasePath / fmt::format("{}{}", NamespaceDiskPrefix, Namespace),
- m_Configuration.NamespaceConfig));
+ m_Namespaces.try_emplace(std::string(Namespace),
+ std::make_unique<ZenCacheNamespace>(m_Gc,
+ m_JobQueue,
+ m_BasePath / fmt::format("{}{}", NamespaceDiskPrefix, Namespace),
+ m_Configuration.NamespaceConfig));
if (m_CapturedNamespaces)
{
@@ -931,13 +931,13 @@ const ZenCacheNamespace*
ZenCacheStore::FindNamespace(std::string_view Namespace) const
{
RwLock::SharedLockScope _(m_NamespacesLock);
- if (auto It = m_Namespaces.find(std::string(Namespace)); It != m_Namespaces.end())
+ if (auto It = m_Namespaces.find(Namespace); It != m_Namespaces.end())
{
return It->second.get();
}
if (Namespace == DefaultNamespace)
{
- if (auto It = m_Namespaces.find(std::string(UE4DDCNamespaceName)); It != m_Namespaces.end())
+ if (auto It = m_Namespaces.find(UE4DDCNamespaceName); It != m_Namespaces.end())
{
return It->second.get();
}
@@ -1086,11 +1086,9 @@ ZenCacheStore::GetBucketInfo(std::string_view NamespaceName, std::string_view Bu
std::vector<RwLock::SharedLockScope>
ZenCacheStore::LockState(GcCtx& Ctx)
{
+ ZEN_UNUSED(Ctx);
ZEN_TRACE_CPU("CacheStore::LockState");
- auto Log = [&Ctx]() { return Ctx.Logger; };
- ZEN_UNUSED(Log);
-
std::vector<RwLock::SharedLockScope> Locks;
Locks.emplace_back(RwLock::SharedLockScope(m_NamespacesLock));
for (auto& NamespaceIt : m_Namespaces)
@@ -1211,7 +1209,7 @@ public:
{
ZEN_TRACE_CPU("Z$::UpdateLockedState");
- auto Log = [&Ctx]() { return Ctx.Logger; };
+ ZEN_SCOPED_LOG(Ctx.Logger);
Stopwatch Timer;
@@ -1276,7 +1274,7 @@ public:
{
ZEN_TRACE_CPU("Z$::GetUnusedReferences");
- auto Log = [&Ctx]() { return Ctx.Logger; };
+ ZEN_SCOPED_LOG(Ctx.Logger);
const size_t InitialCount = IoCids.size();
size_t UsedCount = InitialCount;
@@ -1309,7 +1307,7 @@ ZenCacheStore::CreateReferenceCheckers(GcCtx& Ctx)
{
ZEN_TRACE_CPU("CacheStore::CreateReferenceCheckers");
- auto Log = [&Ctx]() { return Ctx.Logger; };
+ ZEN_SCOPED_LOG(Ctx.Logger);
Stopwatch Timer;
const auto _ = MakeGuard([&] {