Show HN: VennDB: append-only in-memory Rust DB for rows queried using bit flags ...
HN Best 200 @best
Show HN: VennDB: append-only in-memory Rust DB for rows queried using bit flags github.com · 15 points · 1 comments · HN thread
TL;DR VennDB is a Rust crate that derives an append-only, in-memory database from a named-field struct, where rows are queried by bit-flag (bool) columns and filter-map values using set intersections. The README benchmarks it against a hand-written roaring bitmap index, an in-memory SQLite table and a plain Vec, reporting it fastest on most filter queries at 100k and 1M rows. The single comment is from the author, who describes it as a narrow bitmap index generated from a struct and asks for feedback on the benchmarks.
- Designed for mostly static data loaded at startup and then queried constantly with simple filters on bool and filter-map columns.
- A #[derive(VennDB)] macro generates a database type and a query builder; bools become bitmasks and filter values map to sets of rows, and a query is their intersection.
- Supports keys (unique, non-optional lookup), validators on append, optional filters, set-valued filters and a random pick of matching rows via any() without enumerating all matches.
- Benchmarks on an Apple M4 Max: at 100k rows, venn does 3 bool filters in about 247 ns versus 1.57 µs for roaring, 653.7 µs for naive and 4.1 ms for SQLite; at 1M rows, roaring is faster on a few multi-filter queries are not clearly ahead.
- Has no dependencies beyond the core crate, uses #![forbid(unsafe_code)], MSRV 1.96, dual MIT/Apache-2.0 license, and was built for the rama proxy project.
- The author says it is not a general database and should not replace one; version 0.7 rewrote the engine.
Discussion The thread is a single comment from the author introducing the project and its motivation, with no replies from other commenters at the time of the snapshot. The author explains it began as part of the rama proxy project, where a random matching upstream proxy is picked per request, and frames VennDB as a narrow bitmap index rather than a database. The tone is modest and asks for corrections to the benchmarks and pointers to prior art.
- Narrow bitmap index generated from a struct, not a real database (a few): The author argues VennDB fills a niche for read-mostly, flag-filtered data that would otherwise go to an in-memory database, while explicitly saying it should not replace database needs. No other commenter has responded yet.
- Benchmarks may be unfair and need outside review (a few): The author admits they are not database or hardware experts and invites scrutiny of the benchmark methodology and any prior art that was missed.
#rust #inMemoryDatabase #bitmapIndex #benchmarks #showHN #opensource