-
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
Supports additional query timing types for profiling plugin query components #17146
base: 2.x
Are you sure you want to change the base?
Conversation
ContextIndexSearcher Signed-off-by: Tejas Shah <[email protected]>
Signed-off-by: Tejas Shah <[email protected]>
❌ Gradle check result for 51f1446: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
@@ -48,7 +48,9 @@ public enum QueryTimingType { | |||
SCORE, | |||
SHALLOW_ADVANCE, | |||
COMPUTE_MAX_SCORE, | |||
SET_MIN_COMPETITIVE_SCORE; | |||
SET_MIN_COMPETITIVE_SCORE, |
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.
@shatejas the core does not know anything about k-nn plugin (or any other plugin per se), this has to be part of the plugin related instrumentation. We may need to think how the profile phases could be extended / customized though, if required.
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.
@reta I understand, whats the recommendation in that case? this is one way I found to be able to have additional components in profile query
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.
@shatejas we may never run into a need to have such an extensibility feature, so we may have to design in a plugin neural way.
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.
we may never run into a need to have such an extensibility feature
Currently there is a need to have time_in_nanos
for knn. KNN query is relatively complex, both ann and exact search as well as the filter query inside the knn are major components and there is no visibility on these making it extremely difficult to debug performance issues.
Currently I wasn't able to find a hook to have knn components in query breakdown without these changes.
so we may have to design in a plugin neural way.
can you elaborate whats involved here? if its major change in knn plugin it might have to be iterative and this change might work till then
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.
@reta I think agree on designing this in a plugin neutral way. @shatejas lets have extension points in core that can be used by Plugins to provide their QueryTimingTyes.
One idea I can think of here is QueryTimingType
would be getting used to put in some string in the profile output. We can create another enum/class which collects all the TimingType from all the plugins and then put them at right place during serialization.
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.
@reta Thanks, I am looking into it. I haven't found a solution yet. Doing a deep dive on possible options
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.
@reta I tried another approach which holds additional types per query. Let me know what you think
Other options:
- Maintain a Query -> QueryBreakdown registry in the profile tree. But I am not sure if there is a use case for it where a plugin wants to override a default types for a query.
- Maintain a Query -> QueryProfiler registry and get profilers based on Query type falling back to default. Haven't tried it but from what it looks like each profile breakdown is written as a separate json blob
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.
@reta I tried another approach which holds additional types per query. Let me know what you think
Thanks @shatejas , I believe it is important to evolve the APIs in a consistent way, here is the quick sketch that I would like to hear your opinion on:
- the plugins contribute queries using
SearchPlugin
plugin hooks - however, there is nothing here regarding the query profiling
It probably would make sense to introduce the QueryProfilerSpec
API, that we should let plugins to contribute, couple of options to consider:
- the
QuerySpec
could (optionally) supply the correspondingQueryProfilerSpec
, or - the
SearchPlugin
may a generic hook likedefault List<QueryProfilerSpec<?>> getQueryProfilers() { return emptyList(); }
That would provide a basic to build atop, does it make sense?
Thank you.
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.
@reta I found one way to do it shatejas@04cff1c
Currently it uses QueryProfiler instead of AbstractQueryProfiler for simplicity. Overall I don't like the implementation, the context index searcher now is responsible for creating a new instance of profiler. Moreover it has to maintain a state of what profilers were used to be able to send it back to Profilers
class.
Moreover, I don't think plugins should be responsible for concurrentProfilers, for one plugin queries simply leverage concurrency from opensearch-core. apart from that concurrentProfler implementation seems pretty complex, it will be a heavy lift for plugins (if they are not allowed to provide instance of existing one).
Please note that we don't need to replace or piggybacking here
Just so I understand the concern - Why should plugins not be allowed to piggyback on existing response if its not polluting the response? I understand that the APIs should be consistent, but the current implementation doesn't seem to allow it.
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.
@reta I found one way to do it shatejas@04cff1c
Thanks @shatejas , I will try to look at it shortly
Just so I understand the concern - Why should plugins not be allowed to piggyback on existing response if its not polluting the response? I understand that the APIs should be consistent, but the current implementation doesn't seem to allow it.
To reiterate, I think the default query profiler should be always on. The additional profilers could be introduced. The concept of "piggybacking" with such a design is not needed here.
server/src/main/java/org/opensearch/search/profile/query/QueryTimingType.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Tejas Shah <[email protected]>
❌ Gradle check result for 568cfe2: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
On the unrelated note, @shatejas please target |
Signed-off-by: Tejas Shah <[email protected]>
❌ Gradle check result for fe1c855: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
@@ -98,6 +100,10 @@ default QueryBuilder rewrite(QueryRewriteContext queryShardContext) throws IOExc | |||
return this; | |||
} | |||
|
|||
default Set<String> queryProfilerTimingTypes() { |
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.
need to remove this
Description
Adds enums related to knn to be able to profile ann query. Currently its difficult to debug latencies for knn, this will help increase visibility on knn query
KNN PR: opensearch-project/k-NN#2450
Related Issues
Resolves opensearch-project/k-NN#2286
Sample response
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.