The file-first model is ending. Kin is the first layer of what comes next. Learn more →
Back to Labs

KinDB

Alpha

Embedded Graph Engine for Code-Aware Tools

Purpose-built. Not general-purpose.

KinDB is an embeddable graph database built in Rust for code-aware tools. It provides sub-millisecond reads, concurrent readers with zero blocking, full-text search, vector similarity, and cryptographic integrity verification — all without a query language, a server process, or a JVM. It is the storage substrate that powers Kin and is designed to be usable independently by any Rust application that needs a fast, typed code graph.

Why Build a New Graph Database?

We evaluated KuzuDB, SurrealDB, CozoDB, Neo4j, and IndraDB. None of them could do all of this at once.

Sub-Millisecond Reads

HashMap-based adjacency lists with compiled Rust queries. No query language, no parsing, no interpretation. 50-170x faster than KuzuDB on trace and reference lookups.

Concurrent Readers, Zero Blocking

Read-Copy-Update pattern from the Linux kernel. Readers cheaply clone an Arc pointer and work with immutable data. Writers build new state in the background and atomically swap. Readers never wait.

Full-Text Search

Tantivy-powered full-text indexing of entity names, signatures, and file paths. Fuzzy matching with edit distance tolerance. Relevance-ranked results. All in-memory, zero disk I/O during searches.

Vector Similarity Search

HNSW index via usearch with SIMD optimization. Optional GPU acceleration on Metal (Apple Silicon) and CUDA. Sub-millisecond search over millions of vectors. "Find code that looks like this" becomes a graph operation.

Incremental Indexing

File-level change detection via SHA-256 hashes. Only modified files trigger re-indexing. A 500K-entity repo with 10 changed files re-indexes in under 30 seconds — down from 1.8 hours with KuzuDB.

Cryptographic Integrity

Merkle DAG verification with content-addressed hashing. Detect tampering at the entity, relation, or sub-graph level. O(k) verification where k is the number of nodes in the sub-graph being checked.

Architecture

Four layers, each independently useful. 7,200 lines of Rust.

Graph Engine

In-memory adjacency lists with secondary indexes (name, file, kind). Pattern matching with wildcards. BFS/DFS traversal, downstream impact analysis, and dead code detection. Parallel scanning via rayon.

Search & Vectors

Tantivy full-text index + HNSW vector index + local BERT embeddings (384-dimensional, BGE-small-en). Auto-detects Metal/CUDA/CPU. Batch embedding support for GPU parallelization.

Snapshot Manager

RCU-based persistence with atomic writes. Write to temp file, fsync, atomic rename. Crash-safe by construction. OS-level file locking prevents concurrent writers. Backward-compatible format versioning (v1 → v3).

Tiered Storage

Auto-detects available RAM. Small graphs load fully into memory. Large graphs stay memory-mapped with OS page cache handling hot/cold tiering automatically. Zero manual eviction policy.

Performance

Measured against KuzuDB on real codebases.

Operation KuzuDB KinDB Improvement
kin trace 5-30ms <1ms 50x faster
kin search 10-50ms <1ms 50x faster
kin refs 50-170ms <1ms 170x faster
kin commit (3K entities, fresh) 38s <5s 7.6x faster
kin commit (500K entities, incremental) 1.8 hours <30s 216x faster
Concurrent reads during write Blocked Yes
Memory (500K entities) 3.8 GB on disk ~200 MB in-memory 19x smaller

Scale Projections

zod

3,199 entities → ~1 MB in memory

vscode

~213K entities → ~43 MB in memory

kubernetes

~533K entities → ~107 MB in memory

chromium

~3.8M entities → ~768 MB in memory

linux kernel

~4.3M entities → ~853 MB in memory

Quick Start

terminal

# Prerequisites: Rust 1.75+

$ git clone https://github.com/firelock-ai/kin-db.git

$ cd kin-db && cargo build --release

# Run tests

$ cargo test

  29 tests passed

# Run benchmarks

$ cargo bench

How KinDB Fits

Three layers, each building on the one below.

Watch the GitHub repository to get notified of new releases.

Watch on GitHub