A Database Without Dynamic Memory Allocation
TigerBeetle allocates all memory once at startup and never again, using fixed limits for connections, in-flight messages per client, replicas, message size and queries per message so that total memory is a simple compile-time sum. Beyond avoiding GC and use-after-free, static allocation bounds overload, makes resource use predictable for operators, and lets assertions on pool availability surface sizing mistakes under fuzzing rather than as production resource exhaustion. Supporting choices include fixed-size, cache-line-aligned 128-byte account and transfer structs sent zero-copy over the wire, batched queries (up to 8191 per message), and an LSM forest whose in-memory portion is preallocated and kept bounded by small incremental flushes to disk.
Related posts
- The effect of switching to TCMalloc on RocksDB memory use
Cloudflare mediumAdeptQuicksilver's memory roughly doubled after its storage moved to RocksDB, climbing from about 15GB to 30GB over several days. Heap profiling showed the heap was about a third of RSS, which pointed to the allocator rather than a leak. glibc malloc gives threads independent per-thread arenas (60-80 arenas for about 25 threads), and memory cannot move between them, so fragmentation multiplies. Mitigations such as MALLOC_ARENA_MAX, periodic malloc_trim and M_MMAP_THRESHOLD each cost lock contention or syscalls, while TCMalloc's middle-end moves freed memory between per-core caches and cut memory use by 2.5x.
- Synadia and TigerBeetle Pledge $512,000 to the Zig Software Foundation
TigerBeetle easyNoviceSynadia and TigerBeetle are jointly donating $512,000 to the Zig Software Foundation over two years, with no strings attached. The post explains why TigerBeetle chose Zig over Rust and C in 2020. TigerBeetle uses static allocation per NASA's Power of Ten rules and runs single-threaded because transaction contention defeats partitioning, so Rust's borrow checker mattered less than Zig's bounds checking, checked arithmetic by default and absence of hidden allocations or control flow. Three bugs the borrow checker would have prevented were caught by fuzzing on 1,000 dedicated cores, and the upgrade to Zig 0.15.2 made debug builds 2x faster and LLVM release builds 1.6x faster.
- We rewrote large parts of our API in Go using AI: we are now ready to handle one billion databases
Turso mediumAdeptTurso's Go API proxy, which maps database URLs to physical servers, ran out of memory as customers created millions of databases programmatically. Bootstrapping was fixed with streaming and pagination. Route memory was cut by interning repeated App and Address strings with Go's unique package and by dropping the region suffix from map keys. With memory still growing about 500MB per week, the in-memory hash map was replaced by a SQLite-backed store behind an LRU cache, so only active mappings stay in memory and restarts fetch only deltas. Planned next steps are Embedded Replicas sync and dictionary encoding of organization names.
- Introducing Limbo: A complete rewrite of SQLite in Rust
Turso easyNoviceLimbo is Turso's from-scratch rewrite of SQLite in Rust that aims for full language and file-format compatibility, memory safety and a modern architecture. The team chose a rewrite over the libSQL fork because invasive changes such as natural vector-index syntax and async I/O were hard to make in C without SQLite's proprietary test suite. Deterministic Simulation Testing is built in from the start, and Antithesis is used for system-level fault simulation, which has already caught io_uring partial-write bugs. Early results include a fully asynchronous sqlite3_step, a WASM-first build that works with Drizzle, fewer tunables, and a point query about 20% faster than tuned SQLite (506ns vs 620ns).
- An adventure in writing compatible systems
Turso mediumAdeptTurso, a Rust rewrite of SQLite, hit a bug where every write after the database crossed 1GB made SQLite's integrity checks fail, even though Turso's own checks found the file intact. The cause was the SQLite "pending byte" page: once a file passes the 1GB mark, SQLite reserves a special page tied to file locking, and Turso did not reserve it. The deterministic simulation tests had missed the bug because every profile injected faults, so no test database ever grew to 1GB. Adding fault-free runs fixed that gap, a reminder that compatible rewrites must match undocumented-feeling quirks of the original implementation.