summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeir Storli <geirst@yahooinc.com>2021-12-03 16:42:39 +0100
committerGitHub <noreply@github.com>2021-12-03 16:42:39 +0100
commitad4219f3c80db0f4448f7028757cd75b7c4028f0 (patch)
treed2ccaa7f9f55496d553e4595764fb8b292de13ac
parente466832157da463459ee4e65ba8c83119c6a39e6 (diff)
parent6f3518ff56336aa3c185280684a99ec5266d9c58 (diff)
Merge pull request #20358 from vespa-engine/balder/resize-once-upfront
Ensure that we do not get more resizing than necessary.
-rw-r--r--searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp
index 4da09868216..2c0d10abd33 100644
--- a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp
@@ -484,11 +484,19 @@ void
WriteableFileChunk::updateChunkInfo(const ProcessedChunkQ & chunks, const ChunkMetaV & cmetaV, size_t sz)
{
std::lock_guard guard(_lock);
+ uint32_t maxChunkId(0);
+ for (const auto & chunk : chunks) {
+ maxChunkId = std::max(chunk->getChunkId(), maxChunkId);
+ }
+ if (maxChunkId >= _chunkInfo.size()) {
+ _chunkInfo.reserve(vespalib::roundUp2inN(maxChunkId+1));
+ }
size_t nettoSz(sz);
for (size_t i(0); i < chunks.size(); i++) {
const ProcessedChunk & chunk = *chunks[i];
assert(_chunkMap.find(chunk.getChunkId()) == _chunkMap.begin());
const Chunk & active = *_chunkMap.begin()->second;
+ assert(active.getId() == chunk.getChunkId());
if (active.getId() >= _chunkInfo.size()) {
_chunkInfo.resize(active.getId()+1);
}