diff options
Diffstat (limited to 'searchcore')
4 files changed, 7 insertions, 4 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp index e289b71a447..5c96173c678 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp @@ -1064,10 +1064,8 @@ DocumentMetaStore::getEstimatedShrinkLidSpaceGain() const BucketId DocumentMetaStore::getBucketOf(const vespalib::GenerationHandler::Guard &, uint32_t lid) const { - if (__builtin_expect(lid < getCommittedDocIdLimit(), true)) { - if (__builtin_expect(validLidFast(lid), true)) { - return getRawMetaData(lid).getBucketId(); - } + if (__builtin_expect(validLidFastSafe(lid, getCommittedDocIdLimit()), true)) { + return getRawMetaData(lid).getBucketId(); } return BucketId(); } diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h index b5a95b8cd34..51f91241d3e 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h @@ -182,6 +182,7 @@ public: void move(DocId fromLid, DocId toLid, uint64_t prepare_serial_num) override; bool validButMaybeUnusedLid(DocId lid) const { return _lidAlloc.validButMaybeUnusedLid(lid); } bool validLidFast(DocId lid) const { return _lidAlloc.validLid(lid); } + bool validLidFastSafe(DocId lid, uint32_t limit) const { return _lidAlloc.validLidSafe(lid, limit); } bool validLid(DocId lid) const override { return validLidFast(lid); } void removeBatch(const std::vector<DocId> &lidsToRemove, const DocId docIdLimit) override; const RawDocumentMetaData & getRawMetaData(DocId lid) const override { return _metaDataStore.acquire_elem_ref(lid); } diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.h index 08fa4a6489a..e6327163aae 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.h +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.h @@ -70,6 +70,9 @@ public: bool validLid(DocId lid) const { return (lid < _usedLids.size() && _usedLids.testBit(lid)); } + bool validLidSafe(DocId lid, uint32_t limit) const { + return (lid < limit && _usedLids.testBitSafe(lid)); + } DocId getLowestFreeLid() const { return _freeLids.getLowest(); } diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/lidstatevector.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/lidstatevector.h index 74851635124..c0db4e99fa5 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/lidstatevector.h +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/lidstatevector.h @@ -45,6 +45,7 @@ public: void consider_clear_bits(const std::vector<uint32_t>& idxs); void clear_bits(const std::vector<uint32_t>& idxs); bool testBit(unsigned int idx) const { return _bv.testBit(idx); } + bool testBitSafe(unsigned int idx) const { return _bv.testBitSafe(idx); } unsigned int size() const { return _bv.size(); } unsigned int byteSize() const { return _bv.extraByteSize() + sizeof(LidStateVector); |