From f37509213bcf7374d78faa4207dd1a8afdcd41db Mon Sep 17 00:00:00 2001 From: Yukikaze-CZR <48198922+Yukikaze-CZR@users.noreply.github.com> Date: Tue, 10 Dec 2019 16:47:35 +0800 Subject: [PATCH] Add log to debug #678 (#733) * Add log to debug #678 * Rename nsg_mix to RNSG in C++ sdk #735 * [skip ci] change __function__ --- .../index/vector_index/FaissBaseIndex.cpp | 1 + .../index/thirdparty/faiss/gpu/impl/IVFFlat.cu | 16 +++++++++++++++- core/src/sdk/examples/utils/Utils.cpp | 2 +- core/src/sdk/include/MilvusApi.h | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/core/src/index/knowhere/knowhere/index/vector_index/FaissBaseIndex.cpp b/core/src/index/knowhere/knowhere/index/vector_index/FaissBaseIndex.cpp index 8fce37a81e..1ab0301a8d 100644 --- a/core/src/index/knowhere/knowhere/index/vector_index/FaissBaseIndex.cpp +++ b/core/src/index/knowhere/knowhere/index/vector_index/FaissBaseIndex.cpp @@ -70,6 +70,7 @@ FaissBaseIndex::SealImpl() { faiss::Index* index = index_.get(); auto idx = dynamic_cast(index); if (idx != nullptr) { + KNOWHERE_LOG_DEBUG << "Test before to_readonly:" << " IVF READONLY " << std::boolalpha << idx->is_readonly(); idx->to_readonly(); } #endif diff --git a/core/src/index/thirdparty/faiss/gpu/impl/IVFFlat.cu b/core/src/index/thirdparty/faiss/gpu/impl/IVFFlat.cu index 404a2d8603..41a5c3c0e1 100644 --- a/core/src/index/thirdparty/faiss/gpu/impl/IVFFlat.cu +++ b/core/src/index/thirdparty/faiss/gpu/impl/IVFFlat.cu @@ -24,6 +24,7 @@ #include #include #include +#include namespace faiss { namespace gpu { @@ -70,12 +71,14 @@ IVFFlat::copyCodeVectorsFromCpu(const float* vecs, // list; the length is in sizeof(char) FAISS_ASSERT(deviceData_->size() + lengthInBytes <= std::numeric_limits::max()); + std::chrono::high_resolution_clock::time_point time1 = std::chrono::high_resolution_clock::now(); deviceData_->append((unsigned char*) vecs, lengthInBytes, stream, true /* exact reserved size */); + std::chrono::high_resolution_clock::time_point time2 = std::chrono::high_resolution_clock::now(); copyIndicesFromCpu_(indices, list_length); - + std::chrono::high_resolution_clock::time_point time3 = std::chrono::high_resolution_clock::now(); maxListLength_ = 0; size_t listId = 0; @@ -94,6 +97,7 @@ IVFFlat::copyCodeVectorsFromCpu(const float* vecs, pos += size; ++ listId; } + std::chrono::high_resolution_clock::time_point time4 = std::chrono::high_resolution_clock::now(); deviceListDataPointers_ = hostPointers; @@ -102,6 +106,16 @@ IVFFlat::copyCodeVectorsFromCpu(const float* vecs, if (stream != 0) { streamWait({stream}, {0}); } + std::chrono::high_resolution_clock::time_point time5 = std::chrono::high_resolution_clock::now(); + + double span1 = (std::chrono::duration(time2 - time1)).count(); + double span2 = (std::chrono::duration(time3 - time2)).count(); + double span3 = (std::chrono::duration(time4 - time3)).count(); + double span4 = (std::chrono::duration(time5 - time4)).count(); + std::cout << "Span1: " << span1 * 0.001 << "ms" << std::endl; + std::cout << "Span2: " << span2 * 0.001 << "ms" << std::endl; + std::cout << "Span3: " << span3 * 0.001 << "ms" << std::endl; + std::cout << "Span4: " << span4 * 0.001 << "ms" << std::endl; } void diff --git a/core/src/sdk/examples/utils/Utils.cpp b/core/src/sdk/examples/utils/Utils.cpp index 3d26dce77b..98028675c7 100644 --- a/core/src/sdk/examples/utils/Utils.cpp +++ b/core/src/sdk/examples/utils/Utils.cpp @@ -94,7 +94,7 @@ Utils::IndexTypeName(const milvus::IndexType& index_type) { return "IVFFLAT"; case milvus::IndexType::IVFSQ8: return "IVFSQ8"; - case milvus::IndexType::NSG: + case milvus::IndexType::RNSG: return "NSG"; case milvus::IndexType::IVFSQ8H: return "IVFSQ8H"; diff --git a/core/src/sdk/include/MilvusApi.h b/core/src/sdk/include/MilvusApi.h index e631be36be..4abdf31357 100644 --- a/core/src/sdk/include/MilvusApi.h +++ b/core/src/sdk/include/MilvusApi.h @@ -35,7 +35,7 @@ enum class IndexType { FLAT = 1, IVFFLAT = 2, IVFSQ8 = 3, - NSG = 4, + RNSG = 4, IVFSQ8H = 5, IVFPQ = 6, SPTAGKDT = 7,