[HTML search] optimization: don't loop over all document terms and title terms during search. #12045
Labels
javascript
Pull requests that update Javascript code
type:performance
type:proposal
a feature suggestion
Is your feature request related to a problem? Please describe.
There seems to be a potentially-large inefficiency in the Sphinx JavaScript search code: for any query word greater than length two (likely to be >90% of them, I'd guess!), we iterate through all document terms and all title terms in the client's search index to check for partial matches.
However, if an exact-match was already found on the query word, then we won't add any of those candidates, even when they do match. That means that we spend JavaScript compute resources iterating through items that are unused.
The relevant code is found here:
sphinx/sphinx/themes/basic/static/searchtools.js
Lines 469 to 476 in cf7d275
I don't have any stats on the performance impact of this, but it feels like it may be significant, especially for large documentation projects.
Describe the solution you'd like
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
The text was updated successfully, but these errors were encountered: