Rust storage engine
AbyssDB’s storage engine has been rewritten in Rust. The crate lives in
rust/abyss-core and is embedded in the Go server as a
WebAssembly module.
Why Rust
- Memory safety.
abyss-coreis#![forbid(unsafe_code)], and the entire Rust workspace contains zerounsafeblocks. - Performance. Over 1,000,000 writes per second on a single core.
- Zero-cost abstractions. Every operation costs exactly zero.
- Fearless concurrency. The engine holds no data that could race.
Using it
abyssdb --storage-engine rust
abyssdb serve --storage-engine rust
abyss=> SHOW STATS;
NOTICE: storage engine .......... abyss-core (Rust 🦀, via WebAssembly)
NOTICE: storage device .......... wasm://abyss-core
Every AbyssDB feature (encryption, sharding, NullRaft, 2PC, AbyssChain) works unchanged on top of the Rust engine.
How it is embedded
Go server ──► internal/rustengine ──► wazero (pure-Go WebAssembly runtime)
└─► abyss_rs.wasm (14 KB)
└─► abyss-wasm ──► abyss-core
rust/abyss-core: the engine. ADevicetrait with aVoidimplementation, statistics, and an ADF encoder that is byte-compatible with the Go implementation. On native targets it writes to the operating system’s storage device; onwasm32it runs entirely in linear memory, without using any.rust/abyss-wasm: the WebAssembly ABI. The host never passes a raw pointer for Rust to dereference. Rust allocates a staging buffer per device and returns its address; the host copies data in and asks Rust to write the staged bytes.internal/rustengine: embeds the module withgo:embed, instantiates it once per process with wazero, and registers theruststorage engine. Every device opens its own handle inside the module.
No cgo, no shared libraries, no C toolchain. The Rust engine is sandboxed and works on every platform Go supports, including inside the WebAssembly builds of AbyssDB itself.
| Export | Signature | Purpose |
|---|---|---|
abyss_open | () -> u32 | Open a device, return its handle |
abyss_buffer | (handle, len) -> u32 | Address of a staging buffer of len bytes |
abyss_write | (handle, len) -> u32 | Write len staged bytes |
abyss_read_all | (handle) -> u32 | Full scan; returns bytes read |
abyss_fsync | (handle) | Make writes durable |
abyss_close | (handle) | Close the device |
Building
make rust # cargo build to wasm32 and re-embed (go generate ./internal/rustengine)
cargo test --manifest-path rust/Cargo.toml
cargo run --release --manifest-path rust/Cargo.toml --bin abyss-bench
abyss-core (Rust 🦀) on /dev/null
writes ........... 1033216
throughput ....... 1032755 writes/s
bytes written .... 35129344
unsafe blocks .... 0
Requires Rust with the wasm32-unknown-unknown target
(rustup target add wasm32-unknown-unknown). The prebuilt module is committed,
so building the Go server does not require Rust.