diff options
| author | Dan Engelbrecht <[email protected]> | 2024-12-17 14:20:48 +0100 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-12-17 14:20:48 +0100 |
| commit | 48657d2fb6c9c709ec29264a609350c7b4a541f9 (patch) | |
| tree | a2c1997a99e9659ee038663e1a8da4b56ec01ad5 /src/zenstore/compactcas.cpp | |
| parent | remove all referenced attachments in op from pending chunk references (#267) (diff) | |
| download | zen-48657d2fb6c9c709ec29264a609350c7b4a541f9.tar.xz zen-48657d2fb6c9c709ec29264a609350c7b4a541f9.zip | |
batch fetch record cache values (#266)
- Improvement: Batch fetch record attachments when appropriate
- Improvement: Reduce memory buffer allocation in BlockStore::IterateBlock
- Improvement: Tweaked BlockStore::IterateBlock logic when to use threaded work (at least 4 chunks requested)
- Bugfix: CasContainerStrategy::IterateChunks could give wrong payload/index when requesting 1 or 2 chunks
Diffstat (limited to 'src/zenstore/compactcas.cpp')
| -rw-r--r-- | src/zenstore/compactcas.cpp | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/src/zenstore/compactcas.cpp b/src/zenstore/compactcas.cpp index 50af7246e..30cf998f8 100644 --- a/src/zenstore/compactcas.cpp +++ b/src/zenstore/compactcas.cpp @@ -345,12 +345,13 @@ CasContainerStrategy::IterateChunks(std::span<IoHash> ChunkHashes, } } } - if (FoundChunkLocations.size() < 3) + if (FoundChunkLocations.size() < 4) { - for (size_t ChunkIndex : FoundChunkIndexes) + for (size_t Index = 0; Index < FoundChunkIndexes.size(); Index++) { - IoBuffer Chunk = m_BlockStore.TryGetChunk(FoundChunkLocations[ChunkIndex]); - if (!AsyncCallback(ChunkIndex, Chunk)) + IoBuffer Chunk = m_BlockStore.TryGetChunk(FoundChunkLocations[Index]); + size_t OuterIndex = FoundChunkIndexes[Index]; + if (!AsyncCallback(OuterIndex, Chunk)) { return false; } @@ -359,6 +360,18 @@ CasContainerStrategy::IterateChunks(std::span<IoHash> ChunkHashes, } auto DoOneBlock = [&](std::span<const size_t> ChunkIndexes) { + if (ChunkIndexes.size() < 4) + { + for (size_t ChunkIndex : ChunkIndexes) + { + IoBuffer Chunk = m_BlockStore.TryGetChunk(FoundChunkLocations[ChunkIndex]); + if (!AsyncCallback(FoundChunkIndexes[ChunkIndex], Chunk)) + { + return false; + } + } + return true; + } return m_BlockStore.IterateBlock( FoundChunkLocations, ChunkIndexes, @@ -378,19 +391,7 @@ CasContainerStrategy::IterateChunks(std::span<IoHash> ChunkHashes, Latch WorkLatch(1); std::atomic_bool AsyncContinue = true; bool Continue = m_BlockStore.IterateChunks(FoundChunkLocations, [&](uint32_t BlockIndex, std::span<const size_t> ChunkIndexes) { - if (ChunkIndexes.size() < 3) - { - for (size_t ChunkIndex : ChunkIndexes) - { - IoBuffer Chunk = m_BlockStore.TryGetChunk(FoundChunkLocations[ChunkIndex]); - if (!AsyncCallback(FoundChunkIndexes[ChunkIndex], Chunk)) - { - return false; - } - } - return true; - } - else if (OptionalWorkerPool) + if (OptionalWorkerPool && (ChunkIndexes.size() > 3)) { WorkLatch.AddCount(1); OptionalWorkerPool->ScheduleWork([&, ChunkIndexes = std::vector<size_t>(ChunkIndexes.begin(), ChunkIndexes.end())]() { |