Running unmodified Doom in the SQLite bytecode language
Turso compiles unmodified Doom C source to SQLite's VDBE bytecode by using LLVM as a frontend and a custom backend, vdbecc, that lowers LLVM IR to VDBE. The VM's unbounded register file removes the need for register allocation, so every SSA value gets its own register. Calls map to Gosub/Return, function pointers become integers dispatched through a binary search, and XOR is synthesized from OR, AND and subtraction. C's address space is a single 64 MiB BLOB row accessed via BlobRead/BlobWrite with a cached overflow-page table, each frame is emitted as a ResultRow from a never-ending SELECT, input arrives as rebound bind parameters, and a save game is just the SQLite database file.
Related posts
- We're building Postgres in Rust. Using the LLVM of databases
Turso easyNoviceTurso, a Rust rewrite of SQLite, is adding a Postgres frontend by parsing Postgres SQL into a common AST and compiling it to Turso's VDBE bytecode, turning the engine into an "LLVM of databases" with pluggable frontends. The argument is that SQL databases differ mostly in on-disk layout, not in core operations, so Postgres semantics can be expressed in or added to the VDBE. A C-to-VDBE compiler running Doom illustrates that the bytecode works as a real VM. The work starts from the earlier pgmicro experiment and is early-stage but runnable from source. Planned pieces include the Postgres wire protocol, embedded and in-browser use, live materialized views, and WASM-sandboxed extensions, aiming for broad rather than 100% compatibility.
- 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).
- WebAssembly functions for your SQLite-compatible database
Turso mediumAdeptlibSQL, Turso's open-contribution fork of SQLite, adds user-defined functions written in WebAssembly and registered directly from SQL with a CREATE FUNCTION ... LANGUAGE wasm statement, instead of only through SQLite's C API. WebAssembly was chosen for its sandboxing, portability, performance and wide use as a compile target from languages such as Rust and Zig. A walkthrough compiles Rust encrypt/decrypt functions with the libsql_bindgen crate or its playground and loads them as binary blobs in the libSQL shell. Functions cannot touch system resources such as time, randomness or the network, and their signatures must map to INTEGER, REAL, TEXT and BLOB types.
- Turso v0.6.0
Turso mediumAdeptTurso 0.6 is the first release supporting all major SQLite features, adding experimental multi-process WAL access (OFD locks on Linux, fcntl elsewhere, IOCP on Windows) and VACUUM/VACUUM INTO. SQL additions include production-ready triggers, temp tables, virtual generated columns, CREATE TABLE AS SELECT, partial WITHOUT ROWID support, UPDATE...FROM, FILTER on aggregates, NULLS FIRST/LAST, and INDEXED BY hints. The STRICT type system gains arrays, structs/unions and Postgres-style domains, and MVCC logical logs are now encrypted with AEAD in 32 KiB chunks. SDK changes add query timeouts, async prepare, fixed interactive transactions in the serverless driver, an npm-distributed CLI and a SQLAlchemy asyncio dialect.
- Faster schema changes for large SQLite databases
Turso mediumAdeptSQLite re-parses the entire sqlite_schema table after every ALTER TABLE, so schema changes cost time proportional to total schema size even when only one table is touched. Turso, a Rust rewrite of SQLite, adds dedicated bytecode instructions (RenameTable, DropColumn, AddColumn, RenameColumn) that mutate the in-memory schema directly and update only the affected table's indexes in batch. Initial schema loading is also sped up by replacing the lemon-generated parser with a handwritten one, while the in-memory schema is shared across connections so later connections skip parsing entirely.