Repository navigation
perf(adapter): reduce durable SQLite commits per Add - #20
Conversation
Code Review (automated)Is the change reasonable?Yes. Every journal operation goes through a single writer gate, so each durable commit ( Is the implementation correct?On the production path, yes. I found no hard correctness bug. I checked these specifically:
The main concern is that correctness now depends on callers using 1.
Production code always calls 2. 3. 4. Efficiency (minor)5. 6. Benchmark script7. 8. Verdict: the change is sound and the production path is correct. Before merging I'd address #1–#2, so the commit-ordering guarantees don't depend on every caller doing the right thing, and confirm #7, so the benchmark comparison holds. #3–#6 and #8 are cleanup. 🤖 Generated with Claude Code |
A new single-chunk Add currently performs five durable SQLite commits. All journal operations share the writer gate, so repeated commits add storage latency and queueing across concurrent requests.
This change reduces that path to three commits:
Existing atomic inflight intents are reused without an identical rewrite. New multi-chunk requests use 3N commits instead of 3N+2. Completed replays remain read-only. The existing schema, journal mode, synchronous=FULL, per-request locks, and cross-process writer gate remain compatible. No SQLite transaction or global journal gate spans a backend call. Unknown legacy writes retain query-only recovery, and older stored-but-incomplete requests still finish on retry.
Validation:
uv run --extra evaluation pytest -q: 410 passed.git diff --checkpassed.uv run python scripts/benchmark_journal.py --commit-delay-ms 10. Use--source-root /path/to/baseline/agent_memory_leaderboardto run the same harness against the baseline.Local single-run results, 64 one-chunk requests per case, synthetic in-memory backend:
All 1/16/32/64-concurrency cases succeeded with exactly 64 synthetic backend records, both with and without injected latency. Commits fell from 320 to 192 per 64 requests (40% fewer). These are isolated local measurements, not shared-environment capacity results; deployed-storage validation remains necessary. SQLite still has one writer, and this PR does not change probe policy or deploy an image.