Skip to content

Conversation

@el-yawd
Copy link

@el-yawd el-yawd commented Nov 19, 2025

Description

What began with a simple change to apply zero-copy on data end up in a saga.

This PR is entirely and unashamed based on the incredible crate hannoy, the intent with the rewrite is to make the vector core easier to work with, more performant (by reducing allocations and copies), and for free we gained future support for quantization and other distance methods. There is only three caveats:

  1. Hannoy uses u32 for vector ids, but we use u128 as a global id. To don't loose hannoy's optimizations I chose to map the "global" u128 to a "local" u32 id, and back-and-forth. Probably there is a better approach here, so any light on this is welcome.
  2. It doesn't support filtering search for now, I do plan to add it while in draft, but only after having a good "normal" search working.
  3. Again for performance reasons it switches the current vector representation from f64 to f32, since it seems to be the default approach among vector databases.

Checklist when merging to main

  • No compiler warnings (if applicable)
  • Code is formatted with rustfmt
  • No useless or dead code (if applicable)
  • Code is easy to understand
  • Doc comments are used for all functions, enums, structs, and fields (where appropriate)
  • All tests pass
  • Performance has not regressed (assuming change was not to fix a bug)
  • Version number has been updated in helix-cli/Cargo.toml and helixdb/Cargo.toml

@el-yawd el-yawd force-pushed the hnsw-fr branch 23 times, most recently from 18e3890 to 5a7bacc Compare November 25, 2025 00:45
@el-yawd el-yawd changed the base branch from main to rocks-impl November 25, 2025 02:02
@el-yawd el-yawd changed the base branch from rocks-impl to main December 4, 2025 12:57
@el-yawd el-yawd force-pushed the hnsw-fr branch 2 times, most recently from 6fafa00 to e064e1c Compare December 4, 2025 13:31
@el-yawd el-yawd marked this pull request as ready for review December 4, 2025 13:48
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 4, 2025

Skipped: This PR changes more files than the configured file change limit: (197 files found, 100 file limit)

@el-yawd el-yawd requested a review from Copilot December 4, 2025 17:26
the idea is to delay the HVector creation as much as possible, since its
creation is expensive
Still room for improvements since it does two allocations for vector :/
Yeah, this sucks. Althought the current approach incrementally rebuilds the index, it's way more expensive than it should
Only supports Cosine for now, but we definitely want to support more
distance methods
What's life but a collection of tests to pass?
get_item bound HVector to 'txn lifetime, doing zero-copy, but this
complicates some traversal operations. So now, when data is required, we
allocates using the arena and therefore binds HVector's lifetime to the
arena
@el-yawd
Copy link
Author

el-yawd commented Dec 11, 2025

@matthewsanetra wdyt?

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.

1 participant