aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-06-02 21:21:28 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2021-06-02 21:31:39 +0000
commitd31e8cac61e07eca832888cc8440188b8b72467c (patch)
treee7bafab1f72f17f3b37f041689267d2a69ba3496 /searchlib
parent6d7ba4368a8d81247fa66bfe60557dadaffb4108 (diff)
Unify on mmap limit at 16M for bitvectors. Should ideally be controlled with allocator from the outside depending on expected BV lifetime.
Diffstat (limited to 'searchlib')
-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..e80c8f1f108 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 = 16_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;