-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Improve performance of encoding composite keys in multi-term aggregations #9412
Improve performance of encoding composite keys in multi-term aggregations #9412
Conversation
…ions Signed-off-by: Ketan Verma <[email protected]>
Compatibility status:Checks if related components are compatible with change e1c40b4 Incompatible componentsIncompatible components: [https://github.com/opensearch-project/index-management.git, https://github.com/opensearch-project/asynchronous-search.git, https://github.com/opensearch-project/security-analytics.git] Skipped componentsCompatible componentsCompatible components: [https://github.com/opensearch-project/security.git, https://github.com/opensearch-project/alerting.git, https://github.com/opensearch-project/anomaly-detection.git, https://github.com/opensearch-project/sql.git, https://github.com/opensearch-project/job-scheduler.git, https://github.com/opensearch-project/common-utils.git, https://github.com/opensearch-project/observability.git, https://github.com/opensearch-project/k-nn.git, https://github.com/opensearch-project/reporting.git, https://github.com/opensearch-project/cross-cluster-replication.git, https://github.com/opensearch-project/geospatial.git, https://github.com/opensearch-project/notifications.git, https://github.com/opensearch-project/performance-analyzer.git, https://github.com/opensearch-project/neural-search.git, https://github.com/opensearch-project/ml-commons.git, https://github.com/opensearch-project/performance-analyzer-rca.git, https://github.com/opensearch-project/opensearch-oci-object-storage.git] |
Gradle Check (Jenkins) Run Completed with:
|
Codecov Report
@@ Coverage Diff @@
## main #9412 +/- ##
============================================
- Coverage 71.12% 71.08% -0.04%
Complexity 57417 57417
============================================
Files 4776 4776
Lines 270742 270759 +17
Branches 39578 39577 -1
============================================
- Hits 192558 192478 -80
- Misses 62044 62120 +76
- Partials 16140 16161 +21
|
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.
Big heart here for this change! Nice clean up not having to deal with all of this introspection.
I left one minor nitpick purely out of preference but I won't block the PR for it.
Thx for this clean change!
libs/core/src/main/java/org/opensearch/core/common/io/stream/StreamOutput.java
Outdated
Show resolved
Hide resolved
…Class Signed-off-by: Ketan Verma <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
libs/core/src/main/java/org/opensearch/core/common/io/stream/StreamOutput.java
Outdated
Show resolved
Hide resolved
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.
Nice improvement 🥇
Looks good to me. Thanks @ketanv3
server/src/main/java/org/opensearch/search/aggregations/bucket/terms/MultiTermsAggregator.java
Show resolved
Hide resolved
…move unused code Signed-off-by: Ketan Verma <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
Compatibility status:Checks if related components are compatible with change 6a5b464 Incompatible componentsIncompatible components: [https://github.com/opensearch-project/index-management.git, https://github.com/opensearch-project/security-analytics.git, https://github.com/opensearch-project/asynchronous-search.git] Skipped componentsCompatible componentsCompatible components: [https://github.com/opensearch-project/geospatial.git, https://github.com/opensearch-project/security.git, https://github.com/opensearch-project/notifications.git, https://github.com/opensearch-project/neural-search.git, https://github.com/opensearch-project/sql.git, https://github.com/opensearch-project/job-scheduler.git, https://github.com/opensearch-project/opensearch-oci-object-storage.git, https://github.com/opensearch-project/observability.git, https://github.com/opensearch-project/k-nn.git, https://github.com/opensearch-project/alerting.git, https://github.com/opensearch-project/cross-cluster-replication.git, https://github.com/opensearch-project/anomaly-detection.git, https://github.com/opensearch-project/performance-analyzer.git, https://github.com/opensearch-project/common-utils.git, https://github.com/opensearch-project/ml-commons.git, https://github.com/opensearch-project/performance-analyzer-rca.git, https://github.com/opensearch-project/reporting.git] |
…ions (#9412) * Improve performance of encoding composite keys in multi-term aggregations Signed-off-by: Ketan Verma <[email protected]> * Rename StreamOutput::getGenericValueWriter to getGenericValueWriterByClass Signed-off-by: Ketan Verma <[email protected]> * Rename StreamOutput::getGenericValueWriterByClass to getWriter and remove unused code Signed-off-by: Ketan Verma <[email protected]> --------- Signed-off-by: Ketan Verma <[email protected]> (cherry picked from commit 46f2bd0) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…ions (#9412) (#9434) * Improve performance of encoding composite keys in multi-term aggregations * Rename StreamOutput::getGenericValueWriter to getGenericValueWriterByClass * Rename StreamOutput::getGenericValueWriterByClass to getWriter and remove unused code --------- (cherry picked from commit 46f2bd0) Signed-off-by: Ketan Verma <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…ions (opensearch-project#9412) * Improve performance of encoding composite keys in multi-term aggregations Signed-off-by: Ketan Verma <[email protected]> * Rename StreamOutput::getGenericValueWriter to getGenericValueWriterByClass Signed-off-by: Ketan Verma <[email protected]> * Rename StreamOutput::getGenericValueWriterByClass to getWriter and remove unused code Signed-off-by: Ketan Verma <[email protected]> --------- Signed-off-by: Ketan Verma <[email protected]>
…ions (opensearch-project#9412) * Improve performance of encoding composite keys in multi-term aggregations Signed-off-by: Ketan Verma <[email protected]> * Rename StreamOutput::getGenericValueWriter to getGenericValueWriterByClass Signed-off-by: Ketan Verma <[email protected]> * Rename StreamOutput::getGenericValueWriterByClass to getWriter and remove unused code Signed-off-by: Ketan Verma <[email protected]> --------- Signed-off-by: Ketan Verma <[email protected]>
…ions (opensearch-project#9412) * Improve performance of encoding composite keys in multi-term aggregations Signed-off-by: Ketan Verma <[email protected]> * Rename StreamOutput::getGenericValueWriter to getGenericValueWriterByClass Signed-off-by: Ketan Verma <[email protected]> * Rename StreamOutput::getGenericValueWriterByClass to getWriter and remove unused code Signed-off-by: Ketan Verma <[email protected]> --------- Signed-off-by: Ketan Verma <[email protected]>
…ions (opensearch-project#9412) * Improve performance of encoding composite keys in multi-term aggregations Signed-off-by: Ketan Verma <[email protected]> * Rename StreamOutput::getGenericValueWriter to getGenericValueWriterByClass Signed-off-by: Ketan Verma <[email protected]> * Rename StreamOutput::getGenericValueWriterByClass to getWriter and remove unused code Signed-off-by: Ketan Verma <[email protected]> --------- Signed-off-by: Ketan Verma <[email protected]> Signed-off-by: Gagan Juneja <[email protected]>
…ions (opensearch-project#9412) * Improve performance of encoding composite keys in multi-term aggregations Signed-off-by: Ketan Verma <[email protected]> * Rename StreamOutput::getGenericValueWriter to getGenericValueWriterByClass Signed-off-by: Ketan Verma <[email protected]> * Rename StreamOutput::getGenericValueWriterByClass to getWriter and remove unused code Signed-off-by: Ketan Verma <[email protected]> --------- Signed-off-by: Ketan Verma <[email protected]> Signed-off-by: Gagan Juneja <[email protected]>
…ions (opensearch-project#9412) * Improve performance of encoding composite keys in multi-term aggregations Signed-off-by: Ketan Verma <[email protected]> * Rename StreamOutput::getGenericValueWriter to getGenericValueWriterByClass Signed-off-by: Ketan Verma <[email protected]> * Rename StreamOutput::getGenericValueWriterByClass to getWriter and remove unused code Signed-off-by: Ketan Verma <[email protected]> --------- Signed-off-by: Ketan Verma <[email protected]> Signed-off-by: Kiran Reddy <[email protected]>
…ions (opensearch-project#9412) * Improve performance of encoding composite keys in multi-term aggregations Signed-off-by: Ketan Verma <[email protected]> * Rename StreamOutput::getGenericValueWriter to getGenericValueWriterByClass Signed-off-by: Ketan Verma <[email protected]> * Rename StreamOutput::getGenericValueWriterByClass to getWriter and remove unused code Signed-off-by: Ketan Verma <[email protected]> --------- Signed-off-by: Ketan Verma <[email protected]> Signed-off-by: Kaushal Kumar <[email protected]>
…ions (opensearch-project#9412) * Improve performance of encoding composite keys in multi-term aggregations Signed-off-by: Ketan Verma <[email protected]> * Rename StreamOutput::getGenericValueWriter to getGenericValueWriterByClass Signed-off-by: Ketan Verma <[email protected]> * Rename StreamOutput::getGenericValueWriterByClass to getWriter and remove unused code Signed-off-by: Ketan Verma <[email protected]> --------- Signed-off-by: Ketan Verma <[email protected]> Signed-off-by: Ivan Brusic <[email protected]>
…ions (opensearch-project#9412) * Improve performance of encoding composite keys in multi-term aggregations Signed-off-by: Ketan Verma <[email protected]> * Rename StreamOutput::getGenericValueWriter to getGenericValueWriterByClass Signed-off-by: Ketan Verma <[email protected]> * Rename StreamOutput::getGenericValueWriterByClass to getWriter and remove unused code Signed-off-by: Ketan Verma <[email protected]> --------- Signed-off-by: Ketan Verma <[email protected]> Signed-off-by: Shivansh Arora <[email protected]>
Description
Composite keys of arbitrary Java objects are encoded using the StreamOutput::writeGenericValue method (here) which is expensive as it involves a series of "instanceof" checks and map lookups to identify the registered writer. This bottleneck adds up as the number of composite keys is proportional to the number of hits, number of multi-term fields, and the number of field values.
This PR improves the encoding performance by:
Improvement
Improvement is proportional to the number of hits, fields, and field values. The improvement is significant!
Related Issues
#8710
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.