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

Pre computing hash code for WeightedRouting to avoid recomputing it #13099

Merged
merged 1 commit into from
Apr 6, 2024

Conversation

backslasht
Copy link
Contributor

@backslasht backslasht commented Apr 5, 2024

Description

WeightedRoutingKey is used as key in the HashMap to retreive the shard routings, for every usage the hash key is computed. WeightedRoutingKey internally uses WeightedRouting. As the number of the shards getting queried increases, the computation cost goes high.

Computing the hash key during object creation as the object is immutable and using it through out the object thus saving on the additional computation.

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.

WeightedRoutingKey is used as key in the HashMap to retreive the shard
routings, for every usage the hash key is computed. WeightedRoutingKey
internally uses WeightedRouting. As the number of the shards getting
queried increases, the computation cost goes high.

Computing the hash key during object creation as the object is immutable
and using it through out the object thus saving on the additional computation.

Signed-off-by: Prabhakar Sithanandam <prabhakar.s87@gmail.com>
Copy link
Contributor

github-actions bot commented Apr 5, 2024

Compatibility status:

Checks if related components are compatible with change 4c45acc

Incompatible components

Skipped components

Compatible components

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

Copy link
Contributor

github-actions bot commented Apr 5, 2024

❕ Gradle check result for 4c45acc: UNSTABLE

  • TEST FAILURES:
      1 org.opensearch.http.SearchRestCancellationIT.testAutomaticCancellationMultiSearchDuringFetchPhase

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

Copy link

codecov bot commented Apr 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.47%. Comparing base (b15cb0c) to head (4c45acc).
Report is 135 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #13099      +/-   ##
============================================
+ Coverage     71.42%   71.47%   +0.05%     
- Complexity    59978    60432     +454     
============================================
  Files          4985     5026      +41     
  Lines        282275   284458    +2183     
  Branches      40946    41200     +254     
============================================
+ Hits         201603   203316    +1713     
- Misses        63999    64297     +298     
- Partials      16673    16845     +172     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Bukhtawar Bukhtawar merged commit 8d9e12d into opensearch-project:main Apr 6, 2024
109 of 111 checks passed
@backslasht backslasht deleted the weighted_routing branch April 6, 2024 13:32
@backslasht backslasht added the backport 2.x Backport to 2.x branch label Apr 6, 2024
opensearch-trigger-bot bot pushed a commit that referenced this pull request Apr 6, 2024
…13099)

WeightedRoutingKey is used as key in the HashMap to retreive the shard
routings, for every usage the hash key is computed. WeightedRoutingKey
internally uses WeightedRouting. As the number of the shards getting
queried increases, the computation cost goes high.

Computing the hash key during object creation as the object is immutable
and using it through out the object thus saving on the additional computation.

Signed-off-by: Prabhakar Sithanandam <prabhakar.s87@gmail.com>
(cherry picked from commit 8d9e12d)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Bukhtawar pushed a commit that referenced this pull request Apr 7, 2024
…13099) (#13107)

WeightedRoutingKey is used as key in the HashMap to retreive the shard
routings, for every usage the hash key is computed. WeightedRoutingKey
internally uses WeightedRouting. As the number of the shards getting
queried increases, the computation cost goes high.

Computing the hash key during object creation as the object is immutable
and using it through out the object thus saving on the additional computation.


(cherry picked from commit 8d9e12d)

Signed-off-by: Prabhakar Sithanandam <prabhakar.s87@gmail.com>
shiv0408 pushed a commit to Gaurav614/OpenSearch that referenced this pull request Apr 25, 2024
…pensearch-project#13099)

WeightedRoutingKey is used as key in the HashMap to retreive the shard
routings, for every usage the hash key is computed. WeightedRoutingKey
internally uses WeightedRouting. As the number of the shards getting
queried increases, the computation cost goes high.

Computing the hash key during object creation as the object is immutable
and using it through out the object thus saving on the additional computation.

Signed-off-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 skip-changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants