Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Turso 13 min read Deep dive mediumAdept

From v0.7 to v0.8: How group commit changed Turso's tail latency

Turso v0.8 adds group commit to its MVCC write path so that concurrent committers share a single fsync of the logical log instead of each paying for their own. In v0.7 a commit lock was held across pwrite and fsync, so with k concurrent committers the last waited for k flushes. Under a 1,000 TPS Poisson load, tail latency ballooned to seconds (p99.9 up to 157 s at 32 connections). In v0.8 committers enqueue log records and get tickets, and the first to take the lock leads, writing all queued records and fsyncing once while the others park until their ticket is durable. That cuts p50 to about 1 ms and p99.9 to 2.4–14 ms, below SQLite's in every configuration, with tail latency improving as connections increase.

Related posts

  • Turso 0.8: Concurrent writes without SQLite's single-writer bottleneck

    Turso mediumAdept

    Turso 0.8 targets SQLite's single-writer bottleneck with BEGIN CONCURRENT, an MVCC mode where transactions start independently and commit in groups. At 1,000 TPS with Poisson arrivals, p99.9 latency is 2.4 ms at 32 connections versus 1.2 s for SQLite, whose lock-retry sleeps inflate tail latency. On disjoint-key inserts, Turso scales to about 9,500 TPS at 64 connections while SQLite stays near 1,370 TPS, though SQLite is faster with a single connection. The release also adds full window function and recursive CTE support, MVCC-compatible full-text search, and optimizer work including correlated subquery unnesting, hash joins and JSON EXPLAIN QUERY PLAN output.

  • Beyond the Single-Writer Limitation with Turso's Concurrent Writes

    Turso hardMaster

    Turso implements SQLite-compatible BEGIN CONCURRENT using Hekaton-style MVCC, which removes SQLite's single-writer bottleneck and the SQLITE_BUSY errors that come with it. An in-memory row-version index sits on top of the B-tree and WAL, conflicts are detected per row at commit time instead of per page, and the MVCC log is checkpointed back into the database file through the WAL. In benchmarks SQLite still wins single-threaded, but Turso is 16% faster with multiple threads and pure inserts, and 4x faster with 8 threads and 1ms of compute per transaction. The feature is an early tech preview: CREATE INDEX is not supported and full-row versioning carries a high memory cost.

  • Birth and death of a row in Turso's MVCC

    Turso hardMaster

    Turso's MVCC, modeled on Hekaton, tracks each row as a chain of versions in a lock-free SkipMap, with begin/end fields holding a TxId while a transaction is active and a commit timestamp once it commits. The walkthrough follows one row from the INSERT bytecode executed by the VDBE, through the commit protocol (timestamp acquisition, first-committer-wins conflict checks, dependency waits, logical-log write and fsync), crash recovery by replaying the logical log, and checkpointing into the SQLite WAL and B-tree. Checkpoints default to a blocking Truncate mode triggered at about 4 MB, with an experimental Passive mode that lets writers proceed. Reads merge the in-memory store and the B-tree with a two-pointer iteration. Deletes set the end field under the version-chain lock, so concurrent writers to the same row get a WriteWriteConflict.

  • Concurrent Writes in Practice: Building High-Throughput Apps with Turso's MVCC

    Turso mediumAdept

    Turso's BEGIN CONCURRENT replaces SQLite's single-writer lock with Hekaton-inspired optimistic MVCC that detects conflicts at commit time and at row granularity, rather than the page-level detection in SQLite's unmerged experimental branch. Turso's benchmarks show write transactions running 4x faster than SQLite at 8 threads with 1ms of compute per transaction, and 16% faster with no compute. The biggest gains come from transactions that read, compute, then write, from ingestion across distinct rows, and from long-running augmentation jobs. Practical use on Turso Cloud requires opting in and creating a tursodb database, with working TypeScript, Python and Rust code for concurrent transactions and bounded exponential-backoff retry wrappers for write-write conflicts.

  • Turso v0.5.0

    Turso hardMaster

    Turso v0.5.0 promotes MVCC-based concurrent writes (BEGIN CONCURRENT, adapted from Hekaton) to beta. The MVCC work adds commit dependency tracking, a rewritten crash-safe logical log, low-watermark garbage collection, savepoints, hardened conflict detection and lock-free rowid allocation, verified with Antithesis, Hermitage and Elle. The release also adds experimental Tantivy-based full-text search stored inside the SQLite B-tree, and optimizer upgrades: hash joins with bloom filters, outer joins and disk spilling, semi/anti-join decorrelation, multi-index OR scans and a reworked cost model. Rounding it out are STRICT tables with user-defined types via CREATE TYPE, and stable change data capture with a v2 transaction-grouped record format.

The quest for software engineering knowledge.

Look:
Layout: