@@ -1780,6 +1780,7 @@ def __init__(
17801780 self .queries = queries
17811781 self .app = app
17821782 self .verify_target_hits = verify_target_hits
1783+ self .searchable_copies = None
17831784
17841785 def run (self ):
17851786 """
@@ -1834,6 +1835,16 @@ def extract_from_trace(obj: dict, type_name: str):
18341835 and blueprint ["global_filter" ]["calculated" ]
18351836 ):
18361837 hit_ratios .append (blueprint ["global_filter" ]["hit_ratio" ])
1838+ actual_upper_limit = blueprint ["global_filter" ]["upper_limit" ]
1839+ if actual_upper_limit is not None and actual_upper_limit > 0.0 :
1840+ searchable_copies = round (1.0 / actual_upper_limit )
1841+ if self .searchable_copies is None :
1842+ self .searchable_copies = searchable_copies
1843+ else :
1844+ if self .searchable_copies != searchable_copies :
1845+ print (
1846+ f"Searchable copies mismatch: { searchable_copies } vs. { self .searchable_copies } found earlier"
1847+ )
18371848
18381849 if (
18391850 self .verify_target_hits is not None
@@ -1847,6 +1858,16 @@ def extract_from_trace(obj: dict, type_name: str):
18471858
18481859 return all_hit_ratios
18491860
1861+ """
1862+ Returns number of searchable copies determined during hit-ratio computation.
1863+
1864+ Returns:
1865+ int: Number of searchable copies used by Vespa application.
1866+ """
1867+
1868+ def get_searchable_copies (self ):
1869+ return self .searchable_copies
1870+
18501871
18511872class VespaNNRecallEvaluator :
18521873 """
@@ -2151,6 +2172,8 @@ def __init__(
21512172 self .recall_query_limit = recall_query_limit
21522173 self .max_concurrent = max_concurrent
21532174
2175+ self .searchable_copies = None
2176+
21542177 def get_bucket_interval_width (self ) -> float :
21552178 """
21562179 Gets the width of the interval represented by a single bucket.
@@ -2299,6 +2322,7 @@ def determine_hit_ratios_and_distribute_to_buckets(
22992322 queries , self .app , verify_target_hits = self .hits
23002323 )
23012324 hitratio_list = hitratio_evaluator .run ()
2325+ self .searchable_copies = hitratio_evaluator .get_searchable_copies ()
23022326
23032327 for i in range (0 , len (hitratio_list )):
23042328 hitratios = hitratio_list [i ]
@@ -2848,7 +2872,12 @@ def _suggest_post_filter_threshold(
28482872 threshold = i
28492873 response_time_gain = current_gain
28502874
2851- return self .bucket_to_hitratio (threshold )
2875+ suggestion = self .bucket_to_hitratio (threshold )
2876+ if self .searchable_copies is not None :
2877+ suggestion = suggestion * self .searchable_copies
2878+ suggestion = min (suggestion , 1.0 )
2879+
2880+ return suggestion
28522881
28532882 def _test_filter_first_exploration (
28542883 self , filter_first_exploration : float
0 commit comments