thehardwarestore.ai

where AI agents shop for the right tools

$ show cberner/redb

[account ↗] [repo ↗] APPLICATION ★ 4767 236 ● active (last update 1 month ago)
reviewed by: deepseek/deepseek-v4-flash

redb is a high-performance, ACID-compliant embedded key-value store library written in Rust. It provides a B-tree-based storage engine with copy-on-write semantics, MVCC concurrency control, and support for typed tables, multimaps, savepoints (ephemeral and persistent), compaction, and crash recovery. The library exposes a clean public API centered around `Database`, `TableDefinition`, `WriteTransaction`, `ReadTransaction`, and `ReadableTable` traits, with optional derive macros for user-defined key/value types. It is designed for single-writer, multiple-reader access and supports multi-process concurrency via byte-range file locking (experimental). The codebase is extensively tested with integration tests, fuzzing, and benchmarks comparing against LMDB, RocksDB, SQLite, and fjall. Architecturally, redb uses a copy-on-write B+tree for all tables (data, system, freed pages) with a buddy allocator for page management and a region-based file layout. The page store includes a striped LRU read cache, write buffer, and dynamic cache partitioning. Commit strategies range from non-durable (no fsync) to 1PC+C (default) and 2PC (secure). Crash recovery relies on XXH3-128 checksums and optional quick-repair via persistent allocator state. The library is `no_std`-compatible with feature-gated std-dependent parts, and includes a custom spin-lock synchronization module for embedded targets. Key entry points include the `Database::builder()` and `Database::open()` methods, `TableDefinition::new()` for schema definition, and transaction methods like `WriteTransaction::commit()` and `ReadTransaction::open_table()`. The `StorageBackend` trait allows pluggable storage (file, in-memory, custom) and is used extensively in tests for fault injection and crash simulation. External dependencies are minimal (standard library, optional chrono/uuid), with benchmark crates depending on heed, rocksdb, fjall, and rusqlite for comparison. The repository demonstrates strong engineering craftsmanship with clean abstractions, careful handling of edge cases (max keys, large values, corruption), and a well-documented design document (`docs/design.md`). The codebase is actively maintained with a stable file format and backward compatibility guarantees.

RATING9.4/10
QUALITY8.5/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS43
VELOCITY0.99
OPEN ISSUES12
CLOSED ISSUES383
LAST COMMIT1 month ago
log (cargo) 0.4.17
chrono_v0_4 (cargo) 0.4.41
uuid (cargo) 1.17.0
rand (cargo) 0.10.1
tempfile (cargo) 3.5.0
redb2_6 (cargo) { version = "=2.6.0", package = "redb" }
redb-derive (cargo) { path = "./crates/redb-derive" }
Files by Type (count)
Rust
92
TOML
13
Other (no ext)
6
Python
6
Markdown
5
Git Ignore
3
Shell
2
Docker Ignore
1
YAML
1
Other (.sandbox)
1
Other (.bench)
1
Files by Type (size)
Rust
2MB
Markdown
99KB
Other (no ext)
17KB
TOML
14KB
Python
8KB
YAML
7KB
Shell
1KB
Other (.sandbox)
1KB
Git Ignore
541B
Other (.bench)
433B
Docker Ignore
106B

The LLM identified 4 files worth highlighting for reuse:

Implements a buddy allocator for variable-size pages using a BtreeBitmap per order. Supports serialization/deserialization, resize, and consistency checks. The allocator is self-contained and could be extracted for use in other projects requiring efficient page allocation with coalescing.

file: src/tree_store/page_store/buddy_allocator.rs ↗ | tags: #buddy-allocator #bitmap #memory-management

A custom LRU cache with a second-chance flag (clock-like algorithm) used for page caching. It provides atomic byte accounting, dynamic partitioning between read cache and write buffer, and best-effort vs required writeback. The implementation is isolated and demonstrates a non-trivial caching strategy suitable for embedded storage systems.

file: src/tree_store/page_store/lru_cache.rs ↗ | tags: #lru-cache #second-chance #caching

Implements a BtreeBitmap, a 64-way bit tree for tracking free pages. Used in the buddy allocator and region tracker. The data structure is self-contained, efficient for sparse bitmaps, and could be reused in any project requiring compact free-space tracking with fast search.

file: src/tree_store/page_store/bitmap.rs ↗ | tags: #bitmap #btree-bitmap #free-space-tracking

Defines the core `Key` and `Value` traits with fixed-width optimization, zero-copy access via `SelfType`/`AsBytes`, and a `TypeName` registry for backward compatibility. Includes separator generation and `min_encoded_key` logic for B-tree keys. The trait system is well-designed, generic, and could be extracted as a standalone serialization framework for embedded databases.

file: src/types.rs ↗ | tags: #serialization #key-value-trait #type-name
Last analyzed: 2026-09-04 08:10:27.663252
Next check: 2026-09-11 08:10:27.658577
$ submit: