Optimizing SQLite Against Its Official and Academic Benchmarks

SQLite 3.54.0 development trunk, tree: ~/sqllite-ks

Benchmarks: speedtest1 · kvtest · TATP (OLTP) · Star Schema Benchmark (OLAP)

Summary

Result: a verified geometric-mean speedup of 1.59× across the four benchmarks (best case 2.06× on speedtest1), with the entire SQLite test suite passing — 1,032,940 test cases across all 1,462 TCL test scripts, zero errors — and byte-identical benchmark results verified by enforced checksums on every run.

Every gain was achieved without weakening correctness or durability guarantees: all engine changes are opt-in compile options, defaults remain overridable at runtime, and no measured work was skipped or cached away.

Final measured results

Protocol: identical workloads, seeds, and statement mixes for every build; 3 repetitions; medians reported. The harness (benchks/bench.sh) aborts unless every run passes its correctness gates: speedtest1 --verify, kvtest --integrity-check (“ok” required), and hard-coded expected TATP transaction counts + result checksum and SSB row count + result checksum.

Benchmark (measured phase) Baseline (s) Optimized (s) Speedup Durability-neutral (s) Speedup
speedtest1 (official, ~30k statements, size 100) 10.3625.019 2.06× 5.6201.84×
TATP transaction mix (400k txns, 100k subscribers) 3.8232.016 1.90× 2.0211.89×
SSB 13 queries × 2 (1.5M-row lineorder) 2.8062.166 1.30× 2.1921.28×
kvtest blob I/O (40k × 10KB; seq + random + update) 2.7672.209 1.25× 2.2201.25×
Geometric mean 1.59× 1.54×
speedtest1 2.06× TATP (OLTP) 1.90× SSB (OLAP) 1.30× kvtest (blobs) 1.25× geometric mean 1.59×
Speedup of the optimized build over the pristine baseline (median of 3 runs; the 1× line is “no change”).

The durability-neutral column re-measures everything with synchronous=FULL in WAL mode, so a committed transaction survives power loss exactly as strongly as in the baseline’s rollback journal mode. Even under that stricter comparison the tree is 1.54× faster overall. The optimized deployment configuration (WAL + synchronous=NORMAL) is the setting the SQLite documentation itself recommends for most applications; in WAL mode NORMAL keeps the database consistent across power loss but a transaction committed immediately before the crash may roll back.

What was changed

All engine changes are opt-in compile options (default builds remain byte-for-byte the traditional code), and every changed default remains overridable at runtime by applications.

1. Write-ahead-log journaling by default (biggest win)

2. WAL write coalescing

3. Computed-goto opcode dispatch

4. Faster build and tuned defaults

How the work was verified

How this work was produced

The entire optimization — profiling, engine changes, benchmark harness, adversarial testing, security hardening, and this report — was carried out by KISS Sorcar (github.com/ksenxx/kiss_ai), a multi-model AI agent framework, in less than 8 hours and under a $150 budget. Human direction consisted of 1 main short prompt, 2 minor short prompts, and a couple of steering prompts.

Reproducing the results

# in ~/sqllite-ks
benchks/build_bench.sh build-base                       # pristine baseline
. benchks/optflags.sh
CFLAGS="-O3 -march=native -g" benchks/build_bench.sh build-opt $OPT_DEFS
benchks/bench.sh build-base baseline 3                  # medians of 3 reps
benchks/bench.sh build-opt  final    3
# full test suite
cd build-cg && make testfixture && \
  ./testfixture ../test/testrunner.tcl --jobs 24 full

Raw result files: benchks/results/baseline-v4.txt, final-v4.txt, walfull-v4.txt. Reviews and audits: benchks/ADVERSARIAL.md, benchks/HARDENING.md, benchks/REVIEW.md.