Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Meta Engineering 3 min read Research hardMaster

Ribbon filter: Practically smaller than Bloom and Xor

Ribbon filters are a static (immutable) alternative to Bloom filters that save roughly a third of memory, with space overhead as low as 1 percent above the information-theoretic bound versus Bloom's roughly 50 percent, while keeping O(1) queries. They are built by solving a GF(2) linear system over hashed keys using a near-band "ribbon" coefficient matrix from Dietzfelbinger and Walzer. A new on-the-fly Gaussian elimination solver (Rapid Incremental Boolean Banding ON the fly) works much like insertion into a linear-probed hash table, doing row reductions in registers. Like Bloom filters, Ribbon offers near-continuous configurability with no bit-alignment hazards, and Meta expects it to save several percent of RAM in major storage systems at a small CPU cost.

Assumes: Bloom filtersGaussian eliminationhashing basics

Related posts

  • Space efficient machine learning feature stores using probabilistic data structures - a benchmark

    Zalando Engineering mediumAdept

    A Bloom-filter-backed in-process feature store matched a conventional key-value feature store's click-prediction accuracy (AUC ≈0.7997 vs ≈0.80) using about 3% of the memory (470MB vs 15GB). It kept 90% of the history uplift at roughly 40MB, with no measurable throughput cost. Features are stored as composite user^value keys and reconstructed by probing every possible value, so false positives inject tunable noise in exchange for space. The approach suits cases where an extra network call or many lookups per request are too expensive. It is not a drop-in replacement, though: you must know the full feature domain, high-volume real-time updates must hit every node, and deletions or expiry require rebuilding the filter from scratch.

  • Don’t stop early: Case-folding source code at memory speed

    GitHub Engineering hardMaster

    GitHub's Blackbird code search case-folds every byte of 480TB of source, and the fastest ASCII path came from removing the early exit at the first non-ASCII byte. A branchless sweep that ORs bytes into an accumulator and lowercases arithmetically lets LLVM vectorize to over 45 GiB/s on an Apple M4, versus 3.1 GiB/s for the naive break loop. A two-pass chunked scan reaches about 23 GiB/s, and branchless code without vectorization is actually slower. The open-source Rust crate casefold also avoids heap allocation by reusing the input buffer. For non-ASCII text, it rejects non-folding characters with a 64-code-point page bitmap read straight from UTF-8 lead bytes, and run-length/stride-encoded fold ranges shrink Unicode's 1484 simple folds to 1776 bytes.

  • Approximate nearest neighbor search with DiskANN in libSQL

    Turso mediumAdept

    libSQL implements approximate nearest neighbor search using LM-DiskANN, a low-memory variant of DiskANN. The index is wired into SQLite's indexing system through a new OpenVectorIdx bytecode instruction, so inserts update the vector index automatically. Each node is stored on disk as a fixed-size block holding its full vector plus its neighbors' IDs and compressed vectors. That layout lets best-first graph search make local decisions without extra I/O, trading extra storage for lower memory use. Queries go through a vector_top_k virtual table, and early 1-bit binary quantization with Hamming distance is in place to cut index size further.

  • Engineering stories behind the Medium Daily Digest Algorithm: Part 2

    Medium Engineering mediumAdept

    Medium replaced the Bloom filters behind its recommendation filters (muted writers, already-read, presented 3+ times) with per-user DynamoDB queries against the source-of-truth tables, cutting filtering cost roughly 10x and simplifying maintenance. The Bloom filters had grown huge because entries can't be deleted, so unmutes couldn't be reflected, contents couldn't be inspected for debugging, and derived data drifted from the database. Fetching all muted writers per user is cheap because most users mute no one. For the presentation counter, which had been hacked together from three layered Bloom filters, a best-effort query of the most recent 5k presentations (~100ms) is acceptable because the 3-presentation limit is a soft rule.

  • The space complexity of vector indexes in LibSQL

    Turso mediumAdept

    LibSQL's built-in vector index uses LM-DiskANN, a disk-oriented graph ANN algorithm that stores neighbor graphs in shadow tables. That storage can inflate database size sharply: one mobile app grew from 3.5 MB to 50 MB, with a single index taking 19 MB. Compressing neighbor vectors to float8 shrank the index about 3x, and also cutting max_neighbors from the default (~3·sqrt(dim), about 70 for 512-dim vectors) to 20 gave about an 8x reduction. On a dataset under 1,000 nodes, top-k results matched the default index exactly. Recall may drift on datasets above roughly 10,000 vectors.

The quest for software engineering knowledge.

Look:
Layout: