summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-06-03 12:42:12 +0200
committerGitHub <noreply@github.com>2021-06-03 12:42:12 +0200
commit01fd8befc5ab6f8e0c7c0982c45126b29dbd7bc0 (patch)
treebf43f342f59f2524959647080eea30fc1d229dc8
parentc4abcf758d42eea13745edcbfdee543d61b79568 (diff)
parent73fa7f104abd6808d0c180d616b6125d6b3c8889 (diff)
Merge pull request #18098 from vespa-engine/balder/unify-mmap-limit-for-bitvectors
Unify on mmap limit at 16M for bitvectors. Should ideally be controll…
-rw-r--r--searchlib/src/vespa/searchlib/common/bitvector.cpp8
-rw-r--r--searchlib/src/vespa/searchlib/common/partialbitvector.h2
2 files changed, 7 insertions, 3 deletions
diff --git a/searchlib/src/vespa/searchlib/common/bitvector.cpp b/searchlib/src/vespa/searchlib/common/bitvector.cpp
index 8953710e8c7..fa63b846e17 100644
--- a/searchlib/src/vespa/searchlib/common/bitvector.cpp
+++ b/searchlib/src/vespa/searchlib/common/bitvector.cpp
@@ -6,6 +6,7 @@
#include "partialbitvector.h"
#include <vespa/vespalib/hwaccelrated/iaccelrated.h>
#include <vespa/vespalib/util/exceptions.h>
+#include <vespa/vespalib/util/size_literals.h>
#include <vespa/vespalib/objects/nbostream.h>
#include <vespa/fastos/file.h>
#include <cassert>
@@ -32,6 +33,9 @@ void verifyInclusiveStart(const search::BitVector & a, const search::BitVector &
}
}
+constexpr size_t MMAP_LIMIT = 32_Mi;
+constexpr size_t DIRECTIO_ALIGNMENT = 4_Ki;
+
}
/////////////////////////////////
@@ -49,7 +53,7 @@ BitVector::allocatePaddedAndAligned(Index start, Index end, Index capacity)
uint32_t words = numActiveWords(start, capacity);
words += (-words & 15); // Pad to 64 byte alignment
const size_t sz(words * sizeof(Word));
- Alloc alloc = Alloc::alloc(sz);
+ Alloc alloc = Alloc::alloc(sz, MMAP_LIMIT);
assert(alloc.size()/sizeof(Word) >= words);
// Clear padding
size_t usedBytes = numBytes(end - start);
@@ -337,7 +341,7 @@ BitVector::create(Index numberOfElements, FastOS_FileInterface &file,
size_t vectorsize = getFileBytes(numberOfElements);
file.DirectIOPadding(offset, vectorsize, padbefore, padafter);
assert((padbefore & (getAlignment() - 1)) == 0);
- AllocatedBitVector::Alloc alloc = Alloc::alloc(padbefore + vectorsize + padafter, 0x1000000, 0x1000);
+ AllocatedBitVector::Alloc alloc = Alloc::alloc(padbefore + vectorsize + padafter, MMAP_LIMIT, DIRECTIO_ALIGNMENT);
void * alignedBuffer = alloc.get();
file.ReadBuf(alignedBuffer, alloc.size(), offset - padbefore);
bv = std::make_unique<AllocatedBitVector>(numberOfElements, std::move(alloc), padbefore);
diff --git a/searchlib/src/vespa/searchlib/common/partialbitvector.h b/searchlib/src/vespa/searchlib/common/partialbitvector.h
index f1d0716ed60..0c44378e78a 100644
--- a/searchlib/src/vespa/searchlib/common/partialbitvector.h
+++ b/searchlib/src/vespa/searchlib/common/partialbitvector.h
@@ -25,7 +25,7 @@ public:
PartialBitVector(Index start, Index end);
PartialBitVector(const BitVector & org, Index start, Index end);
- virtual ~PartialBitVector();
+ ~PartialBitVector() override;
private:
vespalib::alloc::Alloc _alloc;