-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Added resource usage trackers for in-flight cancellation of SearchShardTask #4805
Changes from 1 commit
1a35384
962cc05
e19c448
442ff82
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Signed-off-by: Ketan Verma <ketan9495@gmail.com>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,10 +41,10 @@ public long getCancellations() { | |
/** | ||
* Notifies the tracker to update its state when a task execution completes. | ||
*/ | ||
public abstract void update(Task task); | ||
public void update(Task task) {} | ||
|
||
/** | ||
* Returns the cancellation reason for the given task, if it's eligible for cancellation. | ||
*/ | ||
public abstract Optional<TaskCancellation.Reason> cancellationReason(Task task); | ||
public abstract Optional<TaskCancellation.Reason> checkAndMaybeGetCancellationReason(Task task); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function signature still doesn't look right, it doesn't clarify if cancellation will occur or not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still feel that it's correct – this only returns a |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.search.backpressure.trackers; | ||
|
||
/** | ||
* Defines the type of TaskResourceUsageTracker. | ||
*/ | ||
public enum TaskResourceUsageTrackerType { | ||
CPU_USAGE_TRACKER("cpu_usage_tracker"), | ||
HEAP_USAGE_TRACKER("heap_usage_tracker"), | ||
ELAPSED_TIME_TRACKER("elapsed_time_tracker"); | ||
|
||
private final String name; | ||
|
||
TaskResourceUsageTrackerType(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
} |
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.
Thanks for this, but in general we should think about decoupling tracking and action once thresholds have breached. Today it might be search cancellation but I do envision this as an action that modifies threadpool size/queue in a manner that creates a backpressure
We can think about that refactor as a fast follow up as that will help us add more actions
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.
Also cancellation isn't truly back pressure :) it's load shedding
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.
That makes sense. Trackers can recommend actions once thresholds are met, and cancellation of tasks can be one such action. This will however influence how dissimilar actions from different trackers are grouped/compared with each other in the
SearchBackpressureService
. For example, we need to aggregate the cancellation scores from each tracker before we start cancelling tasks. With generic actions, this might become really complicated.Let's do a detailed design of this first and refactor as a follow-up. Enhancement: #4985