-
Notifications
You must be signed in to change notification settings - Fork 2.3k
[Aggregations] Optimize singleton handling in GlobalOrdinalValuesSource #17740
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
[Aggregations] Optimize singleton handling in GlobalOrdinalValuesSource #17740
Conversation
❌ Gradle check result for 7a979ba: 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? |
{"run-benchmark-test": "id_4"} |
...main/java/org/opensearch/search/aggregations/bucket/composite/GlobalOrdinalValuesSource.java
Show resolved
Hide resolved
❌ Gradle check result for f715191: 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? |
f715191
to
8ec48cd
Compare
❌ Gradle check result for 8ec48cd: 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? |
Signed-off-by: shreyah963 <[email protected]>
Signed-off-by: shreyah963 <[email protected]>
Signed-off-by: shreyah963 <[email protected]>
…esSource and simplify the optimization logic in GlobalOrdinalValuesSource. The singleton optimization is now only applied when DocValues.unwrapSingleton() succeeds, preventing array index out of bounds errors with high cardinality fields. Signed-off-by: shreyah963 <[email protected]>
Signed-off-by: shreyah963 <[email protected]>
Signed-off-by: shreyah963 <[email protected]>
Signed-off-by: shreyah963 <[email protected]>
Signed-off-by: shreyah963 <[email protected]>
Signed-off-by: shreyah963 <[email protected]>
8ec48cd
to
4a13f79
Compare
❌ Gradle check result for 4a13f79: 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? |
❕ Gradle check result for 4a13f79: UNSTABLE Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #17740 +/- ##
============================================
+ Coverage 72.46% 72.48% +0.02%
- Complexity 66502 66519 +17
============================================
Files 5408 5408
Lines 308080 308192 +112
Branches 44720 44749 +29
============================================
+ Hits 223239 223396 +157
- Misses 66536 66537 +1
+ Partials 18305 18259 -46 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@shreyah963 - Can you add CHANGELOG entry as well? |
Signed-off-by: shreyah963 <[email protected]>
Signed-off-by: shreyah963 <[email protected]>
...main/java/org/opensearch/search/aggregations/bucket/composite/GlobalOrdinalValuesSource.java
Outdated
Show resolved
Hide resolved
Co-authored-by: bowenlan-amzn <[email protected]> Signed-off-by: shreyah963 <[email protected]>
Signed-off-by: shreyah963 <[email protected]>
❕ Gradle check result for d93f589: UNSTABLE Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure. |
Signed-off-by: Ankit Jain <[email protected]>
❕ Gradle check result for a6f9f4f: UNSTABLE Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure. |
The backport to
To backport manually, run these commands in your terminal: # Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch/backport-2.x
# Create a new branch
git switch --create backport/backport-17740-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 38231693572bd00363db1b0221a0bc632c4ceef2
# Push it to GitHub
git push --set-upstream origin backport/backport-17740-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch/backport-2.x Then, create a pull request where the |
…ce (opensearch-project#17740) * added singleton optimization path to globalordinalvaluesource Signed-off-by: shreyah963 <[email protected]> * enabled remote debugging Signed-off-by: shreyah963 <[email protected]> * Removed the minimum cap to handle larger ordinal values Signed-off-by: shreyah963 <[email protected]> * emove redundant singleton optimization state from SingleDimensionValuesSource and simplify the optimization logic in GlobalOrdinalValuesSource. The singleton optimization is now only applied when DocValues.unwrapSingleton() succeeds, preventing array index out of bounds errors with high cardinality fields. Signed-off-by: shreyah963 <[email protected]> * removed redundant initialization Signed-off-by: shreyah963 <[email protected]> * reverted the array allocation in the constructer to its original form Signed-off-by: shreyah963 <[email protected]> * [Docs] Add detailed comments to GlobalOrdinalValuesSource collector Signed-off-by: shreyah963 <[email protected]> * Remote redundant imports and disable remote debugging Signed-off-by: shreyah963 <[email protected]> * replaced wildcard import with only necessary imports Signed-off-by: shreyah963 <[email protected]> * Update CHANGELOG.md Signed-off-by: shreyah963 <[email protected]> * Update CHANGELOG.md Co-authored-by: bowenlan-amzn <[email protected]> Signed-off-by: shreyah963 <[email protected]> * Remove redundant comments from GlobalOrdinalValuesSource Signed-off-by: shreyah963 <[email protected]> --------- Signed-off-by: shreyah963 <[email protected]> Signed-off-by: Ankit Jain <[email protected]> Co-authored-by: bowenlan-amzn <[email protected]> Co-authored-by: Ankit Jain <[email protected]> Signed-off-by: Harsh Kothari <[email protected]>
…ce (opensearch-project#17740) * added singleton optimization path to globalordinalvaluesource Signed-off-by: shreyah963 <[email protected]> * enabled remote debugging Signed-off-by: shreyah963 <[email protected]> * Removed the minimum cap to handle larger ordinal values Signed-off-by: shreyah963 <[email protected]> * emove redundant singleton optimization state from SingleDimensionValuesSource and simplify the optimization logic in GlobalOrdinalValuesSource. The singleton optimization is now only applied when DocValues.unwrapSingleton() succeeds, preventing array index out of bounds errors with high cardinality fields. Signed-off-by: shreyah963 <[email protected]> * removed redundant initialization Signed-off-by: shreyah963 <[email protected]> * reverted the array allocation in the constructer to its original form Signed-off-by: shreyah963 <[email protected]> * [Docs] Add detailed comments to GlobalOrdinalValuesSource collector Signed-off-by: shreyah963 <[email protected]> * Remote redundant imports and disable remote debugging Signed-off-by: shreyah963 <[email protected]> * replaced wildcard import with only necessary imports Signed-off-by: shreyah963 <[email protected]> * Update CHANGELOG.md Signed-off-by: shreyah963 <[email protected]> * Update CHANGELOG.md Co-authored-by: bowenlan-amzn <[email protected]> Signed-off-by: shreyah963 <[email protected]> * Remove redundant comments from GlobalOrdinalValuesSource Signed-off-by: shreyah963 <[email protected]> --------- Signed-off-by: shreyah963 <[email protected]> Signed-off-by: Ankit Jain <[email protected]> Co-authored-by: bowenlan-amzn <[email protected]> Co-authored-by: Ankit Jain <[email protected]> Signed-off-by: Harsh Kothari <[email protected]>
Description
This PR optimizes the handling of single-valued fields in composite aggregations by modifying how we process ordinal values in GlobalOrdinalValuesSource. The key change is eliminating the need for iterative ordinal processing when we can use Lucene's singleton optimization.
Key Changes:
In GlobalOrdinalValuesSource.getLeafCollector(), we replace the iterative ordinal processing:
The key improvement is removing the while loop for single-valued fields. Instead of iterating through ordinals (which is unnecessary for single values), we now:
Performance Impact:
Testing Performance Improvement
Infrastructure Details
Run 1
Before change
After change
Run 2
Before change
After change
Run 3
Before change
After change
Run 4
Before change
After change
Run 5
Before change
After change
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.