search: improve performance of AND-operator evaluation
Created by: stefanhengl
Relates to #11281
This PR improves the performance of AND-operator evaluation by
- lowering
tryCount
(i.e. the value of count:) for cases with few AND-operands: For 2 operands, we reduce the initialtryCount
from 5000 to 100. - adapting
tryCount
based on the number of operands - setting an overall timeout
Bugs fixed:
- previously
tryCount
was increased totryCount*tryCount
iflen(results)<5
, which immediately exceeded maxTryCount and thus we effectively never ran a second iteration of queries. Now we doubletryCount
with each iteration.
Alternatives considered:
- I first implemented a variant where the scope was narrowed with each term we evaluate. However, it turned out that iterating over repos (or repos and files, or repos and batches of files, or batches of repos) caused a significant overhead without obvious improvements in performance. The changes in this PR can be considered orthogonal. Before optimizing further we should add traces and benchmarks for
evaluateAnd
to reliably quantify improvements.