Add resource stats to task framework#2089
Add resource stats to task framework#2089dblock merged 3 commits intoopensearch-project:mainfrom sruti1312:feature/resource-stats
Conversation
|
Can one of the admins verify this patch? |
|
✅ Gradle Check success fa63613384c4b3e2e19f41b58cd76f175396ad62 |
There was a problem hiding this comment.
Would it simplify things to make ResourceStats a class that is composed of a collection of ResourceStat? From a cursory overview, It feels like it would move serialization into the class along with other helper methods that operate on the collection of stats, simplify usage, and make some of the enums child classes of ResourceStat. It would also enable extending resource stats in the future into something more than just a map of string/value.
I agree. In general, when you find yourself creating things like |
client/rest-high-level/src/test/java/org/opensearch/client/tasks/CancelTasksResponseTests.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/opensearch/tasks/CancelTasksResponseTests.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/TaskTests.java
Outdated
Show resolved
Hide resolved
|
@dblock @andrross
The structure would look like this, Note:
Any thoughts? |
|
❌ Gradle Check failure 8e9f1bbb2d5b9b8116831fa021c756051cecc170 |
|
❌ Gradle Check failure da4b58b61e789b2a18474956212ae37610a99eec |
|
❌ Gradle Check failure e8ecfd06c0206c9a52e33fe4aa7dd3f718fe6111 |
|
❌ Gradle Check failure 67d10ce640623c17d9fb5fafd52c47fc2444739e |
|
❌ Gradle Check failure 6f2ebcd240d4dbc6cdb530bb33ab9cc8f5799534 |
|
❌ Gradle Check failure 5da6e8a5983215f35ebe928581363815a6fdc8c0 |
|
❌ Gradle Check failure 0bbad3d8edb27fa524c3fb9800a8709a21045fe6 |
|
❌ Gradle Check failure 9cca9ea49d21a82450fd73dc1fb6b025502d4779 |
server/src/main/java/org/opensearch/tasks/TaskCompleteResourceInfo.java
Outdated
Show resolved
Hide resolved
Is it a bad thing to write custom parsing logic? The option you presented above as "current approach" is I believe the correct way to structure the JSON. The question here is how to model Java code. The approaches I would consider are:
|
server/src/main/java/org/opensearch/tasks/TaskResourceInfo.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/opensearch/tasks/TaskCompleteResourceInfo.java
Outdated
Show resolved
Hide resolved
.../main/java/org/opensearch/action/admin/cluster/node/tasks/list/TransportListTasksAction.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/opensearch/tasks/TaskCompleteResourceInfo.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/opensearch/tasks/TaskCompleteResourceInfo.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
The overall structure might need to be optimised in favour of performance, since every update might need some synchronisation based on whether the actual worker thread is updating its resource overhead or the refresh thread.
Note: We can easily make it lock-free if we update the thread context and avoid the refresh. In which case the overhead can be tracked at discrete checkpoints on-demand(high resource consumption of CPU/memory) something similar to task cancellation instead of a refresh thread.
I would recommend simplifying this in favour of performance and maintainability whilst sacrificing accuracy.
If we go with refresh let's do all the computing without any contention with the common resource structure and do a CAS at the end to swap current and older structures.
|
I am curious how to get cpu time and memory consumption for each query? It's a very difficult job |
|
@xjtushilei ThreadMXBean#getThreadAllocatedBytes is the underlying mechanism that would be used to compute the query cpu time and memory |
|
❌ Gradle Check failure b11eb0402c18162027f75e9086285f6847199c50 |
|
❌ Gradle Check failure 8071f4e56e5e1d379734432319525318d287cdac |
|
❌ Gradle Check failure 09972f21d74f82b3549bae8f28c5ba3897e26da3 |
|
❌ Gradle Check failure fcfac4eb15ddf9fcd8921474d1dd29ae940bbf01 |
Signed-off-by: sruti1312 <srutiparthiban@gmail.com>
|
❌ Gradle Check failure 78880ef84769b0309430c34d34032f5b3dbf81e2 |
|
@Bukhtawar you're good with this? |
|
We will revisit as needed, no immediate blockers for merge |
|
@sruti1312 Do we want this in 2.0? 2.x? Let's label backports if so. |
|
I labeled to backport 2.x and 2.0, we have auto-backport going on. |
* Add resource stats to task framework Signed-off-by: sruti1312 <srutiparthiban@gmail.com> * Update thread resource info and add tests Signed-off-by: sruti1312 <srutiparthiban@gmail.com> (cherry picked from commit 8b997c1)
* Add resource stats to task framework Signed-off-by: sruti1312 <srutiparthiban@gmail.com> * Update thread resource info and add tests Signed-off-by: sruti1312 <srutiparthiban@gmail.com> (cherry picked from commit 8b997c1)
| return taskInfo(localNodeId, description, status); | ||
| if (excludeStats == false) { | ||
| resourceStats = new TaskResourceStats(new HashMap<>() { | ||
| { |
There was a problem hiding this comment.
We probably should not create a new class for that: new TaskResourceStats(Collections.singletonMap(TOTAL, getTotalResourceStats()))
Adds resource stats to task framework Signed-off-by: sruti1312 <srutiparthiban@gmail.com> Signed-off-by: Nicholas Walter Knize <nknize@apache.org> (cherry picked from commit 8b997c1)
Adds resource stats to task framework Signed-off-by: sruti1312 <srutiparthiban@gmail.com> Signed-off-by: Nicholas Walter Knize <nknize@apache.org> (cherry picked from commit 8b997c1)
Backporting pull requests opensearch-project#2089 and opensearch-project#3982 Signed-off-by: PritLadani <pritkladani@gmail.com>
Signed-off-by: sruti1312 srutiparthiban@gmail.com
Description
Add resource stats to task framework. The task expose interfaces to allow updating the resource stats.
Sample task response:
Issues Resolved
This is used for task resource tracking.
#1009
#1329
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.