diff options
| author | Dan Engelbrecht <[email protected]> | 2024-09-20 12:57:56 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-09-20 12:57:56 +0200 |
| commit | c66d244eb7847ec907936a95195ef1f888fc87cd (patch) | |
| tree | 6008cb25be0f51e34867589971160e2b5b6ff232 | |
| parent | End was clamped to the wrong side if Count was defaulted (diff) | |
| download | zen-c66d244eb7847ec907936a95195ef1f888fc87cd.tar.xz zen-c66d244eb7847ec907936a95195ef1f888fc87cd.zip | |
unblock PreCache (#164)
Don't lock disk cache buckets from writing when scanning records for attachment references
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | src/zenstore/cache/cachedisklayer.cpp | 12 | ||||
| -rw-r--r-- | src/zenstore/cache/structuredcachestore.cpp | 2 | ||||
| -rw-r--r-- | src/zenstore/include/zenstore/cache/cachedisklayer.h | 2 |
4 files changed, 10 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index fe5a96c9c..6ccf6d9ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - Feature: Added `zen cache-gen` command to generate large amount of cache data for testing - Improvement: Optimizations to GC leading to 50-100% performance increase when handling large data sets - Bugfix: Symbol resolution could fail on Windows depending on the process' current working directory +- Bugfix: Don't block disk cache buckets from writing when scanning records for attachment references ## 5.5.7 - Bugfix: Fix race condition in zenserver during batched fetch of small cache chunks (<=1024b) resulting in missing rawhash/rawsize in the response. UE-223703 diff --git a/src/zenstore/cache/cachedisklayer.cpp b/src/zenstore/cache/cachedisklayer.cpp index 110acba9e..63f6d708a 100644 --- a/src/zenstore/cache/cachedisklayer.cpp +++ b/src/zenstore/cache/cachedisklayer.cpp @@ -3587,7 +3587,7 @@ ZenCacheDiskLayer::CacheBucket::ReadAttachmentsFromMetaData(uint32_t BlockI } bool -ZenCacheDiskLayer::CacheBucket::GetReferencesLocked(GcCtx& Ctx, std::vector<IoHash>& OutReferences) +ZenCacheDiskLayer::CacheBucket::GetReferences(GcCtx& Ctx, bool StateIsAlreadyLocked, std::vector<IoHash>& OutReferences) { ZEN_TRACE_CPU("Z$::Bucket::GetReferencesLocked"); @@ -3611,7 +3611,11 @@ ZenCacheDiskLayer::CacheBucket::GetReferencesLocked(GcCtx& Ctx, std::vector<IoHa { std::unordered_map<uint32_t, std::size_t> BlockIndexToChunkIndexes; - + std::unique_ptr<RwLock::SharedLockScope> StateLock; + if (!StateIsAlreadyLocked) + { + StateLock = std::make_unique<RwLock::SharedLockScope>(m_IndexLock); + } for (const auto& Entry : m_Index) { if (Ctx.IsCancelledFlag.load()) @@ -3784,9 +3788,7 @@ public: m_CacheBucket.m_IndexLock.WithExclusiveLock([&]() { m_CacheBucket.m_TrackedReferences = std::make_unique<HashSet>(); }); - RwLock::SharedLockScope IndexLock(m_CacheBucket.m_IndexLock); - bool Continue = m_CacheBucket.GetReferencesLocked(Ctx, m_References); - IndexLock.ReleaseNow(); + bool Continue = m_CacheBucket.GetReferences(Ctx, /*StateIsAlreadyLocked*/ false, m_References); if (!Continue) { m_CacheBucket.m_IndexLock.WithExclusiveLock([&]() { m_CacheBucket.m_TrackedReferences.reset(); }); diff --git a/src/zenstore/cache/structuredcachestore.cpp b/src/zenstore/cache/structuredcachestore.cpp index c98561ebb..7794d025f 100644 --- a/src/zenstore/cache/structuredcachestore.cpp +++ b/src/zenstore/cache/structuredcachestore.cpp @@ -1183,7 +1183,7 @@ public: for (ZenCacheDiskLayer::CacheBucket* Bucket : AddedBuckets) { - bool Continue = Bucket->GetReferencesLocked(Ctx, m_References); + bool Continue = Bucket->GetReferences(Ctx, /*StateIsAlreadyLocked*/ true, m_References); if (!Continue) { break; diff --git a/src/zenstore/include/zenstore/cache/cachedisklayer.h b/src/zenstore/include/zenstore/cache/cachedisklayer.h index b0b8b4cf3..a735893a1 100644 --- a/src/zenstore/include/zenstore/cache/cachedisklayer.h +++ b/src/zenstore/include/zenstore/cache/cachedisklayer.h @@ -235,7 +235,7 @@ public: void GatherReferences(GcContext& GcCtx); void CollectGarbage(GcContext& GcCtx); RwLock::SharedLockScope GetGcReferencerLock(); - bool GetReferencesLocked(GcCtx& Ctx, std::vector<IoHash>& OutReferences); + bool GetReferences(GcCtx& Ctx, bool StateIsAlreadyLocked, std::vector<IoHash>& OutReferences); bool ReadAttachmentsFromMetaData(uint32_t BlockIndex, std::span<const IoHash> InlineKeys, |