Skip to content
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

Enabling sort optimization back for half_float with custom comparators #11024

Merged
merged 15 commits into from
Nov 14, 2023

Conversation

gashutos
Copy link
Contributor

@gashutos gashutos commented Oct 31, 2023

Description

Enabling back sort optimization for half_float which was disabled here #10999.
As mentioned in below issue, for this sort optimization to get enabled, the BKD indexed point size and point size passed in comparator should be exactly same. With custom comparator HalfFloatComparator we achieved that.
Also I have added missing unit tests & integ tests for half_float field type to avoid any such issues.

[I am planning to add this in opensearch-3.0]

Tests

  1. Added half_float field type sort unit tests.
  2. Added half_float field type sort integ tests.
  3. Added half_float field type search_after tests.
  4. Added half_float field type mixed type sort result tests.
  5. Added half_float field type missign value sort tests.
  6. Added half_float field type as index sort.

Related Issues

Resolves #[Issue number to be closed when this PR is merged]
#10998

Perf impact with this change (this is already there but we had to disable)

Before this change

|                                   50th percentile service time | desc_sort_tip_amount |     1478.62 |     ms |
|                                   90th percentile service time | desc_sort_tip_amount |     1484.97 |     ms |
|                                   99th percentile service time | desc_sort_tip_amount |     1487.94 |     ms |
|                                  100th percentile service time | desc_sort_tip_amount |     1499.31 |     ms |

|                                   50th percentile service time |  asc_sort_tip_amount |     1466.53 |     ms |
|                                   90th percentile service time |  asc_sort_tip_amount |     1473.64 |     ms |
|                                   99th percentile service time |  asc_sort_tip_amount |     1496.76 |     ms |
|                                  100th percentile service time |  asc_sort_tip_amount |     1704.93 |     ms |

After this change

|                                   50th percentile service time | desc_sort_tip_amount |     9.26986 |     ms |
|                                   90th percentile service time | desc_sort_tip_amount |     9.82747 |     ms |
|                                   99th percentile service time | desc_sort_tip_amount |     10.3689 |     ms |
|                                  100th percentile service time | desc_sort_tip_amount |     10.4408 |     ms |

|                                   50th percentile service time |  asc_sort_tip_amount |     95.3346 |     ms |
|                                   90th percentile service time |  asc_sort_tip_amount |      95.776 |     ms |
|                                   99th percentile service time |  asc_sort_tip_amount |     100.285 |     ms |
|                                  100th percentile service time |  asc_sort_tip_amount |       109.3 |     ms |

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Failing checks are inspected and point to the corresponding known issue(s) (See: Troubleshooting Failing Builds)
  • Commits are signed per the DCO using --signoff
  • Commit changes are listed out in CHANGELOG.md file (See: Changelog)
  • Public documentation issue/PR created

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.

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>
@gashutos
Copy link
Contributor Author

@reta @backslasht I have added back half_float optimization with custom comparators introductions. Added much more tests for half_float now.

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

github-actions bot commented Oct 31, 2023

Compatibility status:

Checks if related components are compatible with change b198f6b

Incompatible components

