Internals

Crate map

The crates of the Raft DB workspace, what each one is for, what it depends on, and the numeric targets kept in raftdb-core.

CratePurposePage
raftdb-coreNumeric targets shared by the benchmarks and the enginebelow
raftdb-docBinary document format, read in placeraftdb-doc
raftdb-tableHash index: 64-bit hash to 32-bit slotraftdb-table
raftdb-storeIn-memory key-to-document collectionraftdb-store
raftdb-bloomCache-local bloom filterraftdb-bloom
raftdb-spscLock-free one-producer one-consumer ringraftdb-spsc
raftdb-schemaDocument schema and type checkingraftdb-schema
raftdb-execFilter plans, batched executor, SQL subsetraftdb-exec
raftdb-indexSecondary index (candidate generator)Secondary indexes
raftdb-walWrite-ahead log with group commitraftdb-wal
raftdb-dbDurable table: schema, store, log, checkpointraftdb-db
raftdb-lsmDisk-resident engine (log-structured merge tree)The LSM engine
raftdb-mvccRow-version header and snapshot visibilityMVCC
raftdb-protoWire protocol codecraftdb-proto
raftdb-clientBlocking Rust clientraftdb-client
raftdb-serverThe server programraftdb-server
raftdb-raftRaft consensus core (pure state machine)Raft
raftdb-watchThe watcher programWatcher
raftdb-reportFatal-error reportsWatcher
raftdb-simDeterministic simulationSimulation tests
raftdb-benchBenchmark harnessbelow
raftdb-mysqlMySQL/MariaDB front-end programFront-end

raftdb-core: targets#

raftdb-core has no dependencies and #![forbid(unsafe_code)]. It holds the numeric targets of the requirements document as constants (targets), so the benchmark harness and the engine cannot drift apart. Changing a value is a requirements change; compile-time asserts reject nonsense and a test checks that all are positive.

ConstantValue
DOC_OVERHEAD_MAX_BYTES16
INDEX_ENTRY_MAX_BYTES24
IDLE_CONNECTION_MAX_BYTES2048
DOC_BYTES_VS_JSON_MAX_RATIO0.5
DOC_BYTES_VS_BSON_MAX_RATIO0.8
S1_FIELD_GETS_PER_SEC_1CORE20 M
S1_POINT_READS_PER_SEC_1CORE5 M
S3_SCAN_DOCS_PER_SEC50 M
S3_PLAN_CACHE_HIT_MICROS5
S4_DURABLE_INSERTS_PER_SEC300 k
S9_FAILOVER_SECONDS5

These are targets, not results. Where a target was missed the crate page says so (for example the acknowledgement latency in raftdb-db).

raftdb-bench: the harness#

raftdb-bench <suite> [--n N] [--out DIR] [--enforce] is a library and a binary. It is the one crate allowed to have dependencies (hdrhistogram, serde, serde_json, hashbrown) because it is not part of the engine. Suites: memory-baseline, doc-format, exec-filter, wal, shard, bloom, mvcc, server, index, proto, db, schema, store, sim, portable. Each writes a JSON report with the host, the rustc version and the git commit, and compares metrics with targets taken from raftdb-core::targets.

Dependency rules#

The engine crates (raftdb-doc, raftdb-table, raftdb-store, raftdb-wal, raftdb-db and so on) use only the Rust standard library and each other. The MySQL front-end depends only on workspace crates (raftdb-proto for SHA-256, raftdb-exec for the JSON reader and writer, and the server crate when it runs in one process), and no engine crate depends on it (D52).