Skip to content

search: improve performance of AND-operator evaluation

Administrator requested to merge sh/11281/improve_evaluateAnd into main

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 initial tryCount from 5000 to 100.
  • adapting tryCount based on the number of operands
  • setting an overall timeout

Bugs fixed:

  • previously tryCount was increased to tryCount*tryCount if len(results)<5, which immediately exceeded maxTryCount and thus we effectively never ran a second iteration of queries. Now we double tryCount 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.

Merge request reports

Loading