diff options
Diffstat (limited to 'searchcore/src/vespa')
3 files changed, 12 insertions, 28 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matching/extract_features.cpp b/searchcore/src/vespa/searchcore/proton/matching/extract_features.cpp index 6115d642b4a..8f7970f5717 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/extract_features.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/extract_features.cpp @@ -114,22 +114,6 @@ struct LaterChunk : MyChunk { } }; -struct MyWork { - size_t num_threads; - std::vector<Runnable::UP> chunks; - MyWork(ThreadBundle &thread_bundle) : num_threads(thread_bundle.size()), chunks() { - chunks.reserve(num_threads); - } - void run(ThreadBundle &thread_bundle) { - std::vector<Runnable*> refs; - refs.reserve(chunks.size()); - for (const auto &task: chunks) { - refs.push_back(task.get()); - } - thread_bundle.run(refs); - } -}; - } // unnamed FeatureSet::UP @@ -161,24 +145,26 @@ ExtractFeatures::get_match_features(const MatchToolsFactory &mtf, const OrderedD FeatureResolver resolver(tools->rank_program().get_seeds(false)); result.names = extract_names(resolver, mtf.get_feature_rename_map()); result.values.resize(result.names.size() * docs.size()); - MyWork work(thread_bundle); - size_t per_thread = docs.size() / work.num_threads; - size_t rest_docs = docs.size() % work.num_threads; + size_t num_threads = thread_bundle.size(); + std::vector<Runnable::UP> chunks; + chunks.reserve(num_threads); + size_t per_thread = docs.size() / num_threads; + size_t rest_docs = docs.size() % num_threads; size_t idx = 0; - for (size_t i = 0; i < work.num_threads; ++i) { + for (size_t i = 0; i < num_threads; ++i) { size_t chunk_size = per_thread + (i < rest_docs); if (chunk_size == 0) { break; } if (i == 0) { - work.chunks.push_back(std::make_unique<FirstChunk>(&docs[idx], &docs[idx + chunk_size], result, tools->getDoom(), tools->search(), resolver)); + chunks.push_back(std::make_unique<FirstChunk>(&docs[idx], &docs[idx + chunk_size], result, tools->getDoom(), tools->search(), resolver)); } else { - work.chunks.push_back(std::make_unique<LaterChunk>(&docs[idx], &docs[idx + chunk_size], result, tools->getDoom(), mtf)); + chunks.push_back(std::make_unique<LaterChunk>(&docs[idx], &docs[idx + chunk_size], result, tools->getDoom(), mtf)); } idx += chunk_size; } assert(idx == docs.size()); - work.run(thread_bundle); + thread_bundle.run(chunks); return result; } diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_master.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_master.cpp index eefb8411df2..063666e9cad 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_master.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/match_master.cpp @@ -103,7 +103,6 @@ MatchMaster::match(search::engine::Trace & trace, DocidRangeScheduler::UP scheduler = createScheduler(threadBundle.size(), numSearchPartitions, params.numDocs); std::vector<MatchThread::UP> threadState; - std::vector<vespalib::Runnable*> targets; for (size_t i = 0; i < threadBundle.size(); ++i) { IMatchLoopCommunicator &com = (i == 0) ? static_cast<IMatchLoopCommunicator&>(timedCommunicator) @@ -111,10 +110,9 @@ MatchMaster::match(search::engine::Trace & trace, threadState.emplace_back(std::make_unique<MatchThread>(i, threadBundle.size(), params, mtf, com, *scheduler, resultProcessor, mergeDirector, distributionKey, trace.getRelativeTime(), trace.getLevel(), trace.getProfileDepth())); - targets.push_back(threadState.back().get()); } resultProcessor.prepareThreadContextCreation(threadBundle.size()); - threadBundle.run(targets); + threadBundle.run(threadState); auto reply = make_reply(mtf, resultProcessor, threadBundle, threadState[0]->extract_result()); double query_time_s = vespalib::to_s(query_latency_time.elapsed()); double rerank_time_s = vespalib::to_s(timedCommunicator.elapsed); diff --git a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp index 95fe6fd6c3e..b612f4cd061 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp @@ -75,8 +75,8 @@ public: { } private: size_t size() const override { return _maxThreads; } - void run(const std::vector<vespalib::Runnable*> &targets) override { - _threadBundle.run(targets); + void run(vespalib::Runnable* const* targets, size_t cnt) override { + _threadBundle.run(targets, cnt); } vespalib::ThreadBundle &_threadBundle; const uint32_t _maxThreads; |