Real Components
Working implementations of WAL, MemTable, and SSTable writer
Real Components
Working implementations of WAL, MemTable, and SSTable writer
Test Suite
Comprehensive tests showing how each component works
Learning Code
Clear implementations prioritizing understanding over optimization
Rust 1.81+
Install via rustup.rs
Git
For cloning the repository
Curiosity
Desire to understand how databases work
Clone the repository
git clone https://github.com/ferrisdb/ferrisdb.gitcd ferrisdb
Install Rust toolchain
rustup toolchain install stablerustup component add rustfmt clippy
Build the components
cargo build --all
Run the tests
cargo test --all
ferrisdb/├── ferrisdb-core/ # Basic types (Key, Value, Error)├── ferrisdb-storage/ # The interesting stuff!│ ├── src/│ │ ├── wal/ # Write-ahead log implementation│ │ ├── memtable/ # Concurrent skip list│ │ └── sstable/ # File format for persistence├── ferrisdb-client/ # Stub only├── ferrisdb-server/ # Stub only└── ferrisdb-tutorials/ # Hands-on learning
The WAL ensures durability - data survives crashes:
# See the implementationcat ferrisdb-storage/src/wal/writer.rs
# Run WAL-specific testscargo test -p ferrisdb-storage wal::
# Trace a write operationRUST_LOG=debug cargo test test_wal_basic -- --nocapture
What to look for:
A concurrent skip list for in-memory operations:
# Explore the skip listcat ferrisdb-storage/src/memtable/skip_list.rs
# See concurrent operations in actioncargo test -p ferrisdb-storage skiplist::tests::test_concurrent
# Understand MVCC (multi-version concurrency)grep -n "timestamp" ferrisdb-storage/src/memtable/skip_list.rs
What to look for:
# See how data is written to diskcat ferrisdb-storage/src/sstable/writer.rs
# Test SSTable creationcargo test -p ferrisdb-storage test_sstable_writer
Creates sorted files with index and footer.
# See the skeletoncat ferrisdb-storage/src/sstable/reader.rs
Structure exists but can’t read files yet.
# Add debug prints to understand flowecho 'println!("WAL write: {:?}", entry);' >> ferrisdb-storage/src/wal/writer.rs
# Run and see the outputcargo test test_wal_basic -- --nocapture
# Don't forget to remove your prints!git checkout ferrisdb-storage/src/wal/writer.rs
# Run benchmarks (if any exist)cargo bench --all
# Time the teststime cargo test -p ferrisdb-storage
# Check binary sizecargo bloat --release -p ferrisdb-storage
# What's left to implement?grep -r "TODO" ferrisdb-storage/src/
# What's not implemented?grep -r "unimplemented!" ferrisdb-storage/src/
Error Handling
Look for Result<T>
and ?
operator usage throughout the codebase
Concurrency
See how Arc
, Mutex
, and lock-free structures are used
Binary Encoding
Understand how data is serialized for disk storage
Testing Patterns
Learn from comprehensive test suites for each component
# Run all testscargo test --all
# Run specific testcargo test test_name
# See println! outputcargo test -- --nocapture
# Run tests in single thread (for debugging)RUST_TEST_THREADS=1 cargo test
# Use nextest for better outputcargo install cargo-nextestcargo nextest run --all
# Generate and view documentationcargo doc --all --no-deps --open
# See dependency treecargo tree -p ferrisdb-storage
# Find a type definitiongrep -r "struct SkipList" ferrisdb-storage/src/
Found something interesting? Share it!
Start Tutorial
Build your own components in our tutorial series
Read the Blog
See how we built these components in our development blog
Pick a Component
Deep dive into WAL, MemTable, or SSTable implementation
Join Discussion
Ask questions and share insights on GitHub
Remember: The goal isn’t to use FerrisDB, it’s to understand how databases work by exploring one
being built.