Persistent KV benchmark (cut C9, sc#485)
Binding design: ADR 0003 (sections 10, 15.1, 16.5). Cut and schema: CUTS.md C9 (B6, B7, B8). Evidence rules: ADR 0001 decisions 2 and 3.
What this measures
bench_persistent_kv runs conversations through the real runtime: the spine, the scheduler, NativeTransformerBackend over ReferenceCpuBackend (host CPU arithmetic, bf16 KV pool) with the synthetic reference test weights, and, for the restore mode, the C4 host filesystem store switched on through the daemon wiring (shared_kv::enable_persistent_kv). Host only: no GPU, no CUDA, no root.
Each row is one mode at one concurrency (1, 2, 4, 8 conversations) and one prompt length (512, 2048 tokens), repeated for a number of rounds:
| mode | workload | what happens | cache_state |
|---|---|---|---|
resident-only | single_turn | one request per conversation, store off; nothing ever leaves memory | none |
cold-prefill | second_turn | turn 1, then turn 2 (turn-1 prompt + turn-1 output + 16 new tokens), store off; turn 2 prefills everything | none |
restore-from-page-cache | second_turn | the same turns with the store on: turn 1 parks, turn 2 restores the stored prefix and prefills only the rest. The objects were written moments before and no cache was dropped. A row is refused unless every measured request committed a restore | page_cache |
restore-from-device | NOT_RUN: a device read needs the page cache dropped (root) and verified empty (ADR 15.1); the harness never uses sudo | device | |
native-physical (Spark, Pi 5) | NOT_RUN in every report (B8): a host run cannot speak for native hardware | device |
Only the turn-2 requests (or the single turn of resident-only) are timed. Every report records, per row: completed and failed requests, request latency p50/p95, time to first token p50/p95, decode tokens per second, the KV pool allocation, the peak holder bytes, the staging bytes, the peak RSS, the store dispatch depth, the restored token count, and every raw sample. The exact definition of each field is written into the report itself (definitions).
Rules the binary enforces (tests in crates/aien-kv-bench/tests/bench_persistent_kv_test.rs):
- no row without its mode, platform and cache_state labels, and no default mode (B7);
- no measured row without every metric of the B6 schema, percentiles that match the raw samples, and at least one completed request (B6);
- latency summaries never mix cache states (ADR 15.1);
- every report carries the Spark-native and Pi 5 physical rows as NOT_RUN with a reason, and refuses measured numbers for any platform other than
hosted(B8); - a report is never overwritten; it records the commit, whether the tree was clean, the machine, the nice value, the exact command and the sha256 of the raw samples.
How to reproduce
cargo build --release -p aien-kv-bench --bin bench_persistent_kv
nice -n 19 ./target/release/bench_persistent_kv \
--modes resident-only,cold-prefill,restore-from-page-cache,restore-from-device \
--concurrency 1,2,4,8 --prompt-tokens 512,2048 --rounds 10 \
--out benchmarks/data/persistent_kv_host_<UTC stamp>.json --store-root target/pkv-bench-store
./target/release/bench_persistent_kv --render benchmarks/data/persistent_kv_host_<UTC stamp>.json
--render re-checks the report (schema, labels, NOT_RUN rows, samples digest) and prints the table below.
Where the numbers live (ADR 0001)
The canonical record is the JSON file in benchmarks/data/, named by its measurement id. ADR 0001 names benchmarks/data/benchmarks_latest.json and a sync-docs tool; neither exists in the repository (also recorded in docs/plans/public-surface-cleanup.md). DOCS SILENT choice, narrowest rule: this bench writes its own file and never edits latest.json, master_benchmark_results.json or the inference sweep files, and the table below is generated by --render from that file, not typed by hand.
Results (host, generated from benchmarks/data/persistent_kv_host_20261014T010721Z.json)
Measurement BENCH-PKV-HOST-20261014T010721Z-5a07c36, commit 5a07c36ab753276f760494863f9a2b7585bb57ff, 2026-10-14T01:07:21Z UTC, platform hosted, backend NativeTransformerBackend over ReferenceCpuBackend (host CPU, FP32 arithmetic, bf16 KV pool), host: the DGX Spark (aarch64, 20 CPUs, kernel 7.0.0-1019-nvidia, nice 19).
Command: bench_persistent_kv --modes resident-only,cold-prefill,restore-from-page-cache,restore-from-device --concurrency 1,2,4,8 --prompt-tokens 512,2048 --rounds 10 --out benchmarks/data/persistent_kv_host_20261014T010721Z.json --store-root target/pkv-bench-store
| mode | status | cache_state | conc | prompt | done/failed | p50 us | p95 us | ttft p50 us | ttft p95 us | decode tok/s | restored tok | pool bytes | holder peak | staging | peak RSS | queue depth |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| resident-only | OK | none | 1 | 512 | 10/0 | 26885 | 30765 | 21703 | 27365 | 3503 | 0 | 528384 | 0 | 0 | 6914048 | 0 |
| resident-only | OK | none | 2 | 512 | 20/0 | 67801 | 77390 | 43922 | 50057 | 1247 | 0 | 860160 | 0 | 0 | 7282688 | 0 |
| resident-only | OK | none | 4 | 512 | 40/0 | 120314 | 128336 | 86016 | 91213 | 1692 | 0 | 1523712 | 0 | 0 | 8007680 | 0 |
| resident-only | OK | none | 8 | 512 | 80/0 | 212563 | 236190 | 158525 | 188198 | 2343 | 0 | 2850816 | 0 | 0 | 9412608 | 0 |
| resident-only | OK | none | 1 | 2048 | 10/0 | 224236 | 229344 | 211023 | 216721 | 1180 | 0 | 1413120 | 0 | 0 | 13832192 | 0 |
| resident-only | OK | none | 2 | 2048 | 20/0 | 477043 | 486085 | 422782 | 435221 | 592 | 0 | 2629632 | 0 | 0 | 15171584 | 0 |
| resident-only | OK | none | 4 | 2048 | 40/0 | 944657 | 959201 | 447167 | 866841 | 116 | 0 | 5062656 | 0 | 0 | 17678336 | 0 |
| resident-only | OK | none | 8 | 2048 | 80/0 | 1850602 | 1886412 | 862684 | 1730094 | 84 | 0 | 9928704 | 0 | 0 | 22790144 | 0 |
| cold-prefill | OK | none | 1 | 512 | 10/0 | 25947 | 30202 | 21395 | 25301 | 3562 | 0 | 528384 | 0 | 0 | 13389824 | 0 |
| cold-prefill | OK | none | 2 | 512 | 20/0 | 73385 | 85255 | 45830 | 59546 | 1151 | 0 | 860160 | 0 | 0 | 13721600 | 0 |
| cold-prefill | OK | none | 4 | 512 | 40/0 | 115292 | 139358 | 85367 | 100550 | 1758 | 0 | 1523712 | 0 | 0 | 14385152 | 0 |
| cold-prefill | OK | none | 8 | 512 | 80/0 | 239925 | 250341 | 172002 | 189685 | 1742 | 0 | 2850816 | 0 | 0 | 15712256 | 0 |
| cold-prefill | OK | none | 1 | 2048 | 10/0 | 232470 | 236956 | 219789 | 224248 | 1163 | 0 | 1413120 | 0 | 0 | 15151104 | 0 |
| cold-prefill | OK | none | 2 | 2048 | 20/0 | 491399 | 519864 | 437217 | 456114 | 431 | 0 | 2629632 | 0 | 0 | 16408576 | 0 |
| cold-prefill | OK | none | 4 | 2048 | 40/0 | 948655 | 962056 | 839660 | 870338 | 113 | 0 | 5062656 | 0 | 0 | 18948096 | 0 |
| cold-prefill | OK | none | 8 | 2048 | 80/0 | 1871585 | 1906118 | 1267748 | 1753110 | 82 | 0 | 9928704 | 0 | 0 | 24383488 | 0 |
| restore-from-page-cache | OK | page_cache | 1 | 512 | 10/0 | 10063 | 11884 | 3712 | 4969 | 2682 | 5120 | 528384 | 101376 | 3072 | 15319040 | 4 |
| restore-from-page-cache | OK | page_cache | 2 | 512 | 20/0 | 33386 | 38450 | 3769 | 7329 | 1020 | 10240 | 860160 | 202752 | 3072 | 15843328 | 4 |
| restore-from-page-cache | OK | page_cache | 4 | 512 | 40/0 | 45491 | 56199 | 12347 | 14196 | 1356 | 20480 | 1523712 | 405504 | 3072 | 16506880 | 4 |
| restore-from-page-cache | OK | page_cache | 8 | 512 | 80/0 | 75847 | 82291 | 23789 | 28650 | 1634 | 40960 | 2850816 | 811008 | 3072 | 17854464 | 4 |
| restore-from-page-cache | OK | page_cache | 1 | 2048 | 10/0 | 36360 | 40269 | 11278 | 15391 | 749 | 20480 | 1413120 | 396288 | 3072 | 16416768 | 4 |
| restore-from-page-cache | OK | page_cache | 2 | 2048 | 20/0 | 76298 | 87144 | 12971 | 23796 | 447 | 40960 | 2629632 | 792576 | 3072 | 17645568 | 4 |
| restore-from-page-cache | OK | page_cache | 4 | 2048 | 40/0 | 135964 | 156081 | 38842 | 53965 | 486 | 81920 | 5062656 | 1585152 | 3072 | 20094976 | 4 |
| restore-from-page-cache | OK | page_cache | 8 | 2048 | 80/0 | 215189 | 248743 | 72130 | 91416 | 560 | 163840 | 9928704 | 3170304 | 3072 | 25022464 | 4 |
| restore-from-device (hosted) | NOT_RUN | device | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| native-physical (native_physical) | NOT_RUN | device | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| native-physical (native physical (Pi 5)) | NOT_RUN | device | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
NOT_RUN reasons:
- restore-from-device (hosted): a device read needs the page cache dropped (root: /proc/sys/vm/drop_caches) and verified empty with mincore (ADR 0003 section 15.1); this harness never uses sudo, and O_DIRECT reads are cut X1/X2
- native-physical (native_physical): Spark-native physical run is blocked on aienos#336 (not authorized); a host run cannot stand in for it
- native-physical (native physical (Pi 5)): Pi 5 physical lane is cut P3 (ADR 16), needs Drake's authorization and a free Pi; not run
What the run shows, and what it does not
- The numbers come from a tiny synthetic model on the CPU. They show how the harness and the persistent KV path behave against each other on this machine; they say nothing about real model speed, GB10 speed, or NVMe speed.
- Turn-2 requests that restore their prefix from the page cache reach their first token sooner than the same requests prefilled cold, at every concurrency of this run (compare
ttftofcold-prefillandrestore-from-page-cachein the table). - Store bounds (finding of the first full run, refused by the row guard and not recorded): with the default per-class bounds (48 restore, 16 park at the time, ADR 7.1), 8 conversations finishing in the same step submit 24 chunk parks and 8 are refused
QueueFull. That is the designed behaviour (not parked this turn, the next turn prefills), but it means the defaults are too small for 8 simultaneous finishes. The bench now setsAIEN_KV_STORE_MAX_RESTORE_OPSandAIEN_KV_STORE_MAX_PARK_OPSto concurrency times the chunks per turn plus one; the park default is now 64 (ADR 0003 section 18.4). resident-onlyis a single turn, so its latency is not a turn-2 number; it is the reference for a conversation that never leaves memory (this runtime has no cross-request resident prefix reuse to measure a resident turn 2).- Not measured: device reads, O_DIRECT, the queue-depth sweep, CPU time per MiB and the device ceiling (cut X1), and every native row.