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

Remove overallocation in faiss query path #501

Merged
merged 2 commits into from
Aug 8, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions jni/src/faiss_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,8 @@ jobjectArray knn_jni::faiss_wrapper::QueryIndex(knn_jni::JNIUtilInterface * jniU
throw std::runtime_error("Invalid pointer to index");
}

int dim = jniUtil->GetJavaFloatArrayLength(env, queryVectorJ);
std::vector<float> dis(kJ * dim);
std::vector<faiss::Index::idx_t> ids(kJ * dim);
std::vector<float> dis(kJ);
std::vector<faiss::Index::idx_t> ids(kJ);
Comment on lines +197 to +198
Copy link
Collaborator

Choose a reason for hiding this comment

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

add a comment on top of this change what it is doing and why it is required.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added the comment.

float* rawQueryvector = jniUtil->GetFloatArrayElements(env, queryVectorJ, nullptr);

try {
Expand Down