pub struct HnswConfig {
pub max_nb_connection: usize,
pub ef_construction: usize,
pub ef_search: usize,
pub max_layer: usize,
pub max_elements: usize,
}Expand description
Configuration for the HNSW vector index.
Controls the trade-off between index build time, memory usage, and search accuracy. The defaults are tuned for PulseDB’s target scale (10K-500K experiences per collective).
§Tuning Guide
| Use Case | M | ef_construction | ef_search |
|---|---|---|---|
| Low memory | 8 | 100 | 30 |
| Balanced | 16 | 200 | 50 |
| High recall | 32 | 400 | 100 |
Fields§
§max_nb_connection: usizeMaximum bidirectional connections per node (M parameter).
Higher values improve recall but increase memory and build time. Each node stores up to M links, so memory per node is O(M). Default: 16
ef_construction: usizeNumber of candidates tracked during index construction.
Higher values produce a better quality graph but slow down insertion. Rule of thumb: ef_construction >= 2 * max_nb_connection. Default: 200
ef_search: usizeNumber of candidates tracked during search.
Higher values improve recall but increase search latency. Must be >= k (the number of results requested). Default: 50
max_layer: usizeMaximum number of layers in the skip-list structure.
Lower layers are dense, upper layers are sparse “express lanes.” Default 16 handles datasets up to ~1M vectors with M=16. Default: 16
max_elements: usizeInitial pre-allocated capacity (number of vectors).
The index grows beyond this automatically, but pre-allocation avoids reallocations for known workloads. Default: 10_000
Trait Implementations§
Source§impl Clone for HnswConfig
impl Clone for HnswConfig
Source§fn clone(&self) -> HnswConfig
fn clone(&self) -> HnswConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HnswConfig
impl Debug for HnswConfig
Auto Trait Implementations§
impl Freeze for HnswConfig
impl RefUnwindSafe for HnswConfig
impl Send for HnswConfig
impl Sync for HnswConfig
impl Unpin for HnswConfig
impl UnsafeUnpin for HnswConfig
impl UnwindSafe for HnswConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more