Portability
The rules that keep Raft DB behaving the same on every platform, the full inventory of platform-specific code, the support tiers and what has actually been run.
Raft DB must behave the same everywhere: the same input gives the same output and the same bytes on disk. Platform features may be used where they are faster, but only behind the same function and never changing the result.
Rules#
- One portable implementation defines the behaviour. It uses only the Rust standard library and plain arithmetic and must be fast enough alone to meet the targets.
- A platform fast path is optional. It sits in a
#[cfg]block inside the same function (same signature, same result) and is added only after a measured gain on that platform. - Every fast path has an equivalence test that runs it and the portable version on the same random and edge-case input and requires identical output.
- The
portablebuild option forces the portable paths on any machine, so the code other platforms run is tested and timed on x86_64 too. - Bytes on disk and on the wire are fixed by the format description: every integer is written explicitly little-endian and nothing depends on
usizesize, struct layout or transmutes. Tests assert exact bytes. - Unsupported targets fail to compile with a clear message (
raftdb-walneeds 64-bit atomics). - No assumption about paths, line endings, timer resolution, scheduler or page size. Windows sleeps in 15.6 ms steps by default, so nothing correctness-critical waits on a short sleep.
Inventory of platform-specific code#
| Component | Portable version | Platform fast path | Measured edge (dev PC, x86_64) |
|---|---|---|---|
| Bucket search in raftdb-table | 64-bit word arithmetic (mask_swar) | SSE2 compare | 785 M vs 392 M searches/s alone; end to end 15.2 M vs 11.5 M reads/s |
| Cache prefetch in raftdb-table | an ordinary load whose value is discarded | _mm_prefetch | batched reads 20.3 M vs 12.6 M/s |
| CRC-32C in raftdb-wal | slicing-by-8 tables, 2.2 GB/s | SSE4.2 crc32, detected at run time, 10.3 GB/s | 4.6 times |
Look before a blocking receive (raftdb-client/src/wait.rs) | block in read at once | ioctlsocket(FIONREAD) on Windows, recv(MSG_PEEK | MSG_DONTWAIT) on Linux | loopback round trip 55 us blocking, 24 us looking |
UDP socket buffer sizes (raftdb-server/src/sockopt.rs) | system defaults | setsockopt | burst tolerance only |
| Streams over shared connections | std sockets, threads, mutexes, condition variables | none | see raftdb-client |
| WAL file writes | Seek, write_all, sync_data | write-through open on Windows | 0.06 vs 0.43 ms per durable append |
Everything else (raftdb-doc, raftdb-exec, raftdb-spsc, raftdb-core, raftdb-bloom, raftdb-mvcc, raftdb-sim) | pure Rust, no cfg | none | n/a |
Open fast paths, to be added only when they can be built and measured on that platform: ARM crc32c and prfm prefetch, Linux fallocate for the log, io_uring, IOCP, kqueue, huge pages and thread pinning.
Support tiers#
| Tier | Platforms | Status |
|---|---|---|
| 1, built and tested | Windows x86_64 | all tests, lint and benchmarks, in default and portable builds |
| 1, tests run | Linux x86_64 (Ubuntu 24.04, 4 CPUs, rustc 1.93.0) | on 2026-11-09, 130 of 130 tests passed in the default build and in the portable build, and the lint check was clean; benchmarks were not run there |
| 2, designed for, must be run before release | Linux aarch64, macOS (x86_64 and Apple Silicon), Windows aarch64 | portable paths are exercised by the portable build; not compiled or run on these systems |
| 3, best effort | 32-bit systems (need 64-bit atomics), big-endian CPUs | formats are explicitly little-endian and covered by byte-exact tests; not run |
Honest status: only Windows x86_64 (everything) and Linux x86_64 (tests) have been run. The LSM engine was also run on a Linux host (see The LSM engine); the tier table above does not count those runs.
Behaviour that differs between systems#
| Difference | Handling |
|---|---|
| What "fsync" guarantees | File::sync_data from the standard library everywhere; its mapping to the strongest flush on each system (including macOS) is to be verified on a Mac before release |
| Directory entries after creating a file | A directory sync is still missing on all systems (the LSM manifest does sync its directory) |
| File locking between processes | Not yet; two processes opening one log would corrupt it |
| Cache line size (64 bytes on x86, 128 on Apple Silicon) | Hot shared counters are padded to 128 bytes; table buckets are 64 bytes |
| Thread scheduling and timers | Benchmarks model the thread-per-core design instead of thread-per-client (D11) |
Before a release on a new machine the project runs its whole test suite in the default and in the portable build, the lint check, and the portable benchmark suite. That suite is not part of the download.