DistX: High-performance vector database in Rust - 6x faster search than Qdrant

⚓ Rust    📅 2025-12-18    👤 surdeus    👁️ 4      

surdeus

I'm excited to share DistX, a vector database I've been building in Rust. It's designed for AI/ML workloads like semantic search, RAG pipelines, and recommendation systems.

Why Another Vector Database?

I wanted to combine:

  • Redis's simplicity - single binary, straightforward persistence model
  • Qdrant's API compatibility - drop-in replacement for existing code
  • Maximum performance - leveraging Rust's zero-cost abstractions

Performance Results

Benchmarked against Qdrant and Redis Stack on 5,000 128-dim vectors:

Metric DistX (gRPC) Qdrant (gRPC) Redis
Insert 0.05ms 0.22ms 0.52ms
Search 0.13ms 0.82ms 0.65ms

Key wins:

  • 6.3x faster search than Qdrant
  • 10x faster inserts than Redis
  • Sub-millisecond p99 latency

Technical Highlights

SIMD Optimizations:

  • AVX2 (x86_64) and NEON (ARM64) for vector distance calculations
  • 8-wide parallel processing with loop unrolling
  • Achieved near-theoretical throughput on M1/M2 Macs
// Example: NEON 8-wide dot product
unsafe fn dot_product_neon(a: &[f32], b: &[f32]) -> f32 {
    let mut sum1 = vdupq_n_f32(0.0);
    let mut sum2 = vdupq_n_f32(0.0);
    
    for i in (0..a.len()).step_by(8) {
        let a1 = vld1q_f32(a.as_ptr().add(i));
        let a2 = vld1q_f32(a.as_ptr().add(i + 4));
        let b1 = vld1q_f32(b.as_ptr().add(i));
        let b2 = vld1q_f32(b.as_ptr().add(i + 4));
        sum1 = vfmaq_f32(sum1, a1, b1);
        sum2 = vfmaq_f32(sum2, a2, b2);
    }
    // horizontal sum...
}

HNSW Index Optimizations:

  • Custom VisitedSet using bit vectors instead of HashSet - O(1) with minimal allocations
  • Contiguous vector storage for cache locality
  • Pre-allocated buffers to avoid per-search allocations

Concurrency:

  • parking_lot::RwLock for lock-free reads
  • Lock-free metrics with AtomicU64
  • Tokio for async I/O

Stack

  • REST API: actix-web
  • gRPC: tonic + prost
  • Storage: heed (LMDB bindings)
  • Serialization: serde + bincode

Try It

# Install from crates.io
cargo install distx

# Or download pre-built binary
curl -LO https://github.com/antonellof/DistX/releases/latest/download/distx-linux-x86_64.tar.gz

# Run
distx --http-port 6333 --grpc-port 6334

Links

Looking for Feedback

I'd love to hear your thoughts on:

  1. The SIMD implementation approach
  2. Any performance improvements I might have missed
  3. API design suggestions

This is my first major Rust project, so any feedback from the community would be invaluable!

1 post - 1 participant

Read full topic

🏷️ Rust_feed