Incompatible components: [https://github.com/opensearch-project/performance-analyzer.git]

Skipped components

Compatible components

Compatible components: [https://github.com/opensearch-project/security-analytics.git, https://github.com/opensearch-project/security.git, https://github.com/opensearch-project/custom-codecs.git, https://github.com/opensearch-project/opensearch-oci-object-storage.git, https://github.com/opensearch-project/index-management.git, https://github.com/opensearch-project/geospatial.git, https://github.com/opensearch-project/sql.git, https://github.com/opensearch-project/job-scheduler.git, https://github.com/opensearch-project/notifications.git, https://github.com/opensearch-project/observability.git, https://github.com/opensearch-project/k-nn.git, https://github.com/opensearch-project/neural-search.git, https://github.com/opensearch-project/cross-cluster-replication.git, https://github.com/opensearch-project/alerting.git, https://github.com/opensearch-project/anomaly-detection.git, https://github.com/opensearch-project/performance-analyzer-rca.git, https://github.com/opensearch-project/asynchronous-search.git, https://github.com/opensearch-project/ml-commons.git, https://github.com/opensearch-project/common-utils.git, https://github.com/opensearch-project/reporting.git]

Copy link
Contributor

github-actions bot commented Nov 8, 2023

Gradle Check (Jenkins) Run Completed with:

Copy link
Contributor

❌ Gradle check result for b198f6b: 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?

Copy link
Contributor

❌ Gradle check result for b198f6b: null

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?

Copy link
Contributor

❌ Gradle check result for b198f6b: null

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?

Copy link
Contributor

❕ Gradle check result for b198f6b: UNSTABLE

  • TEST FAILURES:
      1 org.opensearch.search.SearchWeightedRoutingIT.testMultiGetWithNetworkDisruption_FailOpenEnabled
      1 org.opensearch.remotestore.multipart.RemoteStoreMultipartIT.testRequestDurabilityWhenRestrictSettingExplicitFalse
      1 org.opensearch.http.SearchRestCancellationIT.testAutomaticCancellationMultiSearchDuringQueryPhase

Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure.

@reta reta merged commit 5143198 into opensearch-project:main Nov 14, 2023
27 checks passed
@reta reta added v3.0.0 Issues and PRs related to version 3.0.0 backport 2.x Backport to 2.x branch v2.12.0 Issues and PRs related to version 2.12.0 labels Nov 14, 2023
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

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-11024-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 5143198f43f05e5d1692624adc3733ac19b90004
# Push it to GitHub
git push --set-upstream origin backport/backport-11024-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 base branch is 2.x and the compare/head branch is backport/backport-11024-to-2.x.

gashutos added a commit to gashutos/OpenSearch that referenced this pull request Nov 14, 2023
opensearch-project#11024)

* Enabling sort optimizatin back for half_float with custom comparators

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Fixing tests

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Adding test for Indecx sort half_float

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Making indexFieldData provate in FloatValuesComparatorSource

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Update server/src/main/java/org/opensearch/index/search/comparators/HalfFloatComparator.java

Co-authored-by: Andriy Redko <drreta@gmail.com>
Signed-off-by: Chaitanya Gohel <104654647+gashutos@users.noreply.github.com>

* Adding missing value instead null

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Adding more tests for desc order sort

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Update rest-api-spec/src/main/resources/rest-api-spec/test/search/90_search_after.yml

Co-authored-by: Prabhakar Sithanandam <prabhakar.s87@gmail.com>
Signed-off-by: Chaitanya Gohel <104654647+gashutos@users.noreply.github.com>

* Adding tests in case missing values are competitive

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* chanheing newly added test supported version 3.0.0

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Assing missing float tests

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Remove missing value change to be part of another PR

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

---------

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>
Signed-off-by: Chaitanya Gohel <104654647+gashutos@users.noreply.github.com>
Co-authored-by: Andriy Redko <drreta@gmail.com>
Co-authored-by: Prabhakar Sithanandam <prabhakar.s87@gmail.com>
reta added a commit that referenced this pull request Nov 14, 2023
#11024) (#11197)

* Enabling sort optimizatin back for half_float with custom comparators



* Fixing tests



* Adding test for Indecx sort half_float



* Making indexFieldData provate in FloatValuesComparatorSource



* Update server/src/main/java/org/opensearch/index/search/comparators/HalfFloatComparator.java




* Adding missing value instead null



* Adding more tests for desc order sort



* Update rest-api-spec/src/main/resources/rest-api-spec/test/search/90_search_after.yml




* Adding tests in case missing values are competitive



* chanheing newly added test supported version 3.0.0



* Assing missing float tests



* Remove missing value change to be part of another PR



---------

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>
Signed-off-by: Chaitanya Gohel <104654647+gashutos@users.noreply.github.com>
Co-authored-by: Andriy Redko <drreta@gmail.com>
Co-authored-by: Prabhakar Sithanandam <prabhakar.s87@gmail.com>
@dblock
Copy link
Member

dblock commented Nov 14, 2023

This tests seem broken when run from opensearch-py, https://github.com/opensearch-project/opensearch-py/actions/runs/6868286935/job/18678495702, opensearch-project/opensearch-py#582.

@reta
Copy link
Collaborator

reta commented Nov 14, 2023

This tests seem broken when run from opensearch-py, https://github.com/opensearch-project/opensearch-py/actions/runs/6868286935/job/18678495702, opensearch-project/opensearch-py#582.

Thanks a lot @dblock , @gashutos mind please taking a look? thank you!

@dblock
Copy link
Member

dblock commented Nov 14, 2023

I'm also a bit worried seeing that the error message has a serialized FloatValuesComparatorSource object in it.

{"type":"illegal_argument_exception","reason":"Field population is indexed with 2 bytes per dimension, but org.opensearch.index.fielddata.fieldcomparator.FloatValuesComparatorSource$1@2570133f expected 4"}}

@gashutos
Copy link
Contributor Author

gashutos commented Nov 15, 2023

@dblock @reta just saw this, it looks like this was invoked in 2.11.0 version where half_float were already broken. The fix is in 2.11.1. The half_float sort test should not have run for 2.11.0. I will check why it did run the test for 2.11.0 for py client. For OpenSearch, this test run only for 2.11.1.

@dblock
Copy link
Member

dblock commented Nov 15, 2023

@dblock @reta just saw this, it looks like this was invoked in 2.11.0 version where half_float were already broken. The fix is in 2.11.1. The half_float sort test should not have run for 2.11.0. I will check why it did run the test for 2.11.0 for py client. For OpenSearch, this test run only for 2.11.1.

The REST spec should skip this test for 2.11.0. That version has been released. Will you please make that change @gashutos?

@dblock
Copy link
Member

dblock commented Nov 15, 2023

I'm also a bit worried seeing that the error message has a serialized FloatValuesComparatorSource object in it.

{"type":"illegal_argument_exception","reason":"Field population is indexed with 2 bytes per dimension, but org.opensearch.index.fielddata.fieldcomparator.FloatValuesComparatorSource$1@2570133f expected 4"}}

@gashutos Is this a new bug?

@gashutos
Copy link
Contributor Author

I'm also a bit worried seeing that the error message has a serialized FloatValuesComparatorSource object in it.

{"type":"illegal_argument_exception","reason":"Field population is indexed with 2 bytes per dimension, but org.opensearch.index.fielddata.fieldcomparator.FloatValuesComparatorSource$1@2570133f expected 4"}}

@gashutos Is this a new bug?

No no, its not a bug. In search query, it outputs like that only in response.

fahadshamiinsta pushed a commit to fahadshamiinsta/OpenSearch270 that referenced this pull request Dec 4, 2023
opensearch-project#11024)

* Enabling sort optimizatin back for half_float with custom comparators

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Fixing tests

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Adding test for Indecx sort half_float

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Making indexFieldData provate in FloatValuesComparatorSource

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Update server/src/main/java/org/opensearch/index/search/comparators/HalfFloatComparator.java

Co-authored-by: Andriy Redko <drreta@gmail.com>
Signed-off-by: Chaitanya Gohel <104654647+gashutos@users.noreply.github.com>

* Adding missing value instead null

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Adding more tests for desc order sort

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Update rest-api-spec/src/main/resources/rest-api-spec/test/search/90_search_after.yml

Co-authored-by: Prabhakar Sithanandam <prabhakar.s87@gmail.com>
Signed-off-by: Chaitanya Gohel <104654647+gashutos@users.noreply.github.com>

* Adding tests in case missing values are competitive

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* chanheing newly added test supported version 3.0.0

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Assing missing float tests

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Remove missing value change to be part of another PR

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

---------

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>
Signed-off-by: Chaitanya Gohel <104654647+gashutos@users.noreply.github.com>
Co-authored-by: Andriy Redko <drreta@gmail.com>
Co-authored-by: Prabhakar Sithanandam <prabhakar.s87@gmail.com>
rayshrey pushed a commit to rayshrey/OpenSearch that referenced this pull request Mar 18, 2024
opensearch-project#11024)

* Enabling sort optimizatin back for half_float with custom comparators

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Fixing tests

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Adding test for Indecx sort half_float

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Making indexFieldData provate in FloatValuesComparatorSource

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Update server/src/main/java/org/opensearch/index/search/comparators/HalfFloatComparator.java

Co-authored-by: Andriy Redko <drreta@gmail.com>
Signed-off-by: Chaitanya Gohel <104654647+gashutos@users.noreply.github.com>

* Adding missing value instead null

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Adding more tests for desc order sort

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Update rest-api-spec/src/main/resources/rest-api-spec/test/search/90_search_after.yml

Co-authored-by: Prabhakar Sithanandam <prabhakar.s87@gmail.com>
Signed-off-by: Chaitanya Gohel <104654647+gashutos@users.noreply.github.com>

* Adding tests in case missing values are competitive

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* chanheing newly added test supported version 3.0.0

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Assing missing float tests

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Remove missing value change to be part of another PR

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

---------

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>
Signed-off-by: Chaitanya Gohel <104654647+gashutos@users.noreply.github.com>
Co-authored-by: Andriy Redko <drreta@gmail.com>
Co-authored-by: Prabhakar Sithanandam <prabhakar.s87@gmail.com>
shiv0408 pushed a commit to Gaurav614/OpenSearch that referenced this pull request Apr 25, 2024
opensearch-project#11024)

* Enabling sort optimizatin back for half_float with custom comparators

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Fixing tests

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Adding test for Indecx sort half_float

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Making indexFieldData provate in FloatValuesComparatorSource

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Update server/src/main/java/org/opensearch/index/search/comparators/HalfFloatComparator.java

Co-authored-by: Andriy Redko <drreta@gmail.com>
Signed-off-by: Chaitanya Gohel <104654647+gashutos@users.noreply.github.com>

* Adding missing value instead null

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Adding more tests for desc order sort

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Update rest-api-spec/src/main/resources/rest-api-spec/test/search/90_search_after.yml

Co-authored-by: Prabhakar Sithanandam <prabhakar.s87@gmail.com>
Signed-off-by: Chaitanya Gohel <104654647+gashutos@users.noreply.github.com>

* Adding tests in case missing values are competitive

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* chanheing newly added test supported version 3.0.0

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Assing missing float tests

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

* Remove missing value change to be part of another PR

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>

---------

Signed-off-by: Chaitanya Gohel <gashutos@amazon.com>
Signed-off-by: Chaitanya Gohel <104654647+gashutos@users.noreply.github.com>
Co-authored-by: Andriy Redko <drreta@gmail.com>
Co-authored-by: Prabhakar Sithanandam <prabhakar.s87@gmail.com>
Signed-off-by: Shivansh Arora <hishiv@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Backport to 2.x branch backport-failed v2.12.0 Issues and PRs related to version 2.12.0 v3.0.0 Issues and PRs related to version 3.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants