diff options
| author | Dan Engelbrecht <[email protected]> | 2026-01-13 14:24:15 +0100 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2026-01-13 14:24:15 +0100 |
| commit | e730f9020d6732e944b4b6f319438b2f02296c2e (patch) | |
| tree | 569adcb483617caf8aa99e2fd56a51abc03b3532 /src | |
| parent | if we fail to create the server mutex, gracefully report error without sendin... (diff) | |
| download | zen-e730f9020d6732e944b4b6f319438b2f02296c2e.tar.xz zen-e730f9020d6732e944b4b6f319438b2f02296c2e.zip | |
fixed block generation after bug introduced in PR #704 (#707)
Diffstat (limited to 'src')
| -rw-r--r-- | src/zenremotestore/projectstore/remoteprojectstore.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/zenremotestore/projectstore/remoteprojectstore.cpp b/src/zenremotestore/projectstore/remoteprojectstore.cpp index 5ba541dd0..8be8eb0df 100644 --- a/src/zenremotestore/projectstore/remoteprojectstore.cpp +++ b/src/zenremotestore/projectstore/remoteprojectstore.cpp @@ -389,7 +389,7 @@ namespace remotestore_impl { IgnoreMissingAttachments, OptionalContext, RetriesLeft, - Chunks = Chunks]() { + Chunks = std::vector<IoHash>(Chunks)]() { ZEN_TRACE_CPU("DownloadBlock"); auto _ = MakeGuard([&AttachmentsDownloadLatch] { AttachmentsDownloadLatch.CountDown(); }); @@ -444,7 +444,7 @@ namespace remotestore_impl { IgnoreMissingAttachments, OptionalContext, RetriesLeft, - Chunks = Chunks, + Chunks = std::move(Chunks), Bytes = std::move(BlockResult.Bytes)]() { auto _ = MakeGuard([&AttachmentsWriteLatch] { AttachmentsWriteLatch.CountDown(); }); if (RemoteResult.IsError()) @@ -1989,10 +1989,16 @@ BuildContainer(CidStore& ChunkStore, try { uint64_t FetchAttachmentsStartMS = Timer.GetElapsedTimeMs(); - std::unordered_set<IoHash, IoHash::Hasher> BlockAttachmentHashes; + std::unordered_set<IoHash, IoHash::Hasher> AddedAttachmentHashes; auto NewBlock = [&]() { - size_t BlockIndex = remotestore_impl::AddBlock(BlocksLock, Blocks); - size_t ChunkCount = ChunksInBlock.size(); + size_t BlockIndex = remotestore_impl::AddBlock(BlocksLock, Blocks); + size_t ChunkCount = ChunksInBlock.size(); + std::vector<IoHash> ChunkRawHashes; + ChunkRawHashes.reserve(ChunkCount); + for (const std::pair<IoHash, FetchChunkFunc>& Chunk : ChunksInBlock) + { + ChunkRawHashes.push_back(Chunk.first); + } if (BuildBlocks) { remotestore_impl::CreateBlock(WorkerPool, @@ -2007,15 +2013,13 @@ BuildContainer(CidStore& ChunkStore, } else { - ZEN_INFO("Bulk group {} attachments", BlockAttachmentHashes.size()); + ZEN_INFO("Bulk group {} attachments", ChunkCount); OnBlockChunks(std::move(ChunksInBlock)); } { // We can share the lock as we are not resizing the vector and only touch BlockHash at our own index RwLock::SharedLockScope _(BlocksLock); - Blocks[BlockIndex].ChunkRawHashes.insert(Blocks[BlockIndex].ChunkRawHashes.end(), - BlockAttachmentHashes.begin(), - BlockAttachmentHashes.end()); + Blocks[BlockIndex].ChunkRawHashes = std::move(ChunkRawHashes); } uint64_t NowMS = Timer.GetElapsedTimeMs(); ZEN_INFO("Assembled block {} with {} chunks in {} ({})", @@ -2024,7 +2028,6 @@ BuildContainer(CidStore& ChunkStore, NiceTimeSpanMs(NowMS - FetchAttachmentsStartMS), NiceBytes(BlockSize)); FetchAttachmentsStartMS = NowMS; - BlockAttachmentHashes.clear(); ChunksInBlock.clear(); BlockSize = 0; GeneratedBlockCount++; @@ -2056,7 +2059,7 @@ BuildContainer(CidStore& ChunkStore, ZEN_ASSERT(InfoIt != UploadAttachments.end()); uint64_t PayloadSize = InfoIt->second.Size; - if (BlockAttachmentHashes.insert(AttachmentHash).second) + if (AddedAttachmentHashes.insert(AttachmentHash).second) { if (BuildBlocks && ChunksInBlock.size() > 0) { @@ -2145,7 +2148,7 @@ BuildContainer(CidStore& ChunkStore, const IoHash& ChunkHash = ChunkedFile.Chunked.Info.ChunkHashes[ChunkIndex]; if (auto FindIt = ChunkedHashes.find(ChunkHash); FindIt != ChunkedHashes.end()) { - if (BlockAttachmentHashes.insert(ChunkHash).second) + if (AddedAttachmentHashes.insert(ChunkHash).second) { const ChunkSource& Source = Chunked.ChunkSources[ChunkIndex]; uint32_t ChunkSize = gsl::narrow<uint32_t>(CompressedBuffer::GetHeaderSizeForNoneEncoder() + Source.Size); |