Repository navigation
Description
What happened
In the #6366 benchmark, the Rust Host wrote 655.40 GiB over 76,059 tool calls, and disk-write volume was named as one of the next things to improve. I reproduced the write volume on macOS and traced where it goes.
The production Host on rust-preview (57470e4c1, release build) writes about 1.2–1.6 MiB per tool call to the event log, and more with concurrent sessions:
| Workload | Tool calls | Logical writes / call | Storage writes / call |
|---|---|---|---|
| 1 session, 2 tasks | 240 | 1,250 KiB | 1,543 KiB |
| 16 concurrent sessions, 1 task each | 1,920 | 1,646 KiB | 2,620 KiB |
At 16 sessions the database grew by about 40 KiB per tool call (78 MB in all), so the WAL alone wrote about 22 times the data the database kept. Per tool call:
- WAL, 908 KiB: about 6.5 commits, each writing about 35 pages across 15 to 44 tables and indexes. The most-written were
context_source_prefixes(9.4% of WAL pages, two rows per event) and itscontext_source_ordinalsindex (4.4%), thenevent_log,event_material_owner,invocation_sequence,context_semantic_invocation_rowsandsqlite_autoindex_event_log_1(3.4–4.6% each).sqlite_sequencetook 2.4%. - Main database, 471 KiB: checkpoints. The event log uses SQLite's default
wal_autocheckpointof 1,000 pages, so pages that every commit touches, such as the right edge ofevent_log, are copied back on every cycle. - SQLite temp files, 214 KiB: 2,851
etilqs_*files. Their write pattern (a 4-byte page number, then a page) matches statement journals, which spill to disk because the connection setstemp_store = FILE.
The writer already groups consecutive Write requests into one transaction, but commits per tool call were the same with 1 and 16 sessions (6.3 and 6.5). Replaying the recorded commits, even merging every 8 consecutive commits would cut WAL pages by only 32%, because most pages a commit touches belong to one session.
Replaying the same frames with larger checkpoints predicts the main-database writes well: 460 KiB per call at 1,000 pages (471 observed), 305 at 4,000 and 175 at 10,000. An A/B run with PRAGMA wal_autocheckpoint = 10000 confirmed it:
| Workload | Default | 10,000 pages |
|---|---|---|
| 16 sessions, storage writes / call (2 runs each) | 2,627 / 2,614 KiB | 1,589 / 1,576 KiB |
| 16 sessions, logical writes / call | 1,646 / 1,646 KiB | 1,346 / 1,340 KiB |
| 1 session, storage writes / call | 1,543 KiB | 1,162 KiB |
The 16-session runs took 90–134 s with the default and 95–103 s with 10,000 pages, so wall time didn't regress.
How to reproduce
The workload drives a real Host, as scripts/rust/host-comparison does, through host_benchmark_client, with a loopback OpenAI-compatible model:
- Each task is 24 repair cycles of five tool calls:
Readof a 4 KiB file,Grep,Shellrunning a small Python check,Edit, thenShellagain. - Counters come from
proc_pid_rusageon the Host process. Logical writes areri_logical_writes; storage writes areri_diskio_byteswritten. - An interposed
write/pwrite/fsynccounter attributed bytes to files. Pages came from WAL frame headers, mapped to tables and indexes withdbstat.
I can share the harness, or add a macOS variant next to scripts/rust/host-comparison if that's useful. The existing harness reads /proc, so it needs Linux.
Environment
- Maka version or commit:
rust-preview57470e4c1, release build - OS and version: macOS 27.0.1 (arm64)
- Surface: production Host (
maka host serve) driven byhost_benchmark_client - Node.js version, if running from source: 26.10.0
Logs, screenshots, or additional context
I'll open a PR that raises the event log's auto-checkpoint to 10,000 pages, about 40 MiB of WAL at 4 KiB pages. It is a small change with a measured effect, but it only addresses the checkpoint share. The larger share is the number of pages each event touches, and fewer derived tables or indexes per event, or fewer commits per tool call, would be design decisions. @M4n5ter, would you like this split up in a particular way?
At 16 sessions these numbers are well below the 8.8 MiB per call in #6366, which ran 4,096 sessions on Linux. Per-call writes rose with concurrency here (from 1.5 to 2.6 MiB of storage writes going from 1 to 16 sessions), which fits that result, but I haven't run at that scale.
Activity
YongGoose commentedon Nov 8, 2026
take