How facebook/rocksdb works
RocksDB is an embeddable persistent key-value store built around an LSM design. A caller opens a database and uses its public API to read or write key-value data; internally, the product also manages storage files, compaction, caches, and backup/restore. The README establishes the LSM and multithreaded-compaction roles, while the source index exposes selected implementation dependencies. Many detailed runtime connections are not shown in the excerpts, so those are omitted rather than inferred.
Main entry points: db_impl.cc Database implementation · backup_engine.cc Backup and restore · db.h DB API · wal_manager.cc WAL manager
Components 24
Public API
- DB API
include/rocksdb/db.h - DB options
include/rocksdb/options.h
Database Engine
- Database implementation
db/db_impl/db_impl.cc - Memtable
db/memtable.cc - WAL manager
db/wal_manager.cc - Read iteration
db/db_iter.cc - Flush jobs
db/flush_job.cc - Compaction jobs
db/compaction/compaction_job.cc - Version metadata
db/version_set.cc
Storage and Files
- Blob files
db/blob/blob_file_partition_manager.cc - Environment API
include/rocksdb/env.h - File system API
include/rocksdb/file_system.h - Writable file writer
file/writable_file_writer.h
Caches and Backups
- Block and object caches
cache/cache.cc - Cache reservations
cache/cache_reservation_manager.h - Backup API
include/rocksdb/utilities/backup_engine.h - Backup and restore
utilities/backup/backup_engine.cc - File copy engine
utilities/copy_engine/copy_engine.cc
Core Primitives
- Slice values
include/rocksdb/slice.h - Status results
include/rocksdb/status.h - Binary encoding
util/coding.h - Platform abstraction
port/port.h - Logging interface
logging/logging.h
Other components
- Database caller
Connections 17
- Database caller → DB API: calls
README.md - DB API → Database implementation: serves requests
- Database implementation → Memtable: updates
- Database implementation → WAL manager: manages logs
- Database implementation → Read iteration: serves reads
- Database implementation → Flush jobs: schedules flush
- Database implementation → Compaction jobs: runs compaction
- WAL manager → Version metadata: references
db/wal_manager.cc - Database implementation → Blob files: uses blob storage
- Database implementation → Block and object caches: uses caches
- Cache reservations → Block and object caches: reserves space
cache/cache_reservation_manager.h - Backup API → Backup and restore: implements operations
- Backup and restore → File copy engine: submits copy work
utilities/backup/backup_engine.cc - Backup and restore → File system API: copies files
utilities/backup/backup_engine.cc - Writable file writer → File system API: writes through
file/writable_file_writer.h - Database implementation → DB options: uses configuration
- Database implementation → Environment API: uses environment