Skip to content
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

Split jnis into 2 libs and add common lib #181

Merged
merged 4 commits into from
Nov 4, 2021

Conversation

jmazanec15
Copy link
Member

@jmazanec15 jmazanec15 commented Nov 4, 2021

Signed-off-by: John Mazanec jmazane@amazon.com

Description

This PR splits the "opensearchknn" jni into 2 jni's: "opensearchknn_nmslib" and "opensearchknn_faiss". In addition, it builds another shared library "opensearchknn_common" that will be shared between the 2. The primary reason for splitting the 2 libraries is isolation: for a user using nmslib only, they should not need to load faiss and vice-versa.

Previously, routing to the correct engine was done in jni/src/org_opensearch_knn_index_JNIService.cpp. This change moves this routing decision up into the Java layer. JNIService will route request to either FaissService or NmslibService.

This PR is in WIP for the following:

  • Ensure Docker image and tar ball do not break
  • Fix CPack logic
  • A few minor tweaks

I will remove WIP status once I think it is ready to merge.

Issues Resolved

#173

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed as per the DCO using --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.

Signed-off-by: John Mazanec <jmazane@amazon.com>
@codecov-commenter
Copy link

Codecov Report

Merging #181 (c4fbe71) into main (0264f65) will increase coverage by 0.15%.
The diff coverage is 84.78%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #181      +/-   ##
============================================
+ Coverage     82.62%   82.78%   +0.15%     
- Complexity      804      826      +22     
============================================
  Files           117      120       +3     
  Lines          3575     3631      +56     
  Branches        337      342       +5     
============================================
+ Hits           2954     3006      +52     
- Misses          466      468       +2     
- Partials        155      157       +2     
Impacted Files Coverage Δ
...n/java/org/opensearch/knn/common/KNNConstants.java 91.66% <ø> (ø)
.../main/java/org/opensearch/knn/index/KNNWeight.java 75.00% <ø> (ø)
...index/codec/KNN80Codec/KNN80DocValuesConsumer.java 81.05% <ø> (ø)
...earch/knn/index/memory/NativeMemoryAllocation.java 82.92% <ø> (ø)
...rch/knn/index/memory/NativeMemoryLoadStrategy.java 96.61% <ø> (ø)
.../opensearch/knn/training/TrainingDataConsumer.java 100.00% <ø> (ø)
.../java/org/opensearch/knn/training/TrainingJob.java 86.44% <ø> (ø)
...main/java/org/opensearch/knn/jni/FaissService.java 83.33% <66.66%> (ø)
...ain/java/org/opensearch/knn/jni/NmslibService.java 83.33% <83.33%> (ø)
...c/main/java/org/opensearch/knn/jni/JNIService.java 85.71% <85.71%> (ø)
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0264f65...c4fbe71. Read the comment docs.

Signed-off-by: John Mazanec <jmazane@amazon.com>
Signed-off-by: John Mazanec <jmazane@amazon.com>
Signed-off-by: John Mazanec <jmazane@amazon.com>
@jmazanec15 jmazanec15 changed the title [WIP] Split jnis into 2 libs and add common lib Split jnis into 2 libs and add common lib Nov 4, 2021
@jmazanec15
Copy link
Member Author

Confirmed tar works arm/x64 on AL2 and Ubuntu 18. Confirmed docker works on arm and x64. PR is ready to be reviewed/shipped.

Comment on lines +44 to +48
if (${CONFIG_FAISS} STREQUAL OFF AND ${CONFIG_NMSLIB} STREQUAL OFF AND ${CONFIG_TEST} STREQUAL OFF)
set(CONFIG_ALL ON)
else()
set(CONFIG_ALL OFF)
endif ()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (${CONFIG_FAISS} STREQUAL OFF AND ${CONFIG_NMSLIB} STREQUAL OFF AND ${CONFIG_TEST} STREQUAL OFF)
set(CONFIG_ALL ON)
else()
set(CONFIG_ALL OFF)
endif ()
if (${CONFIG_FAISS} STREQUAL ON OR ${CONFIG_NMSLIB} STREQUAL ON OR ${CONFIG_TEST} STREQUAL ON)
set(CONFIG_ALL OFF)
endif ()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then if they are all on, config_all will be set to off.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

Copy link
Member

@vamshin vamshin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks

@jmazanec15 jmazanec15 merged commit 15b06fa into opensearch-project:main Nov 4, 2021
@jmazanec15 jmazanec15 added the Enhancements Increases software capabilities beyond original client specifications label Nov 15, 2021
martin-gaievski pushed a commit to martin-gaievski/k-NN that referenced this pull request Mar 7, 2022
Signed-off-by: John Mazanec <jmazane@amazon.com>
martin-gaievski pushed a commit to martin-gaievski/k-NN that referenced this pull request Mar 7, 2022
Signed-off-by: John Mazanec <jmazane@amazon.com>
Signed-off-by: Martin Gaievski <gaievski@amazon.com>
martin-gaievski pushed a commit to martin-gaievski/k-NN that referenced this pull request Mar 30, 2022
Signed-off-by: John Mazanec <jmazane@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancements Increases software capabilities beyond original client specifications
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants