From d1c7e0cdb8a3d7a9d26897445822aa51feb1358c Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Wed, 5 Jun 2024 11:00:44 +0200 Subject: Add second phase rank score drop limit to proton::matching::MatchParams. --- .../src/tests/proton/matching/matching_test.cpp | 19 +++++++++++-------- .../vespa/searchcore/proton/matching/match_params.cpp | 4 +++- .../vespa/searchcore/proton/matching/match_params.h | 2 ++ .../src/vespa/searchcore/proton/matching/matcher.cpp | 3 +++ 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/searchcore/src/tests/proton/matching/matching_test.cpp b/searchcore/src/tests/proton/matching/matching_test.cpp index e3bb5d519c6..539843ae164 100644 --- a/searchcore/src/tests/proton/matching/matching_test.cpp +++ b/searchcore/src/tests/proton/matching/matching_test.cpp @@ -958,22 +958,24 @@ TEST(MatchingTest, require_that_getSummaryFeatures_prefers_cached_query_setup) TEST(MatchingTest, require_that_match_params_are_set_up_straight_with_ranking_on) { - MatchParams p(10, 2, 4, 0.7, 0, 1, true, true); + MatchParams p(10, 2, 4, 0.7, 0.75, 0, 1, true, true); ASSERT_EQ(10u, p.numDocs); ASSERT_EQ(2u, p.heapSize); ASSERT_EQ(4u, p.arraySize); ASSERT_EQ(0.7, p.first_phase_rank_score_drop_limit.value()); + ASSERT_EQ(0.75, p.second_phase_rank_score_drop_limit.value()); ASSERT_EQ(0u, p.offset); ASSERT_EQ(1u, p.hits); } -TEST(MatchingTest, require_that_match_params_can_turn_off_rank_drop_limit) +TEST(MatchingTest, require_that_match_params_can_turn_off_rank_score_drop_limits) { - MatchParams p(10, 2, 4, std::nullopt, 0, 1, true, true); + MatchParams p(10, 2, 4, std::nullopt, std::nullopt, 0, 1, true, true); ASSERT_EQ(10u, p.numDocs); ASSERT_EQ(2u, p.heapSize); ASSERT_EQ(4u, p.arraySize); ASSERT_FALSE(p.first_phase_rank_score_drop_limit.has_value()); + ASSERT_FALSE(p.second_phase_rank_score_drop_limit.has_value()); ASSERT_EQ(0u, p.offset); ASSERT_EQ(1u, p.hits); } @@ -981,18 +983,19 @@ TEST(MatchingTest, require_that_match_params_can_turn_off_rank_drop_limit) TEST(MatchingTest, require_that_match_params_are_set_up_straight_with_ranking_on_arraySize_is_atleast_the_size_of_heapSize) { - MatchParams p(10, 6, 4, 0.7, 1, 1, true, true); + MatchParams p(10, 6, 4, 0.7, std::nullopt, 1, 1, true, true); ASSERT_EQ(10u, p.numDocs); ASSERT_EQ(6u, p.heapSize); ASSERT_EQ(6u, p.arraySize); ASSERT_EQ(0.7, p.first_phase_rank_score_drop_limit.value()); + ASSERT_FALSE(p.second_phase_rank_score_drop_limit.has_value()); ASSERT_EQ(1u, p.offset); ASSERT_EQ(1u, p.hits); } TEST(MatchingTest, require_that_match_params_are_set_up_straight_with_ranking_on_arraySize_is_atleast_the_size_of_hits_plus_offset) { - MatchParams p(10, 6, 4, 0.7, 4, 4, true, true); + MatchParams p(10, 6, 4, 0.7, std::nullopt, 4, 4, true, true); ASSERT_EQ(10u, p.numDocs); ASSERT_EQ(6u, p.heapSize); ASSERT_EQ(8u, p.arraySize); @@ -1003,7 +1006,7 @@ TEST(MatchingTest, require_that_match_params_are_set_up_straight_with_ranking_on TEST(MatchingTest, require_that_match_params_are_capped_by_numDocs) { - MatchParams p(1, 6, 4, 0.7, 4, 4, true, true); + MatchParams p(1, 6, 4, 0.7, std::nullopt, 4, 4, true, true); ASSERT_EQ(1u, p.numDocs); ASSERT_EQ(1u, p.heapSize); ASSERT_EQ(1u, p.arraySize); @@ -1014,7 +1017,7 @@ TEST(MatchingTest, require_that_match_params_are_capped_by_numDocs) TEST(MatchingTest, require_that_match_params_are_capped_by_numDocs_and_hits_adjusted_down) { - MatchParams p(5, 6, 4, 0.7, 4, 4, true, true); + MatchParams p(5, 6, 4, 0.7, std::nullopt, 4, 4, true, true); ASSERT_EQ(5u, p.numDocs); ASSERT_EQ(5u, p.heapSize); ASSERT_EQ(5u, p.arraySize); @@ -1025,7 +1028,7 @@ TEST(MatchingTest, require_that_match_params_are_capped_by_numDocs_and_hits_adju TEST(MatchingTest, require_that_match_params_are_set_up_straight_with_ranking_off_array_and_heap_size_is_0) { - MatchParams p(10, 6, 4, 0.7, 4, 4, true, false); + MatchParams p(10, 6, 4, 0.7, std::nullopt, 4, 4, true, false); ASSERT_EQ(10u, p.numDocs); ASSERT_EQ(0u, p.heapSize); ASSERT_EQ(0u, p.arraySize); diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_params.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_params.cpp index 2e3d7c77926..316ef003a28 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_params.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/match_params.cpp @@ -20,6 +20,7 @@ MatchParams::MatchParams(uint32_t numDocs_in, uint32_t heapSize_in, uint32_t arraySize_in, std::optional first_phase_rank_score_drop_limit_in, + std::optional second_phase_rank_score_drop_limit_in, uint32_t offset_in, uint32_t hits_in, bool hasFinalRank, @@ -31,7 +32,8 @@ MatchParams::MatchParams(uint32_t numDocs_in, : 0), offset(std::min(numDocs_in, offset_in)), hits(std::min(numDocs_in - offset, hits_in)), - first_phase_rank_score_drop_limit(first_phase_rank_score_drop_limit_in) + first_phase_rank_score_drop_limit(first_phase_rank_score_drop_limit_in), + second_phase_rank_score_drop_limit(second_phase_rank_score_drop_limit_in) { } } diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_params.h b/searchcore/src/vespa/searchcore/proton/matching/match_params.h index a487b9f13f0..19abcd8e449 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_params.h +++ b/searchcore/src/vespa/searchcore/proton/matching/match_params.h @@ -19,11 +19,13 @@ struct MatchParams { const uint32_t offset; const uint32_t hits; const std::optional first_phase_rank_score_drop_limit; + const std::optional second_phase_rank_score_drop_limit; MatchParams(uint32_t numDocs_in, uint32_t heapSize_in, uint32_t arraySize_in, std::optional first_phase_rank_drop_limit_in, + std::optional second_phase_rank_score_drop_limit_in, uint32_t offset_in, uint32_t hits_in, bool hasFinalRank, diff --git a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp index 52ec4bbedd7..e0897e0378d 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp @@ -39,6 +39,7 @@ using search::fef::RankSetup; using search::fef::indexproperties::hitcollector::HeapSize; using search::fef::indexproperties::hitcollector::ArraySize; using search::fef::indexproperties::hitcollector::FirstPhaseRankScoreDropLimit; +using search::fef::indexproperties::hitcollector::SecondPhaseRankScoreDropLimit; using search::queryeval::Blueprint; using search::queryeval::SearchIterator; using vespalib::Doom; @@ -290,8 +291,10 @@ Matcher::match(const SearchRequest &request, vespalib::ThreadBundle &threadBundl uint32_t heapSize = HeapSize::lookup(rankProperties, _rankSetup->getHeapSize()); uint32_t arraySize = ArraySize::lookup(rankProperties, _rankSetup->getArraySize()); auto first_phase_rank_score_drop_limit = FirstPhaseRankScoreDropLimit::lookup(rankProperties, _rankSetup->get_first_phase_rank_score_drop_limit()); + auto second_phase_rank_score_drop_limit = SecondPhaseRankScoreDropLimit::lookup(rankProperties, _rankSetup->get_second_phase_rank_score_drop_limit()); MatchParams params(searchContext.getDocIdLimit(), heapSize, arraySize, first_phase_rank_score_drop_limit, + second_phase_rank_score_drop_limit, request.offset, request.maxhits, !_rankSetup->getSecondPhaseRank().empty(), willNeedRanking(request, groupingContext, first_phase_rank_score_drop_limit)); -- cgit v1.2.3