From bc17147c11d2e34a287a4e2171484aa3f9e576d4 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Fri, 17 Apr 2026 14:10:02 +0200 Subject: log cleanup (#969) - Improvement: New `ZEN_SCOPED_LOG(Expr)` macro routes `ZEN_INFO`/`ZEN_WARN`/`ZEN_DEBUG` in the enclosing block through the given logger expression instead of the default - Improvement: `BuildContainer`, `SaveOplog`, and `LoadOplogContext` now take a caller-provided `LoggerRef` so diagnostic messages route through the caller's logger --- src/zenstore/cache/structuredcachestore.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/zenstore/cache/structuredcachestore.cpp') diff --git a/src/zenstore/cache/structuredcachestore.cpp b/src/zenstore/cache/structuredcachestore.cpp index cff0e9a35..97b793083 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 Items; while (true) @@ -1086,11 +1086,9 @@ ZenCacheStore::GetBucketInfo(std::string_view NamespaceName, std::string_view Bu std::vector ZenCacheStore::LockState(GcCtx& Ctx) { + ZEN_UNUSED(Ctx); ZEN_TRACE_CPU("CacheStore::LockState"); - auto Log = [&Ctx]() { return Ctx.Logger; }; - ZEN_UNUSED(Log); - std::vector 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([&] { -- cgit v1.2.3 From 2ade130ec3c163cadc4a296e7d7800eb86e72056 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Tue, 21 Apr 2026 10:07:03 +0200 Subject: structured cache: fix some minor issues (#995) - Fix double WriteResponse in PUT record failure path; the detail-body branch now short-circuits instead of falling through to a second WriteResponse call - Return 405 Method Not Allowed for unsupported verbs in the root, namespace, bucket, record, and chunk handlers (previously fell through to no response) - Clamp exec$/replay-recording thread_count so a bogus query value cannot spawn an unbounded worker pool ## Performance / cleanup - NamespaceMap now uses TransparentStringHash + std::equal_to<>, so Get/Put/Find/Drop can probe the map with a std::string_view directly instead of constructing a temporary std::string on every request - Replace insert_or_assign with try_emplace under the exclusive lock in GetNamespace; the find() re-check already guarantees the key is absent, so try_emplace matches intent better ## Reverted - The earlier change to erase the pinned entry from m_DroppedNamespaces after DropNamespace's post-drop work was reverted: other threads may still hold pointers into a dropped namespace, so tearing it down eagerly is unsafe. Dropped namespaces remain pinned for the lifetime of the process as before. --- src/zenstore/cache/structuredcachestore.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/zenstore/cache/structuredcachestore.cpp') diff --git a/src/zenstore/cache/structuredcachestore.cpp b/src/zenstore/cache/structuredcachestore.cpp index 97b793083..990238e1e 100644 --- a/src/zenstore/cache/structuredcachestore.cpp +++ b/src/zenstore/cache/structuredcachestore.cpp @@ -817,7 +817,7 @@ ZenCacheStore::DropNamespace(std::string_view InNamespace) std::function 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(m_Gc, - m_JobQueue, - m_BasePath / fmt::format("{}{}", NamespaceDiskPrefix, Namespace), - m_Configuration.NamespaceConfig)); + m_Namespaces.try_emplace(std::string(Namespace), + std::make_unique(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(); } -- cgit v1.2.3