aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore/compactcas.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2024-11-27 12:52:25 +0100
committerGitHub Enterprise <[email protected]>2024-11-27 12:52:25 +0100
commit1bd5cb6fb09dfa56a7b317a56a9914609f2b4535 (patch)
tree4cc24c2553486c73567707346a860d7164abd121 /src/zenstore/compactcas.cpp
parent5.5.14-pre4 (diff)
downloadzen-1bd5cb6fb09dfa56a7b317a56a9914609f2b4535.tar.xz
zen-1bd5cb6fb09dfa56a7b317a56a9914609f2b4535.zip
use plain sorted array instead of map of vectors (#237)
* use plain sorted array instead of map of vectors * reserve vectors up front = 5% perf increase * don't do batch read of chunks if we have a single chunk -> 1% perf gain
Diffstat (limited to 'src/zenstore/compactcas.cpp')
-rw-r--r--src/zenstore/compactcas.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/zenstore/compactcas.cpp b/src/zenstore/compactcas.cpp
index 792854af6..9982e7571 100644
--- a/src/zenstore/compactcas.cpp
+++ b/src/zenstore/compactcas.cpp
@@ -308,9 +308,10 @@ CasContainerStrategy::IterateChunks(std::span<IoHash> ChunkHashes,
WorkerThreadPool* OptionalWorkerPool,
uint64_t LargeSizeLimit)
{
- if (ChunkHashes.size() < 3)
+ const size_t ChunkCount = ChunkHashes.size();
+ if (ChunkCount < 3)
{
- for (size_t ChunkIndex = 0; ChunkIndex < ChunkHashes.size(); ChunkIndex++)
+ for (size_t ChunkIndex = 0; ChunkIndex < ChunkCount; ChunkIndex++)
{
IoBuffer Chunk = FindChunk(ChunkHashes[ChunkIndex]);
if (!AsyncCallback(ChunkIndex, Chunk))
@@ -322,8 +323,10 @@ CasContainerStrategy::IterateChunks(std::span<IoHash> ChunkHashes,
}
std::vector<size_t> FoundChunkIndexes;
std::vector<BlockStoreLocation> FoundChunkLocations;
- RwLock::SharedLockScope _(m_LocationMapLock);
- for (size_t ChunkIndex = 0; ChunkIndex < ChunkHashes.size(); ChunkIndex++)
+ FoundChunkIndexes.reserve(ChunkCount);
+ FoundChunkLocations.reserve(ChunkCount);
+ RwLock::SharedLockScope _(m_LocationMapLock);
+ for (size_t ChunkIndex = 0; ChunkIndex < ChunkCount; ChunkIndex++)
{
if (auto KeyIt = m_LocationMap.find(ChunkHashes[ChunkIndex]); KeyIt != m_LocationMap.end())
{