memista vs hnsw_rs
hnsw_rs is a pure-Rust HNSW
implementation. memista wraps USearch — a C++/Rust HNSW implementation —
behind an HTTP server and a SQLite metadata layer. Both target Rust
developers who want vector search inside their own binary; the two
projects make different trade-offs about scope.
| dimension | memista 0.1.x | hnsw_rs (jean-pierreBoth/hnswlib-rs) |
|---|---|---|
| Index implementation | USearch (C++ core, Rust bindings) | pure Rust |
| Layer | Library + HTTP service | Library only |
| Vectors per leaf | n/a (multi: true) | configurable |
| Distance trait | MetricKind enum (IP, Cosine, L2, …) — IP in memista | Distance trait, user-implementable |
| Generic over scalar type | F32 only in memista (USearch supports more) | generic via the Distance trait |
| Metadata storage | SQLite WAL, joined automatically | none — you bring your own |
| Persistence | <db_id>.usearch file (USearch native format) | dump / reload (its own format) |
| HTTP server | yes (Actix-web) | no |
| OpenAPI | yes (apistos) | no |
| SIMD | yes via simsimd feature | yes, hand-written in some metrics |
| Parallelism | Tokio runtime + Rayon dep declared | Rayon-based parallel insert / search |
| Multi-tenant | by database_id | one index per Hnsw<T,D> instance |
| Async-friendly | core is sync, wrapped in async handlers | sync core |
| License | GPL-3.0 | MIT/Apache-2.0 (typical for the crate) |
| Maturity | experimental per README | mature, widely used |
Where the two crates actually differ
Implementation language. hnsw_rs is pure Rust. USearch is C++ with Rust
bindings. For most users this is invisible. For users who care about a
fully-Rust dependency tree (no cc linker, no cmake, easier
cross-compilation to esoteric targets), hnsw_rs wins by construction.
Distance metrics. hnsw_rs lets you implement a Distance trait for
your own type. You can put f16 vectors, integer vectors, packed bit
vectors, anything you can compute a distance over. memista accepts
Vec<f32> and computes inner product. The flexibility difference is real.
Service shape. This is the largest difference. hnsw_rs is a pure library — you build the index, you query it, you save it, you load it. memista hands you a working HTTP server with three REST endpoints and four flavours of generated documentation, and a SQLite database wired up to store the text that produced each vector. If your application already has a service skeleton you’re embedding in, hnsw_rs is the cleaner choice. If you want a single binary that runs vector search end-to-end, memista is the shorter path.
Multi-tenancy. memista’s database_id partitioning is a real
ergonomic feature for SaaS-shaped workloads — each tenant gets isolated
storage by name, with no extra code. hnsw_rs leaves this entirely to you;
you’d hold a HashMap<TenantId, Hnsw<...>> or one process per tenant.
Tuning surface. hnsw_rs gives you M, ef_construction, ef_search,
and the max-layer parameter directly. memista currently passes 0 for
connectivity, expansion_add, and expansion_search, meaning you get
USearch’s defaults. To tune, you fork the load_or_create_index helper.
For workloads where recall vs. latency tuning matters, hnsw_rs is more
honest about asking you to choose.
Where they agree
Both are embeddable. Both are HNSW. Both will give you sub-millisecond queries on a hundred-thousand-vector index on a laptop. Both ship as a single Cargo dependency. Both persist to disk.
If your workload is small enough that the algorithmic choices don’t matter — and on embeddable workloads, that’s often the case — the choice comes down to whether you want a library or a service.
When to pick hnsw_rs
- You want a fully-Rust dependency tree.
- You need custom distance metrics or custom vector types.
- You want fine-grained control over HNSW parameters from day one.
- You are embedding inside an existing service that already has its own storage and HTTP layer.
- You need a permissively-licensed (MIT / Apache-2.0) HNSW crate.
When to pick memista
- You want an HTTP service for vector search and you want it now.
- You want SQLite-joined metadata without writing that layer.
- You want multi-tenant partitioning by string ID for free.
- You are prototyping a RAG demo and want OpenAPI docs in the box.
- You are willing to fork the
IndexOptionssetup to escape the hardcodeddimensions: 2and tune HNSW parameters. - You accept GPL-3.0 for your downstream.
The honest summary
hnsw_rs is the right choice for serious, library-shaped Rust vector
search work where you want control. memista is the right choice for
“I want a vector-search service in one cargo install.” They are not
the same project, and the comparison is largely a comparison of scope.
Sources: memista’s src/lib.rs and Cargo.toml in this repository;
hnsw_rs documentation at https://crates.io/crates/hnsw_rs.