Skip to content

Measure the SQLite store: throughput, commit cost and list ordering (#859) - #882

Merged
jimhoyd merged 1 commit into
mainfrom
claude/store-benchmark
Sep 29, 2026
Merged

jimhoyd merged 1 commit into
mainfrom
claude/store-benchmark

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Addresses #859 item 5 and measures item 1. This is measurement only; no store source changes.

  • Benchmark: new packages/store/bench/store-throughput.ts, run with npm run bench:store (not part of verify). --quick gives a short run and --json <file> saves the raw results.
    • A child server runs store and the real audit extension, and samples its own event-loop delay.
    • A keep-alive client drives stateful If-Match and Idempotency-Key writes at fixed concurrency.
    • The FULL vs NORMAL micro-benchmark and the list-ordering micro-benchmark each use a database of their own.
  • Results: recorded in docs/CAPACITY.md under "Measured: the SQLite store", with machine, Node and SQLite versions, the method and the caveats. The run: Apple M4 Pro, macOS, Node 26.10, SQLite 3.53.4; a second run agreed within ~15%.
    • Writes at concurrency 16: creates 5.1k/s, If-Match PATCH 7.0k/s, transitions 7.5k/s. Audit roughly halves each (~3k/s).
    • Event-loop delay during writes: p50 1.9–4.8 ms, max 19 ms.
    • Commit cost in isolation: FULL 41 µs, NORMAL 12 µs. With fullfsync=ON, 4.0 ms (a true cache flush on macOS).
    • Lists: unsorted pages take under 1 ms at 10k records. sort=title takes about 10 ms at 10k and about 1.3 ms at the default 1k cap.
    • Ordering in SQL: 3× faster without an index, about 30× with an index on the sort field. Byte order is not the documented UTF-16 order, so those numbers compare cost only.

Recommendations (no change made)

  1. Keep synchronous=FULL. On macOS the fsync is not the bottleneck. Linux fsync flushes the drive cache, so run bench:store on the target Linux host before deciding. Relaxing to NORMAL gives up durability of the last transactions on power loss, which is a product decision.
  2. SQL-side ordering isn't needed at the default maxRecords of 1,000. It becomes worthwhile near 10k records with concurrent sorted traffic, but only with an index on each sortable field and a UTF-16-correct collation.

Evidence

npm run typecheck, npm test (1150/1150) and npm run check pass.

🤖 Generated with Claude Code

…dering (#859)

Adds a manual benchmark (npm run bench:store, not part of verify) that
serves an owned store collection with idempotency, audit off and on,
drives it with a bounded keep-alive node:http client, samples the server's
event-loop delay, and runs isolated micro-benchmarks for synchronous=FULL
vs NORMAL and for JS-side vs SQL ordering at 1k/10k/50k records. Records
one local run in docs/CAPACITY.md with machine, method and caveats.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant