-
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
Task consumer Integration #2293
Task consumer Integration #2293
Conversation
Can one of the admins verify this patch? |
❌ Gradle Check failure 96388abbca9e2e1c51bb8e1042fbe05a5daa55dc |
server/src/main/java/org/opensearch/tasks/consumer/TopNSearchTaskTracker.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/opensearch/tasks/consumer/TopNSearchTaskTracker.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/opensearch/tasks/consumer/TopNSearchTaskTracker.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/opensearch/search/internal/InternalScrollSearchRequest.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/opensearch/tasks/consumer/TopNSearchTaskTracker.java
Outdated
Show resolved
Hide resolved
@sruti1312 Take a look at the comments above? @kartg do a CR? |
96388ab
to
778463a
Compare
❌ Gradle Check failure 778463abb7369c03397ba48df27b74b519046c9e |
778463a
to
44409d3
Compare
❌ Gradle Check failure 44409d314e27fd683c59b7a36a4540e357333e84 |
} | ||
} | ||
|
||
// TODO: Need performance testing results to understand if we can to use synchronized here. |
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.
Does this TODO need to be answered before merging this code? It looks like you're merging this into a feature branch. What is the ultimate plan for the feature branch?
server/src/test/java/org/opensearch/tasks/consumer/TopNSearchTasksLoggerTests.java
Outdated
Show resolved
Hide resolved
// generating metadata in a lazy way since source can be quite big | ||
private final Supplier<String> metadataSupplier; |
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.
Do you know for sure that doing this lazily is the right approach? It adds complexity and actually results in more work if SearchShardTask#getTaskMetadata
happens to be called more than once. The optimal approach would be to memoize the result of the supplier, but that adds more complexity, so I'd suggest doing this only if you know there is a non-trivial perf benefit.
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.
Same/similar question from me - is there a reason why this can't be a simple String
instead of a Supplier
?
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.
For SearchShardTask
we want to log the query string to be able to correlate the top resource consumers with the query. We have seen query strings can be really huge and with high search workload it can be very expensive to construct it for each shard task. Also depending on the consumers type it may not be needed to get the query string for each shard tasks. Hence, depending upon the consumers (for example in this case TopNConsumer
) it will only call this method on the Tasks which are of interest and not on all the Task object.
I agree with the memoization approach but given at the moment there is only one caller expected for this method seems like we can do that optimization as a follow-up ?
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.
As @sohami pointed out this method will only be added once (from the consumer and if query is top resource consumer), there are no other callers to this method. In future if this method is going to be called more than once, we can extend to memoize the result of this supplier. Adding a comment for future reference.
Signed-off-by: sruti1312 <srutiparthiban@gmail.com>
44409d3
to
eeb754a
Compare
❌ Gradle Check failure c16db7a6d01d62a885caf40646b9aa87b1c5299d |
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.
This looks good to me overall, made some suggestions. Talk me out of the metadata part, looks like a hack.
Try to get the build to green, address @andrross's comments, etc.
server/src/main/java/org/opensearch/tasks/consumer/TaskDetailsLogMessage.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/opensearch/tasks/consumer/TaskDetailsLogMessage.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/opensearch/tasks/consumer/TopNSearchTasksLoggerTests.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/opensearch/tasks/consumer/TopNSearchTasksLogger.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/opensearch/tasks/consumer/TopNSearchTasksLogger.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/opensearch/tasks/consumer/TopNSearchTasksLogger.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/opensearch/tasks/consumer/TopNSearchTasksLoggerTests.java
Outdated
Show resolved
Hide resolved
c16db7a
to
e9ed69f
Compare
// generating metadata in a lazy way since source can be quite big | ||
private final Supplier<String> metadataSupplier; |
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.
Same/similar question from me - is there a reason why this can't be a simple String
instead of a Supplier
?
server/src/main/java/org/opensearch/tasks/consumer/TaskDetailsLogMessage.java
Outdated
Show resolved
Hide resolved
this.taskResourceConsumer = new ArrayList<Consumer<Task>>() { | ||
{ | ||
add(new TopNSearchTasksLogger(settings)); | ||
} | ||
}; |
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.
Nitpick - gate this with a check on taskResourceConsumersEnabled
?
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.
Adding TASK_RESOURCE_CONSUMER_SETTING to clusterSetting to enable/disable as required. Also adding a check to see if enabled before publishing to consumers. Do you still think we need to include a gate check here?
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.
As we continue to add more consumers what might help is a control knob per consumer instead of a blanket level knob
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.
@Bukhtawar When we have more consumers, it makes sense to have control knob per consumer! I think blanket level will also be helpful to control all consumers using one knob (like parent level). Going forward we can add the control knobs per consumer. Any thoughts?
// generating metadata in a lazy way since source can be quite big | ||
private final Supplier<String> metadataSupplier; |
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.
For SearchShardTask
we want to log the query string to be able to correlate the top resource consumers with the query. We have seen query strings can be really huge and with high search workload it can be very expensive to construct it for each shard task. Also depending on the consumers type it may not be needed to get the query string for each shard tasks. Hence, depending upon the consumers (for example in this case TopNConsumer
) it will only call this method on the Tasks which are of interest and not on all the Task object.
I agree with the memoization approach but given at the moment there is only one caller expected for this method seems like we can do that optimization as a follow-up ?
} | ||
} | ||
|
||
private synchronized void recordSearchTask(final Task searchTask) { |
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.
I think instead of making this method synchronized
we should have a queue to hold on to all the tasks which are passed to the consumer. Then a background thread should clear off that queue and manager the topN queue out of that. The reason being unregister
can be called on network thread and if logging takes long time (because of configuration or logging module issue) then we will end up blocking the network thread which can result into other issues in the cluster.
Performance test resultsWorkload configuration details
Cluster with consumer enabledLatency (ms)
Throughput (req/s)
Operation Counts
Usage (%)
Cluster with consumer disabledLatency (ms)
Throughput (req/s)
Operation Counts
Usage (%)
|
@sruti1312 Can you please address the comments? It would be great to get this PR to a closure. |
Is this PR going to target the 2.2 release or a later version? I just want to make sure the associated doc ticket for this functionality is accurate and updated so we don't miss the deadline. |
Gradle Check (Jenkins) Run Completed with:
|
Signed-off-by: sruti1312 <srutiparthiban@gmail.com>
52a6161
to
5f3c262
Compare
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
@Bukhtawar can you take a look and merge this if no blockers remain? I believe @sruti1312 would like to get this into 2.2 |
* Integrate task consumers to capture task resource information during unregister. Add consumer that logs topN expensive search tasks Signed-off-by: sruti1312 <srutiparthiban@gmail.com> (cherry picked from commit fbe93d4)
* Integrate task consumers to capture task resource information during unregister. Add consumer that logs topN expensive search tasks Signed-off-by: sruti1312 <srutiparthiban@gmail.com> (cherry picked from commit fbe93d4)
* Integrate task consumers to capture task resource information during unregister. Add consumer that logs topN expensive search tasks Signed-off-by: sruti1312 <srutiparthiban@gmail.com>
Signed-off-by: Sruti Parthiban partsrut@amazon.com
Description
Integrate task consumers to capture task resource information during unregister.
Add consumer that logs topN expensive search tasks
Issues Resolved
#1009
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.