diff options
author | Håvard Pettersen <havardpe@yahooinc.com> | 2022-06-23 13:50:22 +0000 |
---|---|---|
committer | Håvard Pettersen <havardpe@yahooinc.com> | 2022-06-23 13:50:22 +0000 |
commit | 87411bd1b703af1f67573bdbd224240a150d6873 (patch) | |
tree | eaaf4d773849ae12b8c852cf80ec886027f8e852 /searchcore | |
parent | 4b68b35aedc4c714a76b158dcd81a7db03a0b7a6 (diff) |
waste less time in second phase ranking
avoid setting up second phase ranking for threads with no hits to rank
in second phase.
call initRange with actual docid range when preparing to perform
second phase ranking. This should make sure that eager iterators find
the first hit immediately.
Diffstat (limited to 'searchcore')
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/matching/document_scorer.cpp | 4 | ||||
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp | 10 |
2 files changed, 9 insertions, 5 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matching/document_scorer.cpp b/searchcore/src/vespa/searchcore/proton/matching/document_scorer.cpp index 76c9781d7a5..e955b24cc7f 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/document_scorer.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/document_scorer.cpp @@ -34,8 +34,12 @@ DocumentScorer::DocumentScorer(RankProgram &rankProgram, void DocumentScorer::score(TaggedHits &hits) { + if (hits.empty()) { + return; + } auto sort_on_docid = [](const TaggedHit &a, const TaggedHit &b){ return (a.first.first < b.first.first); }; std::sort(hits.begin(), hits.end(), sort_on_docid); + _searchItr.initRange(hits.front().first.first, hits.back().first.first + 1); for (auto &hit: hits) { hit.first.second = doScore(hit.first.first); } diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp index f1243665636..102da1d71e4 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp @@ -276,9 +276,6 @@ MatchThread::findMatches(MatchTools &tools) match_loop_helper(tools, hits); if (tools.has_second_phase_rank()) { trace->addEvent(4, "Start second phase rerank"); - tools.setup_second_phase(); - DocidRange docid_range(1, matchParams.numDocs); - tools.search().initRange(docid_range.begin, docid_range.end); auto sorted_hit_seq = matchToolsFactory.should_diversify() ? hits.getSortedHitSequence(matchParams.arraySize) : hits.getSortedHitSequence(matchParams.heapSize); @@ -286,11 +283,14 @@ MatchThread::findMatches(MatchTools &tools) WaitTimer get_second_phase_work_timer(wait_time_s); auto my_work = communicator.get_second_phase_work(sorted_hit_seq, thread_id); get_second_phase_work_timer.done(); - DocumentScorer scorer(tools.rank_program(), tools.search()); if (tools.getDoom().hard_doom()) { my_work.clear(); } - scorer.score(my_work); + if (!my_work.empty()) { + tools.setup_second_phase(); + DocumentScorer scorer(tools.rank_program(), tools.search()); + scorer.score(my_work); + } thread_stats.docsReRanked(my_work.size()); trace->addEvent(5, "Synchronize before rank scaling"); WaitTimer complete_second_phase_timer(wait_time_s); |