Building a Sub-Millisecond Vector Database in Rust/WASM

Published: (December 12, 2025 at 05:41 PM EST)
2 min read
Source: Dev.to

Source: Dev.to

Overview

EdgeVec is a high‑performance vector database that runs entirely in the browser using WebAssembly. It achieves sub‑millisecond search times, making client‑side semantic search, RAG, and recommendation feasible without a server.

Performance

VectorsFloat32 SearchQuantized (SQ8) Search
10 k203 µs88 µs
50 k480 µs167 µs
100 k572 µs329 µs

These latencies are comparable to server‑side solutions while running completely client‑side.

Implementation Details

Algorithm

EdgeVec uses Hierarchical Navigable Small World (HNSW) graphs, the same algorithm employed by production vector databases such as Weaviate and Qdrant.

Quantization

Instead of storing 32‑bit floats (768 dimensions × 4 bytes ≈ 3 KB per vector), vectors are compressed to 8‑bit integers. This yields a 3.6× memory reduction with minimal impact on accuracy.

SIMD Optimization

  • Native (x86_64): AVX2 instructions
  • WebAssembly: simd128 where available

Rust’s portable SIMD is used to vectorize distance calculations, delivering the sub‑millisecond query times shown above.

Build Size

Compiled with wasm-pack, the final bundle is only 148 KB gzipped, small enough for any web application.

Where Client‑Side Vector Search Makes Sense

  • Privacy – embeddings never leave the device.
  • Latency – zero network round‑trip.
  • Offline – works without an internet connection.
  • Cost – eliminates server expenses.

Ideal for browser extensions, local‑first apps, and privacy‑preserving RAG pipelines.

Usage Example

import init, { EdgeVec, EdgeVecConfig } from 'edgevec';

await init();

const config = new EdgeVecConfig(768);
const index = new EdgeVec(config);

// Insert a vector
index.insert(new Float32Array(768).fill(0.1));

// Perform a search
const results = index.search(query, 10);
// results: [{ id: 0, score: 0.0 }, ...]

Resources

  • GitHub:
  • npm: npm install edgevec

Alpha release – feedback welcome!

Back to Blog

Related posts

Read more »

The Vibe Coding Paradox

My last PR for Nudges was +96 −312, touched 38 files, and was about 90 % vibe‑coded. I’m confident in it. While I was gliding through Hyrule, two different AI a...

Printable Flashcard Generator

Introduction Are you a visual learner? Have you ever used image‑based flashcards to memorize words or concepts more effectively? If so, you might find this pro...