fix(python): parallelize small high-dimensional query/add batches - #671
Open
chakshu-dhannawat wants to merge 1 commit into
Open
fix(python): parallelize small high-dimensional query/add batches#671chakshu-dhannawat wants to merge 1 commit into
chakshu-dhannawat wants to merge 1 commit into
Conversation
The rows-only threshold disabled multithreading whenever the batch size was below 4 * num_threads, ignoring vector dimension. For high-dimensional vectors, even a small batch has enough per-vector work to benefit from threads. Switch the heuristic to total scalar work (rows * dim). This preserves the existing serialization behavior for low-dimensional vectors while allowing high-dimensional queries/adds to use multiple threads. Closes nmslib#667. Signed-off-by: Awsheshmac <sharuma.aushieshu@otsuka-shokai.co.jp>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #667.
The current Python bindings disabled multithreading whenever the input batch was smaller than 4 * num_threads, regardless of vector dimension. For high-dimensional vectors the per-query work is large enough that serial execution wastes cores.
This change replaces the rows-only threshold with a total-scalar-work threshold (rows * dim). It keeps the existing serialization behavior for low-dimensional vectors while letting small high-dimensional batches use multiple threads.
Changes:
Tested: python -m unittest discover --start-directory tests/python --pattern "bindings_test*.py" => 15 tests passed.