Skip to content

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

Linear 7 min read Case study mediumAdept

Rebuilding Linear’s delta sync read path

Linear moved its delta sync read path, which lets reconnecting local-first clients fetch only changes since their last checkpoint, from a Postgres table to turbopuffer inverted indexes. On Postgres, the reconnect query combined a widening ID range with array-overlap predicates for sync groups and subscriptions, which drove up CPU and made p95/p99 latency volatile. Read replicas didn't help because the per-request intersection work stayed the same. turbopuffer stores per-workspace posting lists of sync action IDs and intersects them directly, fed by a custom CDC pipeline with about 1s p50 replication lag. Reads run as a metadata scan with late payload enrichment from Postgres, Postgres serves an overlapping authoritative head slice with deduplication and fallback, and shadow-mode comparison verified correctness. Tail latency now stays flat as workspaces grow.

Assumes: Postgres indexingchange data captureinverted indexes

Related posts

  • Turso Sync: Local-First SQLite with Push and Pull

    Turso mediumAdept

    Turso Sync replaces libSQL's page-based Embedded Replicas with logical row-level changes captured via CDC in Turso Database, a Rust rewrite of SQLite, so reads and writes stay local and apps call push() and pull() explicitly. Shipping logical statements instead of WAL pages lets unrelated writes merge on the server. Experimental partial sync fetches 128 KiB segments on demand, with optional prefetch. Benchmarks show roughly 7–10x speedups and about 15x less data for small-write workloads, but only 1.2x when writes are already batched. Conflicts resolve by last-push-wins, which suits single-writer data but loses updates on shared counters unless data is modeled append-only.

  • Turso Sync: a much, much, much better way to sync

    Turso mediumAdept

    Turso, a Rust rewrite of SQLite, replaces libSQL's Embedded Replicas with a sync model built on change data capture, shipping logical changes instead of physical pages and splitting sync into separate push() and pull() operations. Page-based replication wasted bandwidth, could not resolve conflicts (so writes defaulted to the remote), and diverged around checkpoints, forcing re-bootstraps. In Node.js benchmarks against Turso Cloud, Turso sync was 8.9x faster with 16.3x less traffic for 3,000 sequential inserts, 312x faster for read-your-writes cycles with local writes (7.3x even when pushing after every write), and 2.1x faster for an initial pull. Turso also supports partial, lazy bootstrap, and the recommendation is to switch from libSQL sync to Turso.

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

    Turso mediumAdept

    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.

  • Everyone gets faster writes: We turned off FPW's in Neon

    Neon hardMaster

    Neon disabled Postgres full-page writes fleet-wide because its stateless compute streams WAL to a Paxos safekeeper quorum and has no local disk pages that can tear. To keep delta chains bounded without FPW images, the pageserver now generates page images itself once a page accumulates more deltas than a threshold, rather than relying on the checkpoint cycle. HammerDB TPROC-C throughput rose up to 4.5x on 32 vCPU, and WAL per transaction fell from 58KB to under 4KB (94%). In production, p99 read latency dropped 30-50%, and the change was rolled out without restarts via the XLOG_FPW_CHANGE WAL record.

  • Beyond synthetic testing: Capturing and replaying real database workloads at Airbnb

    Airbnb Engineering mediumAdept

    Airbnb replaced fragmented per-language client-side query logging with a client-agnostic capture point in ProxySQL, so real production MySQL traffic can be replayed offline. A Log Mover sidecar ships ProxySQL query logs to object storage. A Log Processor splits them per cluster, reassembles transactions, buckets them into five-minute windows and rewrites INSERTs to pin last_insert_id. A queue-driven fleet of replay workers then uses shared start times to reproduce the original concurrency and pacing, at 1x or accelerated speeds. Replay-and-compare runs during the MySQL 5.7→8.0 upgrade caught a 0.03s→2.6s sort regression, duplicate queries the query cache had been hiding, and non-deterministic ORDER BY/LIMIT results. Accelerated replays locate capacity ceilings, for example commit latency rising from 6 ms to 34 ms at 80% more write traffic.

The quest for software engineering knowledge.

Look:
Layout: