aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-12-15 11:03:11 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-12-15 11:03:11 +0000
commit1e1ebc215480ab75e09f3cd7a016bbdf0831c423 (patch)
tree4781852ea529d7019c41c3c8bcc15f58ad38e6e9
parent684abb75b1967c2fa019d3454627ff95c3435aa8 (diff)
- Add a doom that will not expire until it does not matter anymore.
- Doom can never be null. - Wire doom into fillBitVector. Using it will be a separate PR.
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/query.cpp2
-rw-r--r--searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp6
-rw-r--r--searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp28
-rw-r--r--searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp16
-rw-r--r--searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h20
-rw-r--r--searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp36
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/executeinfo.cpp14
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/executeinfo.h16
-rw-r--r--vespalib/src/vespa/vespalib/util/doom.cpp7
-rw-r--r--vespalib/src/vespa/vespalib/util/doom.h1
-rw-r--r--vespalib/src/vespa/vespalib/util/fake_doom.cpp2
-rw-r--r--vespalib/src/vespa/vespalib/util/fake_doom.h4
14 files changed, 88 insertions, 68 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp b/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp
index a3d2a9b33d9..fe5f66a05a7 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp
@@ -101,7 +101,7 @@ AttributeLimiter::create_match_data(size_t want_hits, size_t max_group_size, dou
_blueprint = _searchable_attributes.createBlueprint(_requestContext, field, node);
//TODO use_estimate must be switched to true quite soon
//TODO Use thread_bundle once verified(soon), _requestContext.thread_bundle()
- auto execInfo = ExecuteInfo::create(strictSearch, strictSearch ? 1.0 : hit_rate, &_requestContext.getDoom(),
+ auto execInfo = ExecuteInfo::create(strictSearch, strictSearch ? 1.0 : hit_rate, _requestContext.getDoom(),
vespalib::ThreadBundle::trivial(), true, false);
_blueprint->fetchPostings(execInfo);
_estimatedHits.store(_blueprint->getState().estimate().estHits, std::memory_order_relaxed);
diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp
index 920af030c74..68bda1eacbb 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp
@@ -209,7 +209,7 @@ MatchToolsFactory(QueryLimiter & queryLimiter,
bool create_postinglist_when_non_strict = CreatePostingListWhenNonStrict::check(_queryEnv.getProperties(), rankSetup.create_postinglist_when_non_strict());
bool use_estimate_for_fetch_postings = UseEstimateForFetchPostings::check(_queryEnv.getProperties(), rankSetup.use_estimate_for_fetch_postings());
bool use_thread_bundle_for_fetch_postings = UseThreadBundleForFetchPostings::check(_queryEnv.getProperties(), rankSetup.use_thread_bundle_for_fetch_postings());
- _query.fetchPostings(ExecuteInfo::create(is_search, hitRate, &_requestContext.getDoom(),
+ _query.fetchPostings(ExecuteInfo::create(is_search, hitRate, _requestContext.getDoom(),
use_thread_bundle_for_fetch_postings ? thread_bundle : vespalib::ThreadBundle::trivial(),
create_postinglist_when_non_strict, use_estimate_for_fetch_postings));
if (is_search) {
diff --git a/searchcore/src/vespa/searchcore/proton/matching/query.cpp b/searchcore/src/vespa/searchcore/proton/matching/query.cpp
index 027625a2a57..192be93d9b8 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/query.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/query.cpp
@@ -226,7 +226,7 @@ Query::handle_global_filter(const IRequestContext & requestContext, uint32_t doc
_blueprint = Blueprint::optimize(std::move(_blueprint));
LOG(debug, "blueprint after handle_global_filter:\n%s\n", _blueprint->asString().c_str());
// strictness may change if optimized order changed:
- fetchPostings(ExecuteInfo::create(true, 1.0, &requestContext.getDoom(), requestContext.thread_bundle(),
+ fetchPostings(ExecuteInfo::create(true, 1.0, requestContext.getDoom(), requestContext.thread_bundle(),
create_postinglist_when_non_strict, use_estimate_for_fetch_postings));
}
diff --git a/searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp b/searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp
index 6e334fffa75..d476f7d35d7 100644
--- a/searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp
+++ b/searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp
@@ -468,7 +468,7 @@ template <typename V, typename T>
ResultSetPtr
SearchContextTest::performSearch(const V & vec, const T & term)
{
- return performSearch(search::queryeval::ExecuteInfo::TRUE, vec, term, TermType::WORD);
+ return performSearch(queryeval::ExecuteInfo::TRUE, vec, term, TermType::WORD);
}
template <typename V, typename T>
@@ -503,7 +503,7 @@ void
SearchContextTest::performSearch(const V & vec, const vespalib::string & term,
const DocSet & expected, TermType termType)
{
- performSearch(search::queryeval::ExecuteInfo::TRUE, vec, term, expected, termType);
+ performSearch(queryeval::ExecuteInfo::TRUE, vec, term, expected, termType);
}
void
@@ -1113,7 +1113,7 @@ SearchContextTest::performRangeSearch(const VectorType & vec, const vespalib::st
{
for (size_t num_threads : {1,3}) {
vespalib::SimpleThreadBundle thread_bundle(num_threads);
- auto executeInfo = search::queryeval::ExecuteInfo::create(true, 1.0, nullptr, thread_bundle, true, true);
+ auto executeInfo = queryeval::ExecuteInfo::create(true, 1.0, vespalib::Doom::armageddon(), thread_bundle, true, true);
performSearch(executeInfo, vec, term, expected, TermType::WORD);
}
}
diff --git a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp
index 81862b74eb2..0d3dccd2f1c 100644
--- a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp
+++ b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp
@@ -7,7 +7,6 @@
#include <vespa/searchlib/tensor/dense_tensor_attribute.h>
#include <vespa/searchlib/tensor/direct_tensor_attribute.h>
#include <vespa/searchlib/tensor/doc_vector_access.h>
-#include <vespa/searchlib/tensor/distance_functions.h>
#include <vespa/searchlib/tensor/hnsw_index.h>
#include <vespa/searchlib/tensor/mips_distance_transform.h>
#include <vespa/searchlib/tensor/nearest_neighbor_index.h>
@@ -25,7 +24,6 @@
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/util/mmap_file_allocator_factory.h>
#include <vespa/searchlib/util/bufferwriter.h>
-#include <vespa/vespalib/util/fake_doom.h>
#include <vespa/vespalib/util/threadstackexecutor.h>
#include <vespa/document/base/exceptions.h>
#include <vespa/eval/eval/fast_value.h>
@@ -132,7 +130,7 @@ private:
int _index_value;
public:
- MockIndexSaver(int index_value) : _index_value(index_value) {}
+ explicit MockIndexSaver(int index_value) noexcept : _index_value(index_value) {}
void save(search::BufferWriter& writer) const override {
writer.write(&_index_value, sizeof(int));
writer.flush();
@@ -158,7 +156,7 @@ public:
class MockPrepareResult : public PrepareResult {
public:
uint32_t docid;
- MockPrepareResult(uint32_t docid_in) : docid(docid_in) {}
+ explicit MockPrepareResult(uint32_t docid_in) noexcept : docid(docid_in) {}
};
class MockNearestNeighborIndex : public NearestNeighborIndex {
@@ -177,7 +175,7 @@ private:
int _index_value;
public:
- MockNearestNeighborIndex(const DocVectorAccess& vectors)
+ explicit MockNearestNeighborIndex(const DocVectorAccess& vectors)
: _vectors(vectors),
_adds(),
_removes(),
@@ -279,11 +277,11 @@ public:
}
vespalib::MemoryUsage update_stat(const CompactionStrategy&) override {
++_memory_usage_cnt;
- return vespalib::MemoryUsage();
+ return {};
}
vespalib::MemoryUsage memory_usage() const override {
++_memory_usage_cnt;
- return vespalib::MemoryUsage();
+ return {};
}
void populate_address_space_usage(AddressSpaceUsage&) const override {}
void get_state(const vespalib::slime::Inserter&) const override {}
@@ -293,7 +291,7 @@ public:
if (_index_value != 0) {
return std::make_unique<MockIndexSaver>(_index_value);
}
- return std::unique_ptr<NearestNeighborIndexSaver>();
+ return {};
}
std::unique_ptr<NearestNeighborIndexLoader> make_loader(FastOS_FileInterface& file, const vespalib::GenericHeader& header) override {
(void) header;
@@ -310,7 +308,7 @@ public:
(void) explore_k;
(void) doom;
(void) distance_threshold;
- return std::vector<Neighbor>();
+ return {};
}
std::vector<Neighbor> find_top_k_with_filter(uint32_t k,
const search::tensor::BoundDistanceFunction &df,
@@ -324,7 +322,7 @@ public:
(void) filter;
(void) doom;
(void) distance_threshold;
- return std::vector<Neighbor>();
+ return {};
}
search::tensor::DistanceFunctionFactory &distance_function_factory() const override {
@@ -427,7 +425,7 @@ struct Fixture {
FixtureTraits _traits;
vespalib::string _mmap_allocator_base_dir;
- Fixture(const vespalib::string &typeSpec, FixtureTraits traits = FixtureTraits());
+ explicit Fixture(const vespalib::string &typeSpec, FixtureTraits traits = FixtureTraits());
~Fixture();
@@ -589,7 +587,7 @@ struct Fixture {
}
TensorSpec expEmptyDenseTensor() const {
- return TensorSpec(denseSpec);
+ return {denseSpec};
}
vespalib::string expEmptyDenseTensorSpec() const {
@@ -1296,12 +1294,10 @@ template <typename ParentT>
class NearestNeighborBlueprintFixtureBase : public ParentT {
private:
std::unique_ptr<Value> _query_tensor;
- vespalib::FakeDoom _no_doom;
public:
NearestNeighborBlueprintFixtureBase()
- : _query_tensor(),
- _no_doom()
+ : _query_tensor()
{
this->set_tensor(1, vec_2d(1, 1));
this->set_tensor(2, vec_2d(2, 2));
@@ -1329,7 +1325,7 @@ public:
std::make_unique<DistanceCalculator>(this->as_dense_tensor(),
create_query_tensor(vec_2d(17, 42))),
3, approximate, 5, 100100.25,
- global_filter_lower_limit, 1.0, target_hits_max_adjustment_factor, _no_doom.get_doom());
+ global_filter_lower_limit, 1.0, target_hits_max_adjustment_factor, vespalib::Doom::armageddon());
EXPECT_EQUAL(11u, bp->getState().estimate().estHits);
EXPECT_EQUAL(100100.25 * 100100.25, bp->get_distance_threshold());
return bp;
diff --git a/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp b/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp
index 74d4600a079..da58dd749ba 100644
--- a/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp
+++ b/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp
@@ -106,7 +106,7 @@ public:
.set(7, {3, 5}).set(8, {0, 3}).set(9, {4, 5});
}
- ~HnswIndexTest() {}
+ ~HnswIndexTest() override {}
auto dff() {
return search::tensor::make_distance_function_factory(
@@ -135,7 +135,7 @@ public:
gen_handler.incGeneration();
index->reclaim_memory(gen_handler.get_oldest_used_generation());
}
- void set_filter(std::vector<uint32_t> docids) {
+ void set_filter(const std::vector<uint32_t>& docids) {
uint32_t sz = 10;
global_filter = GlobalFilter::create(docids, sz);
}
@@ -168,7 +168,7 @@ public:
ASSERT_EQ(exp_levels.size(), act_node.size());
EXPECT_EQ(exp_levels, act_node.levels());
}
- void expect_top_3_by_docid(const vespalib::string& label, std::vector<float> qv, std::vector<uint32_t> exp) {
+ void expect_top_3_by_docid(const vespalib::string& label, std::vector<float> qv, const std::vector<uint32_t>& exp) {
SCOPED_TRACE(label);
uint32_t k = 3;
uint32_t explore_k = 100;
@@ -794,7 +794,7 @@ class MyGlobalFilter : public GlobalFilter {
std::shared_ptr<GlobalFilter> _filter;
mutable uint32_t _max_docid;
public:
- MyGlobalFilter(std::shared_ptr<GlobalFilter> filter) noexcept
+ explicit MyGlobalFilter(std::shared_ptr<GlobalFilter> filter) noexcept
: _filter(std::move(filter)),
_max_docid(0)
{
@@ -845,7 +845,7 @@ TEST_F(HnswMultiIndexTest, duplicate_docid_is_removed)
global_filter = filter;
this->expect_top_3_by_docid("{2,2}", {2, 2}, {1, 2});
EXPECT_EQ(2, filter->max_docid());
-};
+}
TEST_F(HnswMultiIndexTest, docid_with_empty_tensor_can_be_removed)
{
@@ -904,10 +904,10 @@ TEST(LevelGeneratorTest, gives_various_levels)
}
hist[l]++;
}
- for (uint32_t l = 0; l < hist.size(); ++l) {
+ for (unsigned int l : hist) {
double expected = left * 0.75;
- EXPECT_TRUE(hist[l] < expected*1.01 + 100);
- EXPECT_TRUE(hist[l] > expected*0.99 - 100);
+ EXPECT_TRUE(l < expected*1.01 + 100);
+ EXPECT_TRUE(l > expected*0.99 - 100);
left *= 0.25;
}
EXPECT_TRUE(hist.size() < 14);
diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h
index 0b75e8c2c0d..50c1e4d2498 100644
--- a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h
+++ b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h
@@ -72,8 +72,6 @@ protected:
* by looking at the posting lists in the range [lower, upper>.
*/
virtual size_t calc_estimated_hits_in_range() const = 0;
- virtual void fillArray() = 0;
- virtual void fillBitVector(vespalib::ThreadBundle & thread_bundle) = 0;
};
@@ -88,6 +86,7 @@ protected:
using AtomicEntryRef = vespalib::datastore::AtomicEntryRef;
using EntryRef = vespalib::datastore::EntryRef;
using FrozenView = typename PostingStore::BTreeType::FrozenView;
+ using ExecuteInfo = queryeval::ExecuteInfo;
const PostingStore& _posting_store;
/*
@@ -101,10 +100,10 @@ protected:
~PostingListSearchContextT() override;
void lookupSingle();
- void fillArray() override;
- void fillBitVector(vespalib::ThreadBundle & thread_bundle) override;
+ virtual void fillArray();
+ virtual void fillBitVector(const ExecuteInfo &);
- void fetchPostings(const queryeval::ExecuteInfo & strict) override;
+ void fetchPostings(const ExecuteInfo & strict) override;
// this will be called instead of the fetchPostings function in some cases
void diversify(bool forward, size_t wanted_hits, const IAttributeVector &diversity_attr,
size_t max_per_group, size_t cutoff_groups, bool cutoff_strict);
@@ -131,6 +130,7 @@ protected:
using DictionaryConstIterator = Dictionary::ConstIterator;
using EntryRef = vespalib::datastore::EntryRef;
using PostingStore = typename Parent::PostingStore;
+ using ExecuteInfo = queryeval::ExecuteInfo;
using Parent::_docIdLimit;
using Parent::_lowerDictItr;
using Parent::_merger;
@@ -154,7 +154,7 @@ protected:
template <bool fill_array>
void fill_array_or_bitvector();
void fillArray() override;
- void fillBitVector(vespalib::ThreadBundle & thread_bundle) override;
+ void fillBitVector(const ExecuteInfo &) override;
};
@@ -177,6 +177,7 @@ class StringPostingSearchContext
: public PostingSearchContext<BaseSC, PostingListFoldedSearchContextT<DataT>, AttrT>
{
private:
+ using ExecuteInfo = queryeval::ExecuteInfo;
using Parent = PostingSearchContext<BaseSC, PostingListFoldedSearchContextT<DataT>, AttrT>;
using RegexpUtil = vespalib::RegexpUtil;
using Parent::_enumStore;
@@ -186,7 +187,7 @@ private:
bool use_single_dictionary_entry(PostingListSearchContext::DictionaryConstIterator it) const {
return use_dictionary_entry(it);
}
- bool use_posting_lists_when_non_strict(const queryeval::ExecuteInfo& info) const override;
+ bool use_posting_lists_when_non_strict(const ExecuteInfo& info) const override;
public:
StringPostingSearchContext(BaseSC&& base_sc, bool useBitVector, const AttrT &toBeSearched);
};
@@ -196,6 +197,7 @@ class NumericPostingSearchContext
: public PostingSearchContext<BaseSC, PostingListSearchContextT<DataT>, AttrT>
{
private:
+ using ExecuteInfo = queryeval::ExecuteInfo;
using Parent = PostingSearchContext<BaseSC, PostingListSearchContextT<DataT>, AttrT>;
using BaseType = typename AttrT::T;
using Params = attribute::SearchContextParams;
@@ -215,7 +217,7 @@ private:
? limit
: estimate;
}
- void fetchPostings(const queryeval::ExecuteInfo & execInfo) override {
+ void fetchPostings(const ExecuteInfo & execInfo) override {
if (params().diversityAttribute() != nullptr) {
bool forward = (this->getRangeLimit() > 0);
size_t wanted_hits = std::abs(this->getRangeLimit());
@@ -227,7 +229,7 @@ private:
}
}
- bool use_posting_lists_when_non_strict(const queryeval::ExecuteInfo& info) const override;
+ bool use_posting_lists_when_non_strict(const ExecuteInfo& info) const override;
size_t calc_estimated_hits_in_range() const override;
public:
diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp
index 68d78619cb5..65c103152d3 100644
--- a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp
@@ -68,11 +68,14 @@ PostingListSearchContextT<DataT>::fillArray()
template <typename DataT>
struct PostingListSearchContextT<DataT>::FillPart : public vespalib::Runnable {
- FillPart(const PostingStore& posting_store, const DictionaryConstIterator & from, size_t count, uint32_t limit)
- : FillPart(posting_store, from, count, nullptr, limit)
+ FillPart(const vespalib::Doom & doom, const PostingStore& posting_store, const DictionaryConstIterator & from,
+ size_t count, uint32_t limit)
+ : FillPart(doom, posting_store, from, count, nullptr, limit)
{ }
- FillPart(const PostingStore& posting_store, const DictionaryConstIterator & from, size_t count, BitVector * bv, uint32_t limit)
- : _posting_store(posting_store),
+ FillPart(const vespalib::Doom & doom, const PostingStore& posting_store, const DictionaryConstIterator & from,
+ size_t count, BitVector * bv, uint32_t limit)
+ : _doom(doom),
+ _posting_store(posting_store),
_bv(bv),
_docIdLimit(limit),
_from(from),
@@ -86,7 +89,8 @@ struct PostingListSearchContextT<DataT>::FillPart : public vespalib::Runnable {
_owned_bv = BitVector::create(_docIdLimit);
_bv = _owned_bv.get();
}
- for (;_from != _to;++_from) {
+ //TODO Add && !_doom.soft_doom() to loop
+ for ( ;_from != _to; ++_from) {
addToBitVector(PostingListTraverser<PostingStore>(_posting_store, _from.getData().load_acquire()));
}
}
@@ -95,6 +99,7 @@ struct PostingListSearchContextT<DataT>::FillPart : public vespalib::Runnable {
if (__builtin_expect(key < _docIdLimit, true)) { _bv->setBit(key); }
});
}
+ const vespalib::Doom _doom;
const PostingStore &_posting_store;
BitVector *_bv;
uint32_t _docIdLimit;
@@ -105,8 +110,9 @@ struct PostingListSearchContextT<DataT>::FillPart : public vespalib::Runnable {
template <typename DataT>
void
-PostingListSearchContextT<DataT>::fillBitVector(vespalib::ThreadBundle & thread_bundle)
+PostingListSearchContextT<DataT>::fillBitVector(const ExecuteInfo & exec_info)
{
+ vespalib::ThreadBundle & thread_bundle = exec_info.thread_bundle();
size_t num_iter = _upperDictItr - _lowerDictItr;
size_t num_threads = std::min(thread_bundle.size(), num_iter);
@@ -115,10 +121,10 @@ PostingListSearchContextT<DataT>::fillBitVector(vespalib::ThreadBundle & thread_
std::vector<FillPart> parts;
parts.reserve(num_threads);
BitVector * master = _merger.getBitVector();
- parts.emplace_back(_posting_store, _lowerDictItr, per_thread + (rest_docs > 0), master, _merger.getDocIdLimit());
+ parts.emplace_back(exec_info.doom(), _posting_store, _lowerDictItr, per_thread + (rest_docs > 0), master, _merger.getDocIdLimit());
for (size_t i(1); i < num_threads; i++) {
size_t num_this_thread = per_thread + (i < rest_docs);
- parts.emplace_back(_posting_store, parts[i-1]._to, num_this_thread, _merger.getDocIdLimit());
+ parts.emplace_back(exec_info.doom(), _posting_store, parts[i-1]._to, num_this_thread, _merger.getDocIdLimit());
}
thread_bundle.run(parts);
for (size_t i(1); i < parts.size(); i++) {
@@ -128,7 +134,7 @@ PostingListSearchContextT<DataT>::fillBitVector(vespalib::ThreadBundle & thread_
template <typename DataT>
void
-PostingListSearchContextT<DataT>::fetchPostings(const queryeval::ExecuteInfo & execInfo)
+PostingListSearchContextT<DataT>::fetchPostings(const ExecuteInfo & exec_info)
{
// The following constant is derived after running parts of
// the range search performance test with 10M documents on an Apple M1 Pro with 32 GB memory.
@@ -159,14 +165,14 @@ PostingListSearchContextT<DataT>::fetchPostings(const queryeval::ExecuteInfo & e
// The threshold for when to use array merging is therefore 0.0025 (0.08 / 32).
constexpr float threshold_for_using_array = 0.0025;
if (!_merger.merge_done() && _uniqueValues >= 2u && this->_dictionary.get_has_btree_dictionary()) {
- if (execInfo.is_strict() || use_posting_lists_when_non_strict(execInfo)) {
+ if (exec_info.is_strict() || use_posting_lists_when_non_strict(exec_info)) {
size_t sum = estimated_hits_in_range();
if (sum < (_docIdLimit * threshold_for_using_array)) {
_merger.reserveArray(_uniqueValues, sum);
fillArray();
} else {
_merger.allocBitVector();
- fillBitVector(execInfo.thread_bundle());
+ fillBitVector(exec_info);
}
_merger.merge();
}
@@ -219,7 +225,7 @@ createPostingIterator(fef::TermFieldMatchData *matchData, bool strict)
}
const BitVector *bv(_merger.getBitVector());
assert(bv != nullptr);
- return search::BitVectorIterator::create(bv, bv->size(), *matchData, strict);
+ return BitVectorIterator::create(bv, bv->size(), *matchData, strict);
}
if (_uniqueValues == 1) {
if (_bv != nullptr && (!_pidx.valid() || _useBitVector || matchData->isNotNeeded())) {
@@ -417,9 +423,9 @@ PostingListFoldedSearchContextT<DataT>::fillArray()
template <typename DataT>
void
-PostingListFoldedSearchContextT<DataT>::fillBitVector(vespalib::ThreadBundle & thread_bundle)
+PostingListFoldedSearchContextT<DataT>::fillBitVector(const ExecuteInfo & exec_info)
{
- (void) thread_bundle;
+ (void) exec_info;
fill_array_or_bitvector<false>();
}
@@ -483,7 +489,7 @@ StringPostingSearchContext<BaseSC, AttrT, DataT>::use_dictionary_entry(PostingLi
template <typename BaseSC, typename AttrT, typename DataT>
bool
-StringPostingSearchContext<BaseSC, AttrT, DataT>::use_posting_lists_when_non_strict(const queryeval::ExecuteInfo& info) const
+StringPostingSearchContext<BaseSC, AttrT, DataT>::use_posting_lists_when_non_strict(const ExecuteInfo& info) const
{
if (this->isFuzzy()) {
uint32_t exp_doc_hits = this->_docIdLimit * info.hit_rate();
diff --git a/searchlib/src/vespa/searchlib/queryeval/executeinfo.cpp b/searchlib/src/vespa/searchlib/queryeval/executeinfo.cpp
index 858cb92331a..5ae65586829 100644
--- a/searchlib/src/vespa/searchlib/queryeval/executeinfo.cpp
+++ b/searchlib/src/vespa/searchlib/queryeval/executeinfo.cpp
@@ -2,9 +2,19 @@
#include "executeinfo.h"
+using vespalib::Doom;
namespace search::queryeval {
-const ExecuteInfo ExecuteInfo::TRUE(true, 1.0, nullptr, vespalib::ThreadBundle::trivial(), true, true);
-const ExecuteInfo ExecuteInfo::FALSE(false, 1.0, nullptr, vespalib::ThreadBundle::trivial(), true, true);
+const ExecuteInfo ExecuteInfo::TRUE(true, 1.0, Doom::armageddon(), vespalib::ThreadBundle::trivial(), true, true);
+const ExecuteInfo ExecuteInfo::FALSE(false, 1.0, Doom::armageddon(), vespalib::ThreadBundle::trivial(), true, true);
+
+ExecuteInfo::ExecuteInfo() noexcept
+ : ExecuteInfo(false, 1.0, Doom::armageddon(), vespalib::ThreadBundle::trivial(), true, true)
+{ }
+
+ExecuteInfo
+ExecuteInfo::createForTest(bool strict, double hitRate) noexcept {
+ return createForTest(strict, hitRate, Doom::armageddon());
+}
}
diff --git a/searchlib/src/vespa/searchlib/queryeval/executeinfo.h b/searchlib/src/vespa/searchlib/queryeval/executeinfo.h
index 3300a2aea4d..fc52d3b531e 100644
--- a/searchlib/src/vespa/searchlib/queryeval/executeinfo.h
+++ b/searchlib/src/vespa/searchlib/queryeval/executeinfo.h
@@ -13,12 +13,12 @@ namespace search::queryeval {
*/
class ExecuteInfo {
public:
- ExecuteInfo() noexcept : ExecuteInfo(false, 1.0, nullptr, vespalib::ThreadBundle::trivial(), true, true) { }
+ ExecuteInfo() noexcept;
bool is_strict() const noexcept { return _strict; }
bool create_postinglist_when_non_strict() const noexcept { return _create_postinglist_when_non_strict; }
bool use_estimate_for_fetch_postings() const noexcept { return _use_estimate_for_fetch_postings; }
double hit_rate() const noexcept { return _hitRate; }
- bool soft_doom() const noexcept { return _doom && _doom->soft_doom(); }
+ const vespalib::Doom & doom() const noexcept { return _doom; }
vespalib::ThreadBundle & thread_bundle() const noexcept { return _thread_bundle; }
static const ExecuteInfo TRUE;
@@ -30,7 +30,7 @@ public:
return {strict, hitRate, org._doom, org.thread_bundle(), org.create_postinglist_when_non_strict(), org.use_estimate_for_fetch_postings()};
}
- static ExecuteInfo create(bool strict, double hitRate, const vespalib::Doom * doom, vespalib::ThreadBundle & thread_bundle_in,
+ static ExecuteInfo create(bool strict, double hitRate, const vespalib::Doom & doom, vespalib::ThreadBundle & thread_bundle_in,
bool postinglist_when_non_strict, bool use_estimate_for_fetch_postings) noexcept
{
return {strict, hitRate, doom, thread_bundle_in, postinglist_when_non_strict, use_estimate_for_fetch_postings};
@@ -38,14 +38,12 @@ public:
static ExecuteInfo createForTest(bool strict) noexcept {
return createForTest(strict, 1.0);
}
- static ExecuteInfo createForTest(bool strict, double hitRate) noexcept {
- return createForTest(strict, hitRate, nullptr);
- }
- static ExecuteInfo createForTest(bool strict, double hitRate, const vespalib::Doom * doom) noexcept {
+ static ExecuteInfo createForTest(bool strict, double hitRate) noexcept;
+ static ExecuteInfo createForTest(bool strict, double hitRate, const vespalib::Doom & doom) noexcept {
return create(strict, hitRate, doom, vespalib::ThreadBundle::trivial(), true, true);
}
private:
- ExecuteInfo(bool strict, double hitRate_in, const vespalib::Doom * doom, vespalib::ThreadBundle & thread_bundle_in,
+ ExecuteInfo(bool strict, double hitRate_in, const vespalib::Doom & doom, vespalib::ThreadBundle & thread_bundle_in,
bool postinglist_when_non_strict, bool use_estimate_for_fetch_postings) noexcept
: _doom(doom),
_thread_bundle(thread_bundle_in),
@@ -54,7 +52,7 @@ private:
_create_postinglist_when_non_strict(postinglist_when_non_strict),
_use_estimate_for_fetch_postings(use_estimate_for_fetch_postings)
{ }
- const vespalib::Doom * _doom;
+ const vespalib::Doom _doom;
vespalib::ThreadBundle & _thread_bundle;
double _hitRate;
bool _strict;
diff --git a/vespalib/src/vespa/vespalib/util/doom.cpp b/vespalib/src/vespa/vespalib/util/doom.cpp
index 227d43ee4c4..fa036c0c9c7 100644
--- a/vespalib/src/vespa/vespalib/util/doom.cpp
+++ b/vespalib/src/vespa/vespalib/util/doom.cpp
@@ -1,9 +1,14 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "doom.h"
+#include "fake_doom.h"
namespace vespalib {
+namespace {
+ vespalib::FakeDoom practicallyNeverExpire(std::chrono::hours(24*365*100)); // doom in 100 years
+}
+
Doom::Doom(const Clock &clock, steady_time softDoom,
steady_time hardDoom, bool explicitSoftDoom) noexcept
: _clock(clock),
@@ -12,4 +17,6 @@ Doom::Doom(const Clock &clock, steady_time softDoom,
_isExplicitSoftDoom(explicitSoftDoom)
{ }
+const Doom & Doom::armageddon() noexcept { return practicallyNeverExpire.get_doom(); }
+
}
diff --git a/vespalib/src/vespa/vespalib/util/doom.h b/vespalib/src/vespa/vespalib/util/doom.h
index a175bbd20df..bf9d9343b8c 100644
--- a/vespalib/src/vespa/vespalib/util/doom.h
+++ b/vespalib/src/vespa/vespalib/util/doom.h
@@ -19,6 +19,7 @@ public:
duration soft_left() const noexcept { return _softDoom - _clock.getTimeNS(); }
duration hard_left() const noexcept { return _hardDoom - _clock.getTimeNS(); }
bool isExplicitSoftDoom() const noexcept { return _isExplicitSoftDoom; }
+ static const Doom & armageddon() noexcept;
private:
const Clock &_clock;
steady_time _softDoom;
diff --git a/vespalib/src/vespa/vespalib/util/fake_doom.cpp b/vespalib/src/vespa/vespalib/util/fake_doom.cpp
index 51318db135c..d9cbce0b152 100644
--- a/vespalib/src/vespa/vespalib/util/fake_doom.cpp
+++ b/vespalib/src/vespa/vespalib/util/fake_doom.cpp
@@ -4,7 +4,7 @@
namespace vespalib {
-FakeDoom::FakeDoom(steady_time::duration time_to_doom)
+FakeDoom::FakeDoom(steady_time::duration time_to_doom) noexcept
: _time(steady_clock::now()),
_clock(_time),
_doom(_clock, _clock.getTimeNS() + time_to_doom)
diff --git a/vespalib/src/vespa/vespalib/util/fake_doom.h b/vespalib/src/vespa/vespalib/util/fake_doom.h
index 78fc9d0f38a..1e6cfcb0c4d 100644
--- a/vespalib/src/vespa/vespalib/util/fake_doom.h
+++ b/vespalib/src/vespa/vespalib/util/fake_doom.h
@@ -15,8 +15,8 @@ class FakeDoom {
Clock _clock;
Doom _doom;
public:
- FakeDoom() : FakeDoom(1s) { }
- FakeDoom(steady_time::duration time_to_doom);
+ FakeDoom() noexcept : FakeDoom(1s) { }
+ FakeDoom(steady_time::duration time_to_doom) noexcept;
~FakeDoom();
const Doom& get_doom() const noexcept { return _doom; }
};