Merge pull request #521 from tinkerlin/issue-465

Fix Issue 465
This commit is contained in:
Jin Hai 2019-11-25 23:09:52 +08:00 committed by GitHub
commit 88ca2c805f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 35 deletions

View File

@ -20,6 +20,7 @@ Please mark all change in change log and use the ticket from JIRA.
- \#440 - Query API in customization still uses old version
- \#440 - Server cannot startup with gpu_resource_config.enable=false in GPU version
- \#458 - Index data is not compatible between 0.5 and 0.6
- \#465 - Server hang caused by searching with nsg index
- \#486 - gpu no usage during index building
- \#513 - Unittest DELETE_BY_RANGE sometimes failed

View File

@ -56,7 +56,7 @@ while getopts "p:d:t:f:ulrcgjhxzme" arg; do
USE_JFROG_CACHE="ON"
;;
x)
CUSTOMIZATION="OFF" # force use ori faiss
CUSTOMIZATION="ON"
;;
g)
GPU_VERSION="ON"

View File

@ -17,6 +17,7 @@
#include <iostream> // TODO(linxj): using Log instead
#include "knowhere/common/Log.h"
#include "knowhere/common/Timer.h"
namespace knowhere {
@ -51,30 +52,18 @@ TimeRecorder::PrintTimeRecord(const std::string& msg, double span) {
std::cout << str_log << std::endl;
break;
}
// case 1: {
// SERVER_LOG_DEBUG << str_log;
// break;
//}
case 1: {
KNOWHERE_LOG_DEBUG << str_log;
break;
}
// case 2: {
// SERVER_LOG_INFO << str_log;
// break;
//}
// KNOWHERE_LOG_TRACE << str_log;
// break;
// }
// case 3: {
// SERVER_LOG_WARNING << str_log;
// break;
//}
// case 4: {
// SERVER_LOG_ERROR << str_log;
// break;
//}
// case 5: {
// SERVER_LOG_FATAL << str_log;
// break;
//}
// default: {
// SERVER_LOG_INFO << str_log;
// break;
//}
// KNOWHERE_LOG_WARNING << str_log;
// break;
// }
}
}

View File

@ -718,29 +718,38 @@ NsgIndex::Search(const float* query, const unsigned& nq, const unsigned& dim, co
int64_t* ids, SearchParams& params) {
std::vector<std::vector<Neighbor>> resset(nq);
TimeRecorder rc("search");
if (nq == 1) {
params.search_length = k;
TimeRecorder rc("NsgIndex::search", 1);
// TODO(linxj): when to use openmp
if (nq <= 4) {
GetNeighbors(query, resset[0], nsg, &params);
} else {
//#pragma omp parallel for schedule(dynamic, 50)
#pragma omp parallel for
for (unsigned int i = 0; i < nq; ++i) {
// TODO(linxj): when to use openmp
auto single_query = query + i * dim;
GetNeighbors(single_query, resset[i], nsg, &params);
}
}
rc.ElapseFromBegin("cost");
rc.RecordSection("search");
for (unsigned int i = 0; i < nq; ++i) {
for (unsigned int j = 0; j < k; ++j) {
// ids[i * k + j] = resset[i][j].id;
// Fix(linxj): bug, reset[i][j] out of range
ids[i * k + j] = ids_[resset[i][j].id];
dist[i * k + j] = resset[i][j].distance;
int64_t var = resset[i].size() - k;
if (var >= 0) {
for (unsigned int j = 0; j < k; ++j) {
ids[i * k + j] = ids_[resset[i][j].id];
dist[i * k + j] = resset[i][j].distance;
}
} else {
for (unsigned int j = 0; j < resset[i].size(); ++j) {
ids[i * k + j] = ids_[resset[i][j].id];
dist[i * k + j] = resset[i][j].distance;
}
for (unsigned int j = resset[i].size(); j < k; ++j) {
ids[i * k + j] = -1;
dist[i * k + j] = -1;
}
}
}
rc.RecordSection("merge");
//>> Debug: test single insert
// int x_0 = resset[0].size();