diff options
author | Tor Egge <Tor.Egge@online.no> | 2024-06-04 13:13:59 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2024-06-04 13:13:59 +0200 |
commit | cad0d92c69f82eadd855818b17ddb854808cb6fe (patch) | |
tree | 4be753f2d373fa97abea9a1a10b962f666de8cd0 /searchcore | |
parent | 6ef5c172d1ab4ff880f0ae7daca5bc5f23f43fa1 (diff) |
Rename existing rank drop limit and rank score drop limit to
first phase rank score drop limit.
Stop using std::isnan to mark no value.
Diffstat (limited to 'searchcore')
6 files changed, 27 insertions, 33 deletions
diff --git a/searchcore/src/tests/proton/matching/matching_test.cpp b/searchcore/src/tests/proton/matching/matching_test.cpp index 4d74a42a3bc..e3bb5d519c6 100644 --- a/searchcore/src/tests/proton/matching/matching_test.cpp +++ b/searchcore/src/tests/proton/matching/matching_test.cpp @@ -962,22 +962,20 @@ TEST(MatchingTest, require_that_match_params_are_set_up_straight_with_ranking_on ASSERT_EQ(10u, p.numDocs); ASSERT_EQ(2u, p.heapSize); ASSERT_EQ(4u, p.arraySize); - ASSERT_EQ(0.7, p.rankDropLimit); + ASSERT_EQ(0.7, p.first_phase_rank_score_drop_limit.value()); ASSERT_EQ(0u, p.offset); ASSERT_EQ(1u, p.hits); - ASSERT_TRUE(p.has_rank_drop_limit()); } TEST(MatchingTest, require_that_match_params_can_turn_off_rank_drop_limit) { - MatchParams p(10, 2, 4, -std::numeric_limits<feature_t>::quiet_NaN(), 0, 1, true, true); + MatchParams p(10, 2, 4, std::nullopt, 0, 1, true, true); ASSERT_EQ(10u, p.numDocs); ASSERT_EQ(2u, p.heapSize); ASSERT_EQ(4u, p.arraySize); - ASSERT_TRUE(std::isnan(p.rankDropLimit)); + ASSERT_FALSE(p.first_phase_rank_score_drop_limit.has_value()); ASSERT_EQ(0u, p.offset); ASSERT_EQ(1u, p.hits); - ASSERT_FALSE(p.has_rank_drop_limit()); } @@ -987,7 +985,7 @@ TEST(MatchingTest, require_that_match_params_are_set_up_straight_with_ranking_on ASSERT_EQ(10u, p.numDocs); ASSERT_EQ(6u, p.heapSize); ASSERT_EQ(6u, p.arraySize); - ASSERT_EQ(0.7, p.rankDropLimit); + ASSERT_EQ(0.7, p.first_phase_rank_score_drop_limit.value()); ASSERT_EQ(1u, p.offset); ASSERT_EQ(1u, p.hits); } @@ -998,7 +996,7 @@ TEST(MatchingTest, require_that_match_params_are_set_up_straight_with_ranking_on ASSERT_EQ(10u, p.numDocs); ASSERT_EQ(6u, p.heapSize); ASSERT_EQ(8u, p.arraySize); - ASSERT_EQ(0.7, p.rankDropLimit); + ASSERT_EQ(0.7, p.first_phase_rank_score_drop_limit.value()); ASSERT_EQ(4u, p.offset); ASSERT_EQ(4u, p.hits); } @@ -1009,7 +1007,7 @@ TEST(MatchingTest, require_that_match_params_are_capped_by_numDocs) ASSERT_EQ(1u, p.numDocs); ASSERT_EQ(1u, p.heapSize); ASSERT_EQ(1u, p.arraySize); - ASSERT_EQ(0.7, p.rankDropLimit); + ASSERT_EQ(0.7, p.first_phase_rank_score_drop_limit.value()); ASSERT_EQ(1u, p.offset); ASSERT_EQ(0u, p.hits); } @@ -1020,7 +1018,7 @@ TEST(MatchingTest, require_that_match_params_are_capped_by_numDocs_and_hits_adju ASSERT_EQ(5u, p.numDocs); ASSERT_EQ(5u, p.heapSize); ASSERT_EQ(5u, p.arraySize); - ASSERT_EQ(0.7, p.rankDropLimit); + ASSERT_EQ(0.7, p.first_phase_rank_score_drop_limit.value()); ASSERT_EQ(4u, p.offset); ASSERT_EQ(1u, p.hits); } @@ -1031,7 +1029,7 @@ TEST(MatchingTest, require_that_match_params_are_set_up_straight_with_ranking_of ASSERT_EQ(10u, p.numDocs); ASSERT_EQ(0u, p.heapSize); ASSERT_EQ(0u, p.arraySize); - ASSERT_EQ(0.7, p.rankDropLimit); + ASSERT_EQ(0.7, p.first_phase_rank_score_drop_limit.value()); ASSERT_EQ(4u, p.offset); ASSERT_EQ(4u, p.hits); } diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_params.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_params.cpp index 5cd97d314b5..2e3d7c77926 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_params.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/match_params.cpp @@ -19,7 +19,7 @@ computeArraySize(uint32_t hitsPlussOffset, uint32_t heapSize, uint32_t arraySize MatchParams::MatchParams(uint32_t numDocs_in, uint32_t heapSize_in, uint32_t arraySize_in, - search::feature_t rankDropLimit_in, + std::optional<search::feature_t> first_phase_rank_score_drop_limit_in, uint32_t offset_in, uint32_t hits_in, bool hasFinalRank, @@ -31,12 +31,7 @@ MatchParams::MatchParams(uint32_t numDocs_in, : 0), offset(std::min(numDocs_in, offset_in)), hits(std::min(numDocs_in - offset, hits_in)), - rankDropLimit(rankDropLimit_in) + first_phase_rank_score_drop_limit(first_phase_rank_score_drop_limit_in) { } -bool -MatchParams::has_rank_drop_limit() const { - return ! std::isnan(rankDropLimit); -} - } diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_params.h b/searchcore/src/vespa/searchcore/proton/matching/match_params.h index 96ff892525f..a487b9f13f0 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_params.h +++ b/searchcore/src/vespa/searchcore/proton/matching/match_params.h @@ -4,6 +4,7 @@ #include <vespa/searchlib/common/feature.h> #include <cstdint> +#include <optional> namespace proton::matching { @@ -17,18 +18,17 @@ struct MatchParams { const uint32_t arraySize; const uint32_t offset; const uint32_t hits; - const search::feature_t rankDropLimit; + const std::optional<search::feature_t> first_phase_rank_score_drop_limit; MatchParams(uint32_t numDocs_in, uint32_t heapSize_in, uint32_t arraySize_in, - search::feature_t rankDropLimit_in, + std::optional<search::feature_t> first_phase_rank_drop_limit_in, uint32_t offset_in, uint32_t hits_in, bool hasFinalRank, bool needRanking); bool save_rank_scores() const noexcept { return (arraySize != 0); } - bool has_rank_drop_limit() const; }; } diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp index 6b443231c0a..81a4b443208 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp @@ -15,6 +15,7 @@ #include <vespa/searchlib/queryeval/profiled_iterator.h> #include <vespa/vespalib/data/slime/cursor.h> #include <vespa/vespalib/data/slime/inserter.h> +#include <limits> #include <vespa/log/log.h> LOG_SETUP(".proton.matching.match_thread"); @@ -99,11 +100,11 @@ fillPartialResult(ResultProcessor::Context & context, size_t totalHits, size_t n //----------------------------------------------------------------------------- -MatchThread::Context::Context(double rankDropLimit, MatchTools &tools, HitCollector &hits, uint32_t num_threads) +MatchThread::Context::Context(std::optional<double> first_phase_rank_score_drop_limit, MatchTools &tools, HitCollector &hits, uint32_t num_threads) : matches(0), _matches_limit(tools.match_limiter().sample_hits_per_thread(num_threads)), _score_feature(get_score_feature(tools.rank_program())), - _rankDropLimit(rankDropLimit), + _first_phase_rank_score_drop_limit(first_phase_rank_score_drop_limit.value_or(0.0 /* ignored */)), _hits(hits), _doom(tools.getDoom()), dropped() @@ -119,7 +120,7 @@ MatchThread::Context::rankHit(uint32_t docId) { score = -HUGE_VAL; } if (use_rank_drop_limit != RankDropLimitE::no) { - if (__builtin_expect(score > _rankDropLimit, true)) { + if (__builtin_expect(score > _first_phase_rank_score_drop_limit, true)) { _hits.addHit(docId, score); } else if (use_rank_drop_limit == RankDropLimitE::track) { dropped.template emplace_back(docId); @@ -217,7 +218,7 @@ MatchThread::match_loop(MatchTools &tools, HitCollector &hits) bool softDoomed = false; uint32_t docsCovered = 0; vespalib::duration overtime(vespalib::duration::zero()); - Context context(matchParams.rankDropLimit, tools, hits, num_threads); + Context context(matchParams.first_phase_rank_score_drop_limit, tools, hits, num_threads); for (DocidRange docid_range = scheduler.first_range(thread_id); !docid_range.empty(); docid_range = scheduler.next_range(thread_id)) @@ -270,7 +271,7 @@ template <bool do_rank, bool do_limit, bool do_share> void MatchThread::match_loop_helper_rank_limit_share(MatchTools &tools, HitCollector &hits) { - if (matchParams.has_rank_drop_limit()) { + if (matchParams.first_phase_rank_score_drop_limit.has_value()) { if (matchToolsFactory.hasOnMatchTask()) { match_loop_helper_rank_limit_share_drop<do_rank, do_limit, do_share, RankDropLimitE::track>(tools, hits); } else { diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_thread.h b/searchcore/src/vespa/searchcore/proton/matching/match_thread.h index c6b233f2fcd..b267e7b799c 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_thread.h +++ b/searchcore/src/vespa/searchcore/proton/matching/match_thread.h @@ -73,7 +73,7 @@ private: class Context { public: - Context(double rankDropLimit, MatchTools &tools, HitCollector &hits, + Context(std::optional<double> first_phase_rank_score_drop_limit, MatchTools &tools, HitCollector &hits, uint32_t num_threads) __attribute__((noinline)); template <RankDropLimitE use_rank_drop_limit> void rankHit(uint32_t docId); @@ -86,7 +86,7 @@ private: private: uint32_t _matches_limit; LazyValue _score_feature; - double _rankDropLimit; + double _first_phase_rank_score_drop_limit; HitCollector &_hits; const Doom _doom; public: diff --git a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp index 4a9156770f0..52ec4bbedd7 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp @@ -38,7 +38,7 @@ using search::fef::MatchData; using search::fef::RankSetup; using search::fef::indexproperties::hitcollector::HeapSize; using search::fef::indexproperties::hitcollector::ArraySize; -using search::fef::indexproperties::hitcollector::RankScoreDropLimit; +using search::fef::indexproperties::hitcollector::FirstPhaseRankScoreDropLimit; using search::queryeval::Blueprint; using search::queryeval::SearchIterator; using vespalib::Doom; @@ -94,12 +94,12 @@ private: bool willNeedRanking(const SearchRequest & request, const GroupingContext & groupingContext, - search::feature_t rank_score_drop_limit) + std::optional<search::feature_t> first_phase_rank_score_drop_limit) { return (groupingContext.needRanking() || (request.maxhits != 0)) && (request.sortSpec.empty() || (request.sortSpec.find("[rank]") != vespalib::string::npos) || - !std::isnan(rank_score_drop_limit)); + first_phase_rank_score_drop_limit.has_value()); } SearchReply::UP @@ -289,11 +289,11 @@ Matcher::match(const SearchRequest &request, vespalib::ThreadBundle &threadBundl const Properties & rankProperties = request.propertiesMap.rankProperties(); uint32_t heapSize = HeapSize::lookup(rankProperties, _rankSetup->getHeapSize()); uint32_t arraySize = ArraySize::lookup(rankProperties, _rankSetup->getArraySize()); - search::feature_t rank_score_drop_limit = RankScoreDropLimit::lookup(rankProperties, _rankSetup->getRankScoreDropLimit()); + auto first_phase_rank_score_drop_limit = FirstPhaseRankScoreDropLimit::lookup(rankProperties, _rankSetup->get_first_phase_rank_score_drop_limit()); - MatchParams params(searchContext.getDocIdLimit(), heapSize, arraySize, rank_score_drop_limit, + MatchParams params(searchContext.getDocIdLimit(), heapSize, arraySize, first_phase_rank_score_drop_limit, request.offset, request.maxhits, !_rankSetup->getSecondPhaseRank().empty(), - willNeedRanking(request, groupingContext, rank_score_drop_limit)); + willNeedRanking(request, groupingContext, first_phase_rank_score_drop_limit)); ResultProcessor rp(attrContext, metaStore, sessionMgr, groupingContext, sessionId, request.sortSpec, params.offset, params.hits); |