-
Notifications
You must be signed in to change notification settings - Fork 123
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
Integrates KNN plugin with ConcurrentSearchRequestDecider interface #2111
Integrates KNN plugin with ConcurrentSearchRequestDecider interface #2111
Conversation
726db9a
to
641620c
Compare
@shatejas for perf runs completeness please add below details
|
src/main/java/org/opensearch/knn/plugin/search/KNNConcurrentSearchRequestDecider.java
Outdated
Show resolved
Hide resolved
1 shard
cohere 1 million
This was run on docker with this configuration |
src/main/java/org/opensearch/knn/plugin/search/KNNConcurrentSearchRequestDecider.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/knn/plugin/search/KNNConcurrentSearchRequestDecider.java
Show resolved
Hide resolved
public Optional<ConcurrentSearchRequestDecider> create(IndexSettings indexSettings) { | ||
return Optional.of(new KNNConcurrentSearchRequestDecider()); | ||
} |
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 we should not always send the new instance of KNNConcurrentSearchRequestDecider
. Only if indexSettings has index.knn = true we should send the new instance. Otherwise even for non k-NN indices this create method will be called, which means that for every querybuilder evaluateForQuery
function of KNNConcurrentSearchRequestDecider class.
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 before resolving the comment can you add a comment if you are going to make the change or not?
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.
@navneet1v Resolved after I made the change :)
Curious on why JVM was 36g? |
cc1ebaa
to
132894c
Compare
Didn't think memory made a difference as there is no change in amount of threads (as of 2.17) allocated by OS when concurrent segment search code path is used, so gave sufficient memory |
132894c
to
c0b4743
Compare
eb0c997
to
886d57e
Compare
src/test/java/org/opensearch/knn/integ/search/ConcurrentSegmentSearchIT.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
@SneakyThrows | ||
public void testConcurrentSegmentSearch() { |
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.
better to use the convention testABC_whenLMN_thenXYZ()
} | ||
*/ | ||
@SneakyThrows | ||
private XContentBuilder createFaissHnswIndexMapping(String fieldName, int dimension) { |
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.
You can do something like this:
createKnnIndex(testIndex, getKNNDefaultIndexSettings(), createKnnIndexMapping(TEST_FIELD, DIMENSIONS));
I would suggest checking KNNRestTestCase.java class as it has a lot of helper functions to create the index and not create another function in ITs for creating the mappings.
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.
You can do something like this
The mapping is being asserted so I need to separate it out
I would suggest checking KNNRestTestCase.java class as it has a lot of helper functions to create the index and not create another function in ITs for creating the mappings.
The requests for tests should be ideally localized to tests so we unknowingly don't affect multiple different test scenarios. Switching to KNNJsonIndexMappingsBuilder
but I would prefer this mapping to be localized to this test
updateIndexSettings(indexName, Settings.builder().put("index.search.concurrent_segment_search.mode", "auto")); | ||
|
||
// Test search queries | ||
int k = 10; | ||
verifySearch(indexName, fieldName, k); | ||
|
||
updateIndexSettings(indexName, Settings.builder().put("index.search.concurrent_segment_search.mode", "all")); |
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.
the indexsetting should be reverted back to default otherwise for all other tests CSS will start to work.
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.
Its using a specific index name for the IT to make sure no other tests are affected.
Will delete the index to be safe
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.
sure.
|
||
public class KNNConcurrentSearchRequestDeciderTests extends KNNTestCase { | ||
|
||
public void testDecider() { |
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 as above use testABC_whenLMN_thenXYZ() for all the test functions
src/main/java/org/opensearch/knn/plugin/search/KNNConcurrentSearchRequestDecider.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/knn/plugin/search/KNNConcurrentSearchRequestDecider.java
Show resolved
Hide resolved
|
||
@Override | ||
public void evaluateForQuery(final QueryBuilder queryBuilder, final IndexSettings indexSettings) { | ||
if (queryBuilder instanceof KNNQueryBuilder && indexSettings.getValue(KNNSettings.IS_KNN_INDEX_SETTING)) { |
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.
Will we be able to look into cpu and memory? Is this done in a chain like fashion?
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.
Will we be able to look into cpu and memory
The control is with core and core decides based on CPU and couple other conditions. I don't think they have any immediate plans to give that control to plugin as per the RFC and plugin RFC
Is this done in a chain like fashion?
I don't completely understand the question. There will be multiple deciders based on number of plugins, it will loop through each of them and evaluate the query builder with visitor pattern using QueryBuilder.visit
which evaluates and sets a decision. Even if one decider decides NO
it will not execute concurrent search. Let me know if that answers your question
886d57e
to
11a1d0e
Compare
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! Thanks!
This allows knn queries to enable concurrency when index.search.concurrent_segment_search.mode or search.concurrent_segment_search.mode in auto mode. Without this the default behavior of auto mode is non-concurrent search Signed-off-by: Tejas Shah <[email protected]>
e502d6f
to
921e5d7
Compare
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.x 2.x
# Navigate to the new working tree
cd .worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-2111-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 0421cdc907b43e4a930bd5a51454e5efea8413b6
# Push it to GitHub
git push --set-upstream origin backport/backport-2111-to-2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.x Then, create a pull request where the |
…pensearch-project#2111) This allows knn queries to enable concurrency when index.search.concurrent_segment_search.mode or search.concurrent_segment_search.mode in auto mode. Without this the default behavior of auto mode is non-concurrent search Signed-off-by: Tejas Shah <[email protected]> (cherry picked from commit 0421cdc)
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.17 2.17
# Navigate to the new working tree
cd .worktrees/backport-2.17
# Create a new branch
git switch --create backport/backport-2111-to-2.17
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 0421cdc907b43e4a930bd5a51454e5efea8413b6
# Push it to GitHub
git push --set-upstream origin backport/backport-2111-to-2.17
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.17 Then, create a pull request where the |
…pensearch-project#2111) This allows knn queries to enable concurrency when index.search.concurrent_segment_search.mode or search.concurrent_segment_search.mode in auto mode. Without this the default behavior of auto mode is non-concurrent search Signed-off-by: Tejas Shah <[email protected]> (cherry picked from commit 0421cdc)
…pensearch-project#2111) This allows knn queries to enable concurrency when index.search.concurrent_segment_search.mode or search.concurrent_segment_search.mode in auto mode. Without this the default behavior of auto mode is non-concurrent search Signed-off-by: Tejas Shah <[email protected]> (cherry picked from commit 0421cdc)
…pensearch-project#2111) This allows knn queries to enable concurrency when index.search.concurrent_segment_search.mode or search.concurrent_segment_search.mode in auto mode. Without this the default behavior of auto mode is non-concurrent search Signed-off-by: Tejas Shah <[email protected]> (cherry picked from commit 0421cdc)
…pensearch-project#2111) This allows knn queries to enable concurrency when index.search.concurrent_segment_search.mode or search.concurrent_segment_search.mode in auto mode. Without this the default behavior of auto mode is non-concurrent search Signed-off-by: Tejas Shah <[email protected]> (cherry picked from commit 0421cdc)
…2111) (#2132) This allows knn queries to enable concurrency when index.search.concurrent_segment_search.mode or search.concurrent_segment_search.mode in auto mode. Without this the default behavior of auto mode is non-concurrent search Signed-off-by: Tejas Shah <[email protected]> (cherry picked from commit 0421cdc)
…2111) (#2126) This allows knn queries to enable concurrency when index.search.concurrent_segment_search.mode or search.concurrent_segment_search.mode in auto mode. Without this the default behavior of auto mode is non-concurrent search Signed-off-by: Tejas Shah <[email protected]> (cherry picked from commit 0421cdc)
This allows knn queries to enable concurrency when
index.search.concurrent_segment_search.mode
orsearch.concurrent_segment_search.mode
inauto
mode. Without this the default behavior of auto mode is non-concurrent searchDescription
More details in opensearch-project/OpenSearch#15259
Testing
Functional
ConcurrentQueryPhaseSearcher
is usedPerformance
Baseline (no settings update)
50th percentile latency,prod-queries,58.86101468404134,ms
90th percentile latency,prod-queries,85.32014465332031,ms
99th percentile latency,prod-queries,95.10733413696289,ms
Concurrent_segment_search.mode: auto
50th percentile latency,prod-queries,45.04893729613377,ms
90th percentile latency,prod-queries,48.14952836545217,ms
99th percentile latency,prod-queries,50.41835594177246,ms
Check List
--signoff
.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.