Why We’re Rewriting SQLite in Rust by Glauber Costa
ScyllaDB
0 views
35 slides
Oct 09, 2025
Slide 1 of 35
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
About This Presentation
As we were adding Vector Search to SQLite, we had a crazy idea. What could we achieve if we were to completely rewrite SQLite in Rust? This talk explains what drove us down this path, how we’re using deterministic simulation testing to ensure the reliability of the Rust rewrite, and the lessons le...
As we were adding Vector Search to SQLite, we had a crazy idea. What could we achieve if we were to completely rewrite SQLite in Rust? This talk explains what drove us down this path, how we’re using deterministic simulation testing to ensure the reliability of the Rust rewrite, and the lessons learned (so far). I will show how a reimagining of this iconic database can lead to performance improvements of over 500x in some cases by looking at what powers it under the hood.
Size: 2.16 MB
Language: en
Added: Oct 09, 2025
Slides: 35 pages
Slide Content
A ScyllaDB Community
Why We’re Rewriting
SQLite in Rust
Glauber Costa
CEO
Glauber Costa
Founder/CEO - Turso
■Linux Kernel contributor
■VP Field Engineering at ScyllaDB
■Staff Engineer at Datadog
■Founder of Turso
Why Rust?
Why Rust specifically?
It could have worked in Zig.
Ultimately, whatever works.
Team was very familiar with Rust.
But ultimately, the borrow checker!
Why rewrite the most deployed
database in the solar system?
Can the best be better?
■SQLite is great for reads, but writes are painful: single writer.
■SQLite is hard to extend. Extensions exist, but:
■Not memory-safe,
■Can’t add new index types,
■Can’t add new data types and affinities,
■Can’t influence the language syntax.
■Lacks modern features like CDC, Encryption, Vector Search.
Can the best be better?
■SQLite is great for reads, but writes are painful: single writer.
■SQLite is hard to extend. Extensions exist, but:
■Not memory-safe,
■Can’t add new index types,
■Can’t add new data types and affinities,
■Can’t influence the language syntax.
■Lacks modern features like CDC, Encryption, Vector Search.
SQLite - Open Source, Not Open Contribution
Small and restricted team of contributors.
Contributions not accepted, or rarely accepted.
Test suite is legendary, but also proprietary.
Every rewrite is an opportunity
■New async architecture.
■Concurrent writes, solving the notorious “database is locked” problem.
■Deterministic Simulation Testing from day1 to match SQLite’s reliability.
This is a performance conf!
Async
Multithreading
Incrementalism
Asynchronous interface
SQLite’s C API is synchronous
Meaning I/O is synchronous.
Turso on Linux: io_uring: asynchronous fsync.
MVCC
MVCC (Multi-Version Concurrency Control)
●MVCC: Optimistic concurrency control.
●Transactions that do not conflict can proceed in parallel.
●Conflict resolution at COMMIT time.
●Async fsync makes sure the next transactions can start already.
MVCC in Turso
●Lifting the single-writer limitation.
●Concurrent transactions can progress independently until they commit.
SQLite parallel write behavior
●Writing batches of 10 rows, with a 1ms think time in the transaction:
SQLite vs Turso write throughput
10 rows per transaction
1 ms simulated think time
SQLite write throughput
Multi-threading
Threads are… fine ?
The hierarchy of evil
Def.Evil
Maybe a bit evil
Not Evil
Threads
Opening a new connection: O(N) on tables.
Opening a new connection: O(N) on tables.
Opening a new connection: O(1) on tables.
Opening a new connection: O(1) on tables.
Incrementalism
SQLite schema changes
sqlite> create table foo(bar);
sqlite> create index bar_i on foo(bar);
sqlite> select * from sqlite_master;
table|foo|foo|2|CREATE TABLE foo(bar)
index|bar_i|foo|3|CREATE INDEX bar_i on foo(bar)
-- a new change now will reparse the entire schema!
Turso schema changes are incremental
Live Materialized Views
How Materialized Views work
Materialized Views on an in-process database?
DBSP
DBSP
Conclusion:
●We believe SQLite needs a facelift to power modern applications.
●Turso is an Open Contribution rewrite of SQLite.
●Even on performance, there is a lot of room for improvement.
●Perf improvements are architectural, not language-derived.
●Foundation is: Async I/O, multithreading, and incrementalism.