Based on following flamegraph next area that may give high boost is a lookup of sub-query index by the query. That is needed to get index of sub-query and store score of that sub-query for one document (code ref).
Most time (~28%) is taken by store and lookup of the index based on query as a key. Depending on the exact sub-query calculation of its hash code can be slow (hybrid query works with any type of OpenSearch query). That is a problem on large datasets as this is done for each doc by each sub-query.
[X] Commits are signed as per the DCO using --signoff
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.
In this PR we're continue to improve latency of hybrid query as part of meta issue https://github.com/opensearch-project/neural-search/issues/705.
Based on following flamegraph next area that may give high boost is a lookup of sub-query index by the query. That is needed to get index of sub-query and store score of that sub-query for one document (code ref).
Most time (~28%) is taken by store and lookup of the index based on query as a key. Depending on the exact sub-query calculation of its hash code can be slow (hybrid query works with any type of OpenSearch query). That is a problem on large datasets as this is done for each doc by each sub-query.
We can avoid creation and usage of that query to index map by storing sub-query index at time we create collection of DISIWrapers.
As per benchmark results that gives about 20% performance boost. I've run it on 2.13 using noaa OSB workload, all times are in ms:
Before the change (baseline)
After the change:
Issues Resolved
https://github.com/opensearch-project/neural-search/issues/705
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. For more information on following Developer Certificate of Origin and signing off your commits, please check here.