-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize innerhits query performance #16937
base: main
Are you sure you want to change the base?
Conversation
b79e7d9
to
a1c5a45
Compare
{"run-benchmark-test": "id_5"} |
I found that |
❌ Gradle check result for a1c5a45: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
a1c5a45
to
6b556c0
Compare
{"run-benchmark-test": "id_5"} |
The Jenkins job url is https://build.ci.opensearch.org/job/benchmark-pull-request/2018/ . Final results will be published once the job is completed. |
❌ Gradle check result for 58f9a01: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Benchmark ResultsBenchmark Results for Job: https://build.ci.opensearch.org/job/benchmark-pull-request/2018/
|
Benchmark Baseline Comparison ResultsBenchmark Results for Job: https://build.ci.opensearch.org/job/benchmark-compare/31/
|
@jed326, please have a look, it appears that performance benchmarks do not take |
@kkewwei It looks like there is a So you could either open a separate PR to add some nested workload to the benchmarking config, or you can try to run that benchmarking workload separately on your own stup. |
Let me schedule a baseline for this as well and add it to the config. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In principle, I think the change makes sense.
I think I remember seeing something similar in another Lucene-based project where child doc IDs were cached in a bitset to carry them from the query phase to a later step (though it might have been related to the Lucene facets module, rather than the fetch phase like here).
I guess my only concern is whether explicitly adding the nested doc IDs to the BitsetFilterCache
could lead to excessive memory consumption, since that class has the following JavaDoc:
* This is a cache for {@link BitDocIdSet} based filters and is unbounded by size or time.
* <p>
* Use this cache with care, only components that require that a filter is to be materialized as a {@link BitDocIdSet}
* and require that it should always be around should use this cache, otherwise the
* {@link org.opensearch.index.cache.query.QueryCache} should be used instead.
I could be mistaken, but I think things only get removed from BitsetFilterCache
when a segment gets merged away.
That said, it looks like this is only caching a nestedTypeFilter
, which is consistent with the parent filter (i.e. this filter depends on the mapping, which shouldn't change frequently, as opposed to depending on something in the query that could have higher cardinality). So, I think it's safe.
server/src/main/java/org/opensearch/index/mapper/DocumentMapper.java
Outdated
Show resolved
Hide resolved
{"run-benchmark-test": "id_16"} |
The Jenkins job url is https://build.ci.opensearch.org/job/benchmark-pull-request/2041/ . Final results will be published once the job is completed. |
Benchmark ResultsBenchmark Results for Job: https://build.ci.opensearch.org/job/benchmark-pull-request/2041/
|
Benchmark Baseline Comparison ResultsBenchmark Results for Job: https://build.ci.opensearch.org/job/benchmark-compare/32/
|
Signed-off-by: kkewwei <[email protected]> Signed-off-by: kkewwei <[email protected]>
58f9a01
to
b1d2f72
Compare
@msfroh, initially, I had this concern. However, upon further investigation, I discovered that the In my side, doc is more completed than the benchmark doc, the took will be greatly reduced 34%(836ms->551ms).
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16937 +/- ##
=========================================
Coverage 72.20% 72.21%
+ Complexity 65289 65276 -13
=========================================
Files 5299 5299
Lines 303536 303541 +5
Branches 43941 43942 +1
=========================================
+ Hits 219180 219200 +20
+ Misses 66441 66425 -16
- Partials 17915 17916 +1 ☔ View full report in Codecov by Sentry. |
@kkewwei Looking at the perf numbers from #16937 (comment) it seems the I'll re-trigger these benchmarks as well. |
{"run-benchmark-test": "id_16"} |
The Jenkins job url is https://build.ci.opensearch.org/job/benchmark-pull-request/2051/ . Final results will be published once the job is completed. |
Benchmark ResultsBenchmark Results for Job: https://build.ci.opensearch.org/job/benchmark-pull-request/2051/
|
Benchmark Baseline Comparison ResultsBenchmark Results for Job: https://build.ci.opensearch.org/job/benchmark-compare/33/
|
Description
During I experimentation with concurrent execution in the innerhit phase, I discovered another logic that requires optimization.
It is known that TermQuery is never cached in QueryCache, but innerhit phase extensively utilizes TermQuery, resulting in inefficient(https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/search/UsageTrackingQueryCachingPolicy.java#L57). The following improvements can be made:
can also help reduce redundant query executions. Similar usage can be seen in
NestedQueryBuilder
(https://github.com/opensearch-project/OpenSearch/blob/main/server/src/main/java/org/opensearch/index/query/NestedQueryBuilder.java#L410).Related Issues
Resolves #16878 (comment)
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.