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

fix: Don't crash on reaching hnsw capacity #2046

Merged
merged 2 commits into from
Oct 20, 2023

Conversation

dranikpg
Copy link
Contributor

Fixes a bug with hnsw crashing when overstepping the initial limit

@dranikpg dranikpg requested a review from kostasrim October 20, 2023 13:59
kostasrim
kostasrim previously approved these changes Oct 20, 2023
@@ -163,6 +163,8 @@ struct HnswlibAdapter {
}

void Add(float* data, DocId id) {
if (world_.cur_element_count + 1 >= world_.max_elements_)
world_.resizeIndex(max(world_.cur_element_count * 2, world_.cur_element_count + 5));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

um why + 5 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Contributor Author

@dranikpg dranikpg Oct 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid pointless rebuilds with low sizes because they're costly. But actually let's just grow like a basic vector, I don't assume anyone will specify low values at all

Signed-off-by: Vladislav Oleshko <[email protected]>
@dranikpg dranikpg merged commit 4a2dd30 into dragonflydb:main Oct 20, 2023
7 checks passed
@dranikpg dranikpg deleted the search-vec-resize branch November 9, 2023 09:18
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

Successfully merging this pull request may close these issues.

2 participants