aboutsummaryrefslogtreecommitdiff
path: root/zenstore/compactcas.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-03-23 21:45:15 +0100
committerDan Engelbrecht <[email protected]>2022-03-31 11:29:27 +0200
commit21d72116a3ed729b3ec66166d66044b3759a655d (patch)
treeddb916211ecc0f83ca8cf225683b2c9a60ad8c27 /zenstore/compactcas.cpp
parentreview feedback (diff)
downloadzen-21d72116a3ed729b3ec66166d66044b3759a655d.tar.xz
zen-21d72116a3ed729b3ec66166d66044b3759a655d.zip
No neeed to bookkeep moved chunk hashes
Diffstat (limited to 'zenstore/compactcas.cpp')
-rw-r--r--zenstore/compactcas.cpp22
1 files changed, 8 insertions, 14 deletions
diff --git a/zenstore/compactcas.cpp b/zenstore/compactcas.cpp
index a2656fb0a..95fa00a5e 100644
--- a/zenstore/compactcas.cpp
+++ b/zenstore/compactcas.cpp
@@ -419,7 +419,7 @@ CasContainerStrategy::CollectGarbage(GcContext& GcCtx)
uint64_t OldTotalSize = m_TotalSize.load(std::memory_order::relaxed);
std::vector<IoHash> DeletedChunks;
- std::vector<IoHash> MovedChunks;
+ uint64_t MovedCount = 0;
const auto Guard = MakeGuard([this,
&TotalTimer,
@@ -427,7 +427,7 @@ CasContainerStrategy::CollectGarbage(GcContext& GcCtx)
&ReadBlockTimeUs,
&TotalChunkCount,
&DeletedChunks,
- &MovedChunks,
+ &MovedCount,
&DeletedSize,
&OldTotalSize] {
ZEN_INFO(
@@ -439,7 +439,7 @@ CasContainerStrategy::CollectGarbage(GcContext& GcCtx)
NiceTimeSpanMs(ReadBlockTimeUs / 1000),
NiceBytes(DeletedSize),
DeletedChunks.size(),
- MovedChunks.size(),
+ MovedCount,
TotalChunkCount,
NiceBytes(OldTotalSize));
});
@@ -578,7 +578,6 @@ CasContainerStrategy::CollectGarbage(GcContext& GcCtx)
OldBlockFile->Open();
}
- MovedChunks.reserve(MovedChunks.size() + KeepMap.size());
std::vector<uint8_t> Chunk;
for (const IoHash& ChunkHash : KeepMap)
{
@@ -613,10 +612,7 @@ CasContainerStrategy::CollectGarbage(GcContext& GcCtx)
m_ChunkBlocks[NextBlockIndex] = NewBlockFile;
}
- for (const auto& MovedEntry : MovedBlockChunks)
- {
- MovedChunks.push_back(MovedEntry.first);
- }
+ MovedCount += MovedBlockChunks.size();
MovedBlockChunks.clear();
std::error_code Error;
@@ -659,8 +655,9 @@ CasContainerStrategy::CollectGarbage(GcContext& GcCtx)
}
NewBlockFile->Write(Chunk.data(), Chunk.size(), WriteOffset);
- BlockStoreLocation NewChunkLocation(NewBlockIndex, WriteOffset, Chunk.size());
- MovedBlockChunks.emplace(ChunkHash, BlockStoreDiskLocation(NewChunkLocation, m_PayloadAlignment));
+ MovedBlockChunks.emplace(
+ ChunkHash,
+ BlockStoreDiskLocation({.BlockIndex = NewBlockIndex, .Offset = WriteOffset, .Size = Chunk.size()}, m_PayloadAlignment));
WriteOffset = RoundUp(WriteOffset + Chunk.size(), m_PayloadAlignment);
}
Chunk.clear();
@@ -675,10 +672,7 @@ CasContainerStrategy::CollectGarbage(GcContext& GcCtx)
m_CasLog.Append(LogEntries);
m_ChunkBlocks[BlockIndex].reset();
}
- for (const auto& MovedEntry : MovedBlockChunks)
- {
- MovedChunks.push_back(MovedEntry.first);
- }
+ MovedCount += MovedBlockChunks.size();
DeletedChunks.insert(DeletedChunks.end(), DeleteMap.begin(), DeleteMap.end());
MovedBlockChunks.clear();