diff options
| author | Dan Engelbrecht <[email protected]> | 2022-03-23 15:35:06 +0100 |
|---|---|---|
| committer | Dan Engelbrecht <[email protected]> | 2022-03-31 11:29:27 +0200 |
| commit | 6257a0e862e64dc7e7a33e347d2053cc44666daf (patch) | |
| tree | 5882411f6e1c8ba75f3608f01512652f6975cceb /zenstore/compactcas.cpp | |
| parent | cleanup (diff) | |
| download | zen-6257a0e862e64dc7e7a33e347d2053cc44666daf.tar.xz zen-6257a0e862e64dc7e7a33e347d2053cc44666daf.zip | |
Simpler creation of LocationMap copy
Diffstat (limited to 'zenstore/compactcas.cpp')
| -rw-r--r-- | zenstore/compactcas.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/zenstore/compactcas.cpp b/zenstore/compactcas.cpp index 8815b1b53..312bc205d 100644 --- a/zenstore/compactcas.cpp +++ b/zenstore/compactcas.cpp @@ -446,23 +446,18 @@ CasContainerStrategy::CollectGarbage(GcContext& GcCtx) std::unordered_map<IoHash, BlockStoreDiskLocation, IoHash::Hasher> LocationMap; size_t BlockCount; + uint64_t ExcludeBlockIndex = 0x800000000ull; { RwLock::SharedLockScope _i(m_InsertLock); RwLock::SharedLockScope _l(m_LocationMapLock); Stopwatch Timer; const auto TimerGuard = MakeGuard([&Timer, &WriteBlockTimeUs] { WriteBlockTimeUs += Timer.GetElapsedTimeUs(); }); - LocationMap.reserve(m_LocationMap.size()); - bool IsWriting = !m_WriteBlock.expired(); - uint32_t WritingBlock = m_WriteBlockIndex.load(std::memory_order_acquire); - for (const auto& Entry : m_LocationMap) + if (!m_WriteBlock.expired()) { - if (IsWriting && Entry.second.GetBlockIndex() == WritingBlock) - { - continue; - } - LocationMap.emplace(Entry.first, Entry.second); + ExcludeBlockIndex = m_WriteBlockIndex.load(std::memory_order_acquire); } - BlockCount = m_ChunkBlocks.size(); + LocationMap = m_LocationMap; + BlockCount = m_ChunkBlocks.size(); } if (LocationMap.empty()) @@ -488,8 +483,12 @@ CasContainerStrategy::CollectGarbage(GcContext& GcCtx) TotalChunkHashes.reserve(TotalChunkCount); for (const auto& Entry : LocationMap) { - TotalChunkHashes.push_back(Entry.first); uint32_t BlockIndex = Entry.second.GetBlockIndex(); + if (static_cast<uint64_t>(BlockIndex) == ExcludeBlockIndex) + { + continue; + } + TotalChunkHashes.push_back(Entry.first); if (BlockIndexToChunkMapIndex.contains(BlockIndex)) { continue; |