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

Removing task Id using remove() in TaskCancellationMonitoringService #15918

Merged

Conversation

sgup432
Copy link
Contributor

@sgup432 sgup432 commented Sep 12, 2024

Description

In TaskCancellationMonitoringService, we track long cancelled tasks via hashmap. Once they are completed, we remove such tasks from the tracker. To do so, earlier we used to traverse the whole entrySet, find the taskId and then remove it which is basically a O(n) operation and unnecessary. Changed it to use remove() directly.

As we saw in one occasion, if a domain is facing too many cancellations and tasks are not getting cleared up, this traversal might become heavy on CPU.

Related Issues

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

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • [ ] Public documentation issue/PR created, if applicable.

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.

@sgup432 sgup432 changed the title Removing task Id from map using remove() in TaskCancellationMonitoringService Removing task Id remove() in TaskCancellationMonitoringService Sep 12, 2024
@jainankitk jainankitk added skip-changelog backport 2.x Backport to 2.x branch labels Sep 12, 2024
@sgup432 sgup432 changed the title Removing task Id remove() in TaskCancellationMonitoringService Removing task Id using remove() in TaskCancellationMonitoringService Sep 12, 2024
Copy link
Contributor

✅ Gradle check result for 3d83bfb: SUCCESS

Copy link

codecov bot commented Sep 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.90%. Comparing base (92d7fe8) to head (3d83bfb).
Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main   #15918   +/-   ##
=========================================
  Coverage     71.90%   71.90%           
- Complexity    64216    64278   +62     
=========================================
  Files          5272     5277    +5     
  Lines        300597   300691   +94     
  Branches      43440    43449    +9     
=========================================
+ Hits         216151   216225   +74     
- Misses        66680    66707   +27     
+ Partials      17766    17759    -7     

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

@jainankitk jainankitk merged commit 4223fab into opensearch-project:main Sep 12, 2024
65 of 66 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Sep 12, 2024
Signed-off-by: Sagar Upadhyaya <[email protected]>
(cherry picked from commit 4223fab)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
jainankitk pushed a commit that referenced this pull request Sep 13, 2024
(cherry picked from commit 4223fab)

Signed-off-by: Sagar Upadhyaya <[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>
dk2k pushed a commit to dk2k/OpenSearch that referenced this pull request Oct 16, 2024
dk2k pushed a commit to dk2k/OpenSearch that referenced this pull request Oct 17, 2024
dk2k pushed a commit to dk2k/OpenSearch that referenced this pull request Oct 21, 2024
akolarkunnu pushed a commit to akolarkunnu/OpenSearch that referenced this pull request Jan 21, 2025
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.

2 participants