Skip to content

Commit 5f97dfd

Browse files
fix(vector): Correct FAISS index training and search locking
This commit addresses two critical issues in the `faiss_manager.rs` file to improve correctness and performance. First, it fixes a bug where the FAISS index was not being trained before vectors were added. This is a required step for many index types (e.g., IVF) and would lead to runtime crashes. The code now checks if the index is trained and, if not, trains it on the first batch of vectors that meets the training threshold. Second, it resolves a performance bottleneck in concurrent search scenarios. The `search` function was taking a write lock on the index, which unnecessarily serialized all search operations. This has been changed to a read lock, allowing for concurrent searches and significantly improving throughput in multi-threaded environments.
1 parent 4dbc069 commit 5f97dfd

File tree

0 file changed

+0
-0
lines changed

    0 file changed

    +0
    -0
    lines changed

    0 commit comments

    Comments
     (0)