diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-12-12 12:18:38 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2023-12-12 12:18:38 +0000 |
commit | 3f54d4088502406eda15288bde29a16f6c810751 (patch) | |
tree | 838d8518e5d65f51e812bc4b4a7a14c67bb3b7a9 /searchcore | |
parent | 00f810fa679db282b246d83a3b7b4003a206f722 (diff) |
Wire in thread bundle to execute info and request context.
Diffstat (limited to 'searchcore')
9 files changed, 46 insertions, 30 deletions
diff --git a/searchcore/src/tests/proton/matching/match_phase_limiter/match_phase_limiter_test.cpp b/searchcore/src/tests/proton/matching/match_phase_limiter/match_phase_limiter_test.cpp index b26ed1d4765..67490c03985 100644 --- a/searchcore/src/tests/proton/matching/match_phase_limiter/match_phase_limiter_test.cpp +++ b/searchcore/src/tests/proton/matching/match_phase_limiter/match_phase_limiter_test.cpp @@ -78,7 +78,7 @@ struct MockBlueprint : SimpleLeafBlueprint { SearchIterator::UP createLeafSearch(const TermFieldMatchDataArray &tfmda, bool strict) const override { if (postings_fetched) { - EXPECT_EQUAL(postings_strict.isStrict(), strict); + EXPECT_EQUAL(postings_strict.is_strict(), strict); } return std::make_unique<MockSearch>(spec, term, strict, tfmda, postings_fetched); } diff --git a/searchcore/src/tests/proton/matching/request_context/request_context_test.cpp b/searchcore/src/tests/proton/matching/request_context/request_context_test.cpp index 815561dc94c..8b223c3ef3a 100644 --- a/searchcore/src/tests/proton/matching/request_context/request_context_test.cpp +++ b/searchcore/src/tests/proton/matching/request_context/request_context_test.cpp @@ -8,6 +8,7 @@ #include <vespa/searchlib/fef/test/indexenvironment.h> #include <vespa/searchlib/fef/test/queryenvironment.h> #include <vespa/vespalib/util/testclock.h> +#include <vespa/vespalib/util/simple_thread_bundle.h> #include <vespa/vespalib/gtest/gtest.h> #include <vespa/vespalib/objects/nbostream.h> @@ -34,13 +35,14 @@ public: class RequestContextTest : public ::testing::Test { private: - vespalib::TestClock _clock; - vespalib::Doom _doom; - MyAttributeContext _attr_ctx; - IndexEnvironment _index_env; - QueryEnvironment _query_env; - RequestContext _request_ctx; - Value::UP _query_tensor; + vespalib::TestClock _clock; + vespalib::Doom _doom; + vespalib::SimpleThreadBundle _thread_bundle; + MyAttributeContext _attr_ctx; + IndexEnvironment _index_env; + QueryEnvironment _query_env; + RequestContext _request_ctx; + Value::UP _query_tensor; void insert_tensor_in_properties(const vespalib::string& tensor_name, const Value& tensor_value) { vespalib::nbostream stream; @@ -52,10 +54,11 @@ public: RequestContextTest() : _clock(), _doom(_clock.clock(), vespalib::steady_time(), vespalib::steady_time(), false), + _thread_bundle(1), _attr_ctx(), _index_env(), _query_env(&_index_env), - _request_ctx(_doom, _attr_ctx, _query_env, _query_env.getObjectStore(), AttributeBlueprintParams(), nullptr), + _request_ctx(_doom, _thread_bundle, _attr_ctx, _query_env, _query_env.getObjectStore(), AttributeBlueprintParams(), nullptr), _query_tensor(SimpleValue::from_spec(TensorSpec("tensor(x[2])") .add({{"x", 0}}, 3).add({{"x", 1}}, 5))) { diff --git a/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp b/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp index d66f5420990..51d96c5a843 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp @@ -100,7 +100,8 @@ AttributeLimiter::create_match_data(size_t want_hits, size_t max_group_size, dou field.add(FieldSpec(_attribute_name, my_field_id, my_handle)); _blueprint = _searchable_attributes.createBlueprint(_requestContext, field, node); //TODO use_estimate must be switched to true quite soon - auto execInfo = ExecuteInfo::create(strictSearch, strictSearch ? 1.0 : hit_rate, &_requestContext.getDoom(), true, false); + auto execInfo = ExecuteInfo::create(strictSearch, strictSearch ? 1.0 : hit_rate, &_requestContext.getDoom(), + _requestContext.thread_bundle(), true, false); _blueprint->fetchPostings(execInfo); _estimatedHits.store(_blueprint->getState().estimate().estHits, std::memory_order_relaxed); _blueprint->freeze(); diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp index ace0f8642b9..dc1596b9d16 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp @@ -182,7 +182,8 @@ MatchToolsFactory(QueryLimiter & queryLimiter, _query(), _match_limiter(), _queryEnv(indexEnv, attributeContext, rankProperties, searchContext.getIndexes()), - _requestContext(doom, attributeContext, _queryEnv, _queryEnv.getObjectStore(), _attribute_blueprint_params, metaStoreReadGuard), + _requestContext(doom, thread_bundle, attributeContext, _queryEnv, _queryEnv.getObjectStore(), + _attribute_blueprint_params, metaStoreReadGuard), _mdl(), _rankSetup(rankSetup), _featureOverrides(featureOverrides), @@ -207,14 +208,13 @@ MatchToolsFactory(QueryLimiter & queryLimiter, double hitRate = std::min(1.0, double(maxNumHits)/double(searchContext.getDocIdLimit())); 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()); - _query.fetchPostings(ExecuteInfo::create(is_search, hitRate, &_requestContext.getDoom(), + _query.fetchPostings(ExecuteInfo::create(is_search, hitRate, &_requestContext.getDoom(), &thread_bundle, create_postinglist_when_non_strict, use_estimate_for_fetch_postings)); if (is_search) { - _query.handle_global_filter(_requestContext.getDoom(), searchContext.getDocIdLimit(), + _query.handle_global_filter(_requestContext, searchContext.getDocIdLimit(), _attribute_blueprint_params.global_filter_lower_limit, _attribute_blueprint_params.global_filter_upper_limit, - thread_bundle, trace, create_postinglist_when_non_strict, - use_estimate_for_fetch_postings); + trace, create_postinglist_when_non_strict, use_estimate_for_fetch_postings); } _query.freeze(); trace.addEvent(5, "Prepare shared state for multi-threaded rank executors"); diff --git a/searchcore/src/vespa/searchcore/proton/matching/query.cpp b/searchcore/src/vespa/searchcore/proton/matching/query.cpp index 42db9ab65ab..451a891312c 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/query.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/query.cpp @@ -211,12 +211,14 @@ Query::fetchPostings(const ExecuteInfo & executeInfo) } void -Query::handle_global_filter(const vespalib::Doom & doom, uint32_t docid_limit, +Query::handle_global_filter(const IRequestContext & requestContext, uint32_t docid_limit, double global_filter_lower_limit, double global_filter_upper_limit, - vespalib::ThreadBundle &thread_bundle, search::engine::Trace& trace, + search::engine::Trace& trace, bool create_postinglist_when_non_strict, bool use_estimate_for_fetch_postings) { - if (!handle_global_filter(*_blueprint, docid_limit, global_filter_lower_limit, global_filter_upper_limit, thread_bundle, &trace)) { + if (!handle_global_filter(*_blueprint, docid_limit, global_filter_lower_limit, global_filter_upper_limit, + *requestContext.thread_bundle(), &trace)) + { return; } // optimized order may change after accounting for global filter: @@ -224,7 +226,8 @@ Query::handle_global_filter(const vespalib::Doom & doom, uint32_t docid_limit, _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, &doom, create_postinglist_when_non_strict, use_estimate_for_fetch_postings)); + fetchPostings(ExecuteInfo::create(true, 1.0, &requestContext.getDoom(), requestContext.thread_bundle(), + create_postinglist_when_non_strict, use_estimate_for_fetch_postings)); } bool diff --git a/searchcore/src/vespa/searchcore/proton/matching/query.h b/searchcore/src/vespa/searchcore/proton/matching/query.h index c3ea2c5e664..97402d766ea 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/query.h +++ b/searchcore/src/vespa/searchcore/proton/matching/query.h @@ -24,14 +24,16 @@ private: using Blueprint = search::queryeval::Blueprint; using GlobalFilter = search::queryeval::GlobalFilter; using ExecuteInfo = search::queryeval::ExecuteInfo; - search::query::Node::UP _query_tree; - Blueprint::UP _blueprint; - Blueprint::UP _whiteListBlueprint; - std::vector<search::common::GeoLocationSpec> _locations; + using IRequestContext = search::queryeval::IRequestContext; + using GeoLocationSpec = search::common::GeoLocationSpec; + search::query::Node::UP _query_tree; + Blueprint::UP _blueprint; + Blueprint::UP _whiteListBlueprint; + std::vector<GeoLocationSpec> _locations; public: /** Convenience typedef. */ - using GeoLocationSpecPtrs = std::vector<const search::common::GeoLocationSpec *>; + using GeoLocationSpecPtrs = std::vector<const GeoLocationSpec *>; Query(); ~Query(); @@ -89,7 +91,7 @@ public: * @param context search context * @param mdl match data layout **/ - void reserveHandles(const search::queryeval::IRequestContext & requestContext, + void reserveHandles(const IRequestContext & requestContext, ISearchContext &context, search::fef::MatchDataLayout &mdl); @@ -104,9 +106,9 @@ public: void optimize(); void fetchPostings(const ExecuteInfo & executeInfo) ; - void handle_global_filter(const vespalib::Doom & doom, uint32_t docid_limit, + void handle_global_filter(const IRequestContext & requestContext, uint32_t docid_limit, double global_filter_lower_limit, double global_filter_upper_limit, - vespalib::ThreadBundle &thread_bundle, search::engine::Trace& trace, + search::engine::Trace& trace, bool create_postinglist_when_non_strict, bool use_estimate_for_fetch_postings); /** diff --git a/searchcore/src/vespa/searchcore/proton/matching/requestcontext.cpp b/searchcore/src/vespa/searchcore/proton/matching/requestcontext.cpp index 41da21b1583..9663a3ebd8b 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/requestcontext.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/requestcontext.cpp @@ -18,12 +18,15 @@ namespace proton { using search::attribute::IAttributeVector; -RequestContext::RequestContext(const Doom & doom, IAttributeContext & attributeContext, +RequestContext::RequestContext(const Doom & doom, + vespalib::ThreadBundle & thread_bundle_in, + IAttributeContext & attributeContext, const search::fef::IQueryEnvironment& query_env, search::fef::IObjectStore& shared_store, const search::attribute::AttributeBlueprintParams& attribute_blueprint_params, const MetaStoreReadGuardSP * metaStoreReadGuard) : _doom(doom), + _thread_bundle(thread_bundle_in), _attributeContext(attributeContext), _query_env(query_env), _shared_store(shared_store), diff --git a/searchcore/src/vespa/searchcore/proton/matching/requestcontext.h b/searchcore/src/vespa/searchcore/proton/matching/requestcontext.h index 5596826f7da..d843035791d 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/requestcontext.h +++ b/searchcore/src/vespa/searchcore/proton/matching/requestcontext.h @@ -23,6 +23,7 @@ public: using IAttributeFunctor = search::attribute::IAttributeFunctor; using Doom = vespalib::Doom; RequestContext(const Doom& softDoom, + vespalib::ThreadBundle & threadBundle, IAttributeContext& attributeContext, const search::fef::IQueryEnvironment& query_env, search::fef::IObjectStore& shared_store, @@ -30,6 +31,7 @@ public: const MetaStoreReadGuardSP * metaStoreReadGuard); const Doom & getDoom() const override { return _doom; } + vespalib::ThreadBundle * thread_bundle() const override { return &_thread_bundle; } const search::attribute::IAttributeVector *getAttribute(const vespalib::string &name) const override; void asyncForAttribute(const vespalib::string &name, std::unique_ptr<IAttributeFunctor> func) const override; @@ -47,6 +49,7 @@ public: private: const Doom _doom; + vespalib::ThreadBundle & _thread_bundle; IAttributeContext & _attributeContext; const search::fef::IQueryEnvironment & _query_env; search::fef::IObjectStore & _shared_store; diff --git a/searchcore/src/vespa/searchcorespi/index/warmupindexcollection.cpp b/searchcore/src/vespa/searchcorespi/index/warmupindexcollection.cpp index 46dfcda119d..bd6dc6da558 100644 --- a/searchcore/src/vespa/searchcorespi/index/warmupindexcollection.cpp +++ b/searchcore/src/vespa/searchcorespi/index/warmupindexcollection.cpp @@ -35,9 +35,10 @@ class WarmupRequestContext : public IRequestContext { using IAttributeVector = search::attribute::IAttributeVector; using AttributeBlueprintParams = search::attribute::AttributeBlueprintParams; public: - WarmupRequestContext(const vespalib::Clock & clock); + explicit WarmupRequestContext(const vespalib::Clock & clock); ~WarmupRequestContext() override; const vespalib::Doom & getDoom() const override { return _doom; } + vespalib::ThreadBundle * thread_bundle() const override { return nullptr; } const IAttributeVector *getAttribute(const vespalib::string &) const override { return nullptr; } const IAttributeVector *getAttributeStableEnum(const vespalib::string &) const override { return nullptr; } const vespalib::eval::Value* get_query_tensor(const vespalib::string&) const override; @@ -182,7 +183,7 @@ WarmupIndexCollection::fireWarmup(Task::UP task) bool WarmupIndexCollection::handledBefore(uint32_t fieldId, const Node &term) { - const StringBase * sb(dynamic_cast<const StringBase *>(&term)); + const auto * sb(dynamic_cast<const StringBase *>(&term)); if (sb != nullptr) { const vespalib::string & s = sb->getTerm(); std::lock_guard<std::mutex> guard(_lock); |