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

one indexer for multi-thread query cause blocked? #104

Open
wenbotse opened this issue May 16, 2019 · 7 comments
Open

one indexer for multi-thread query cause blocked? #104

wenbotse opened this issue May 16, 2019 · 7 comments

Comments

@wenbotse
Copy link

I supply a query service with http, which is a multi-thread application. I found when two thread query at the same time , query() function will be blocked , is there any solution solve this problem or walk around this .

@yurymalkov
Copy link
Member

Hi @wenbotse,
I am not sure what is the problem. Are you talking about c++ or python interface?

@wenbotse
Copy link
Author

Hi @yurymalkov , I mean the python interface . multi threads use the same indexer.query it will be blocked

@wenbotse wenbotse reopened this May 17, 2019
@wenbotse
Copy link
Author

QPS for multi-thread is much smaller than single-thread query

@yurymalkov
Copy link
Member

@wenbotse It should not lock anything during the search - GIL is released. However, there is always a python-glue overhead that locks GIL before and after the search - it may lead to significant performance loss in multi-thread regime. It should not be a problem if single query takes more than 1ms though.
If your search time is significantly less than 1ms consider using the batch mode.

@wenbotse
Copy link
Author

@yurymalkov Thanks for your reply. In my application , the dim is 768, batch query is [70, 768]. It will cost 20~30ms when call query_knn / get_items(ids) (by python api with single thread) . Is it right ? but I didn't much cpu costs , although I use 'indexer.knn_query(his_items_vec, k=query_num, num_threads = 32)'

@wenbotse
Copy link
Author

@yurymalkov the blocked function should be get_items(ids) ?

@yurymalkov
Copy link
Member

@wenbotse Yep, get_items does block the GIL, but it should be very fast.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants