milvus-io / knowhere

Knowhere is an open-source vector search engine, integrating FAISS, HNSW, etc.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[bug]: [main branch]nq is 30, IVF_SQ index, multi-threaded concurrent search, unstable results

elstic opened this issue · comments

commented

case:

pytest test_ivf.py::TestIvf::test_ivf_async --data_type glove

case branch:feature-2.0
case repo: knowhere-test

param:

nlist: 1024
metric_type:IP
dim : 200
top_k :  1
nq : 30
nprobes: [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]    (Rotation training)
glove dataset

50 thread counts, search appears 3 times search results and serial inconsistency
log:

I20230522 17:27:57.307876   896 factory.cc:20] [KNOWHERE][Create][pytest] create knowhere index IVFSQ

------------------------------ Captured log call -------------------------------

INFO     root:test_ivf.py:489 **********IVFSQ test_ivf_async **********

INFO     root:test_ivf.py:491 hdf5 dataset: <HDF5 file "glove-200-angular.hdf5" (mode r)>

ERROR    root:test_ivf.py:529 result id error, nprobe:1 

ERROR    root:test_ivf.py:530 [[ 863946]

 [   5069]

 [1077727]

 [ 104732]
……

 [ 666531]

 [1139159]]

ERROR    root:test_ivf.py:529 result id error, nprobe:1 

ERROR    root:test_ivf.py:530 [[ 863946]

 [   5069]

 [1077727]
…… 

ERROR    root:test_ivf.py:529 result id error, nprobe:128 

ERROR    root:test_ivf.py:530 [[ 863946]

 [   5069]

 [1077727]

……

commented

/assign @cydrain

caused by this PR:

commit d21966f63f7f451b9e4f078bc2a1976b6d6c9fc9
Author: zh Wang <rekind133@outlook.com>
Date:   Tue May 16 09:19:18 2023 +0800
    Release python GIL when calling C++ (#848)
    Signed-off-by: zh Wang <rekind133@outlook.com>

Hi @elstic, you can change your script in this way, this case will pass.

diff --git a/tests/test_ivf.py b/tests/test_ivf.py
index 11204ff..1a81a08 100644
--- a/tests/test_ivf.py
+++ b/tests/test_ivf.py
@@ -547,10 +547,14 @@ class TestIvf:
         else:
             logging.info(f"{index} thread safety start")
             num = 50
+            ts = []
             for i in range(num):
                 logging.info(f"thread number: {i}")
                 t = threading.Thread(target=ivf_search_async)
                 t.start()
+                ts.append(t)
+            for t in ts:
+                t.join()
             logging.info(f"{index} thread num: {num}")
commented

Hi @elstic, you can change your script in this way, this case will pass.

diff --git a/tests/test_ivf.py b/tests/test_ivf.py
index 11204ff..1a81a08 100644
--- a/tests/test_ivf.py
+++ b/tests/test_ivf.py
@@ -547,10 +547,14 @@ class TestIvf:
         else:
             logging.info(f"{index} thread safety start")
             num = 50
+            ts = []
             for i in range(num):
                 logging.info(f"thread number: {i}")
                 t = threading.Thread(target=ivf_search_async)
                 t.start()
+                ts.append(t)
+            for t in ts:
+                t.join()
             logging.info(f"{index} thread num: {num}")

okay, I'll add the thread release code