Design decisions

Foundations

Decisions about language, dependencies, typing, filters, documentation, portability and testing (D1, D5 to D9, D13, D16).

D1 Rust, no dependencies in the engine crates#

The engine crates (raftdb-table, raftdb-doc, raftdb-exec) are written in Rust with no dependencies, and no async framework is used yet. The goal is that no line adds delay or memory that was not measured; a dependency brings code and allocations nobody has measured. Test and benchmark code may use dependencies.

D5 No silent type coercion#

Comparing values of different types is "no match" and is never converted: Int(30), F64(30.0) and Str("30") are three different values. $ne and $not match values that are missing or of another type, and decimal floats must round-trip bit for bit. The consequence is that an integer literal does not match a float field; the schema layer converts literals to the declared field type when the plan is built, so conversion is explicit and visible and never happens inside the executor.

D6 Filters are data, not code#

A filter is a plan, an array of nodes with a root. JSON filter text compiles to it, and SQL compiles to the same form (see D31). The executor is pre-built and no code is generated at run time. The log records plan-from-cache at 0.03 us and compile-from-text at 1.2 us.

D7 Batched execution with 64-bit mask words#

The executor takes 1024 documents per batch and keeps one u64 mask word per 64 documents. An And narrows the candidate set for its second side, and empty words are skipped. The design follows DuckDB and makes selective filters faster than non-selective ones.

D8 Every item is documented, enforced by the compiler#

Every item in the code carries documentation, and the compiler lints missing_docs, clippy::missing_docs_in_private_items and clippy::undocumented_unsafe_blocks as errors. Enforcement by the compiler keeps the rule from decaying.

D9 Build outputs are never committed, and no CI build runs on the code host#

Build output (target/, bench-results/) is ignored by git. The CI workflow is kept as an example file and is not active. This was an instruction from the project owner.

D13 Portable by default; platform fast paths are optional, equivalent and tested#

Every component has a portable implementation that defines the behaviour. x86_64 fast paths (SSE2 bucket search, prefetch, SSE4.2 CRC) sit behind the same functions, and a portable feature forces the portable code so it is tested and timed everywhere. Slow portable fallbacks were replaced (the byte-at-a-time CRC became about four times faster), and platform-specific file-write code in the WAL was removed because the standard Seek and Write were not measurably slower. Not done: ARM hardware paths and any run on Linux or macOS could not be built or tested at that time.

D16 Deterministic simulation from the first storage code#

All test randomness comes from one seeded generator, disks (and later network and time) are simulated, and every failing run can be replayed from its seed. The simulator must find a planted bug within 1,000 schedules or it is not trusted. The real table and WAL run on the simulated disk through the Storage trait. The first generator failed that check and was fixed by making rare cases common, not by moving the target.